akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!

n=input().rstrip().split(" ")
n[0]=int(n[0])
n[1]=int(n[1])
if n[1]>=0:
    terget=0
elif n[1]+n[0]<=0:
    terget=n[0]-1
else:
    terget=-(n[1])
ans=n[1]*(n[0]-1)
#print(ans)
ans=ans+int(n[0]*(n[0]-1)/2)
#print(int(n[0]*(n[0]-1)/2))
print(ans-terget)
#print(terget)

Measured memory_bytes: 3064
n, m, x, y = map(int, input().split())
xw = list(map(int, input().split()))
yw = list(map(int, input().split()))
xm = max(x, max(xw))
ym = min(y, min(yw))
if xm < ym:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 500000 + 9;
ll n,x,sum,mod=1e9+7,ans;

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n;
        forr(i,1,n)
        {
            cin>>x;
            ans+= (x*sum)%mod;
            ans%=mod;
            sum+=x;
            sum%=mod;
        }

        cout<<(ans+mod)%mod<<endl;








return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
const int maxn = (int)1e5;

vector<int> edges[maxn];
int dp[2][maxn] = {0};
bool visi[maxn] = {0};
void dfs(int v, int par, int d, int p){
	visi[v]= true;
	dp[p][v] += d;
	for(auto x : edges[v]){
		if(x==par) continue;
		if(!visi[x])
		dfs(x, v, d + 1, p);
	}
}
void solve(){
	int n, u, v;cin>>n>>u>>v;
	--u;--v;
	for0(i, n-1){
		int x, y;cin>>x>>y;
		--x;--y;
		edges[x].pb(y);
		edges[y].pb(x);
	}
	dfs(u, -1, 0, 0);
	assign(visi, 0);
	dfs(v, -1, 0, 1);
	int ans = 0;
	for0(i,n){
		if(dp[0][i]>=dp[1][i]) continue;
		ans = max(ans, dp[1][i]-1);
	}	
	cout<<ans<<endl;
}
 
int main(){
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	string s,t;
	cin >> s;
	cin >> t;
	
	
	rep(i,n){
		cout << s[i] << t[i];
	}
	
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    if(n % 2 == 1) {
        cout << n / 2 + 1 << endl;
    }else{
        cout << n/2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n := nextInt()
	var re float64
	for index := 0; index < n; index++ {
		nn := nextInt()
		re += 1 / float64(nn)
	}

	fmt.Println(1 / re)
}


Measured memory_bytes: 640
# coding: utf-8

# https://atcoder.jp/contests/abc089/tasks/abc089_d
# 17:17-18:17 read testcase
# 18:17-18:26 done


def main():
    H, W, D = map(int, input().split())
    A = [None] * H
    for i in range(H):
        A[i] = list(map(int, input().split()))
    Q = int(input())
    L, R = [None] * Q, [None] * Q
    for i in range(Q):
        L[i], R[i] = map(int, input().split())
        L[i] -= 1  # 1-index => 0-index
        R[i] -= 1  # 1-index => 0-index
    
    if D == H*W:
        for _ in range(Q):
            print(0)
        return None

    positions = [None] * (H*W)
    for i in range(H):
        for j in range(W):
            positions[A[i][j]-1] = (i, j)

    n_graph = D if D <= (H*W)//2 else (H*W)-D

    graphs = [[] for _ in range(n_graph)]

    for start in range(n_graph):
        cost = 0
        start_x, start_y = positions[start]
        m = 0
        while start + m*D < H*W:
            to_x, to_y = positions[start + m*D]
            cost += abs(to_x-start_x) + abs(to_y-start_y)
            graphs[start].append(cost)
            start_x, start_y = to_x, to_y
            m += 1

    for l, r in zip(L, R):
        graph_num = l % n_graph
        graph = graphs[graph_num]
        print(graph[r//D] - graph[l//D])


main()
# print(main())


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

using namespace std;

const int N = 2002, S = 2000 * 2000 + 2;
bitset<S>last, curr;
int n, a[N], stot;
int main() {
   //freopen("J.in", "r", stdin);
   cin >> n;
   last[0] = 1;

   for(int i = 1; i <= n; ++i) {
      cin >> a[i];
      stot += a[i];
      curr = last;
      curr |= curr << a[i];
      last = curr;
   }

   int mn = 1e9;
   for(int q = 0 ; q <= stot ; ++q)
   {
       if(curr[q])
       mn = min(mn , max(q , stot - q));
   }
   cout << mn;
}


Measured memory_bytes: 2176
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = 2;
      
	if(a%2==0){
      System.out.println(a);
    }else{
       System.out.println(a*b);
    }
      
    }
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int tmp=0;
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(a>c){
        tmp=a;
        a=c;
        c=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
int H[111111];

int main() {
	scanf("%d", &n);
	REP(i, n) scanf("%d", H+i);
	int curr = 0;
	int best = 0;
	for(int i = n-2; i >= 0; i--) {
		if(H[i] >= H[i+1]) {
			curr++;
			best = max(curr, best);
		} else {
			curr = 0;
		}

	}
	printf("%d\n", best);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    string t;
    cin>>t;
    string t2;
    t2 = t.substr(0,sz(t)-1);
    if(t2==s && sz(t)==sz(s)+1)cout<<"Yes\n";
    else cout<<"No\n";
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	int d , n ;
	cin >> d >> n ;
	int ans = pow(100,d) + pow(100,d) * (n-1); 
	if(n==100) ans += pow(100,d);
	cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
hs = gets.split.map(&:to_i)

max = 0
cur = 0

n.times do |i|
  right = i == n - 1 ? 10000000000 : hs[i+1]

  if hs[i] >= right
    cur += 1
  else
    cur = 0
  end

  max = [max, cur].max
end

p max


Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // 回数変数
  int times;
  cin >> times;
  
  // 出目用変数
  int d1, d2;
  // ゾロ目回数カウント用変数
  int count = 0;
  // 出力用変数
  string output = "No";
  
  // 回数分繰り返し
  for (int i = 1; i <= times; i++)
  {
    cin >> d1 >> d2;
    
    if (d1 == d2)
    {
	  count += 1;
      
      if (count >= 3)
      {
        break;
      }
    }
    else
    {
      count = 0;
    }
  }
  
  if (count >= 3) output = "Yes";
  
  cout << output << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

struct CustomCompare{
    bool operator()(const ll& lhs, const ll& rhs){
        return lhs < rhs;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll, vector<ll>, CustomCompare > que;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        que.push(a);
    }
    for(int i = 0; i < m; i++){
        ll p = que.top();
        que.pop();
        que.push( p / 2);
    }
    ll ans = 0LL;
    while(!que.empty()){
        ll p = que.top();
        ans += p;
        que.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
import math

# スペース区切りの整数の入力
a, b = map(int, input().split())

c = b
if (b < 10):
    c += a*10
elif (b < 100):
    c += a * 100
else:
    c += a * 1000

if ( math.sqrt(c) % 1 == 0 ):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9240
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n = 1000001;
    vector<bool> prime(n, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i < n; i++) {
        if (prime[i]) {
            for (int j = 2 * i; j < n; j += i) {
                prime[j] = false;
            }
        }
    }

    long long a, b;
    cin >> a >> b;

    long long ia = a;
    vector<long long> a_fact(1, 1);
    for (long long i = 2; i < n; i++) {
        if (prime[i] && ia % i == 0) {
            a_fact.push_back(i);
            while (ia % i == 0) {
                ia /= i;
            }
        }
    }
    if (ia > n - 1) {
        a_fact.push_back(ia);
    }

    long long ib = b;
    vector<long long> b_fact(1, 1);
    for (long long i = 2; i < n; i++) {
        if (prime[i] && ib % i == 0) {
            b_fact.push_back(i);
            while (ib % i == 0) {
                ib /= i;
            }
        }
    }
    if (ib > n - 1) {
        b_fact.push_back(ib);
    }

    int res = 0;
    for (int ia = 0, ib = 0;
            ia < static_cast<int>(a_fact.size()) && ib < static_cast<int>(b_fact.size()); ) {
        if (a_fact[ia] == b_fact[ib]) {
            res++;
            ia++;
            ib++;
        } else if (a_fact[ia] < b_fact[ib]) {
            ia++;
        } else {
            ib++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 384
import sys


N,K = map(int,input().split())

if N == K:
    print (0)
    sys.exit()

H = list(map(int,input().split()))


dp = [[None] * (N-K+1) for i in range(N) ]

for i in range(N):

    nh = H[i]

    dp[i][1] = nh

    for j in range(i):
        for k in range(N-K):

            if dp[j][k] != None:

                if dp[i][k+1] == None:
                    
                    dp[i][k+1] = dp[j][k] + max(0, H[i]-H[j])

                else:

                    dp[i][k+1] = min(dp[i][k+1] , dp[j][k] + max(0, H[i]-H[j]))

ans = float("inf")
for i in range(N):

    if dp[i][-1] != None:
        ans = min(ans,dp[i][-1])

print (ans)



Measured memory_bytes: 45004
#include <cstdio>

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

    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

struct job {
    int time, dl;

    bool operator<(const job& other) const {
        return dl < other.dl;
    }
};

void nope() {
    cout << "No\n";
    exit(0);
}

int32_t main() {

    int n; cin >> n;
    vector<job> jobs(n);
    for(int i = 0; i < n; ++i) {
        cin >> jobs[i].time >> jobs[i].dl;
    }

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

    int time = 0;
    for(job j : jobs) {
        time += j.time;
        if(time > j.dl) nope();
    }

    cout << "Yes\n";
    
    return 0;
}


Measured memory_bytes: 3328
#[allow(unused_imports)]
use std::io::stdin;
 
#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let n: usize = scan.next();
    let a: Vec<usize> = (0..n).map(|_| scan.next()).collect();
    let b: Vec<usize> = (0..n).map(|_| scan.next()).collect();
    let c: Vec<usize> = (0..n-1).map(|_| scan.next()).collect();
    let mut prev: Option<usize> = None;
    let result = a.iter().fold(0, |sum, i| {
        let s = sum + b[*i-1] + if let Some(p) = prev {
            if p + 1 == *i {
                c[p-1]
            } else {
                0
            }
        } else {
            0
        };
        prev = Some(*i);
        s
    });
    println!("{}", result);
}


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

int n;
string a, b, c;

int main(){
	cin >> n >> a >> b >> c;
	int tot = 0;
	unordered_set<char> s;
	for (int i = 0; i < n; i++){
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		if (s.size() == 2) tot++;
		else if (s.size() == 3) tot += 2;
		s.clear();
	}
	cout << tot << '\n';
	return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n,k;
  cin>>n>>k;
  vector<long>arr(n);
  for(int i=0;i<n;i++)
  cin>>arr[i];
  sort(arr.begin(),arr.end());
  long sum=0;
  for(int i=0;i<n-k;i++)
  sum+=arr[i];
  cout<<sum<<endl;
  

  
  

  
    
}

Measured memory_bytes: 1792
n=int(input())
xlist=[]
ylist=[]
v=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
  if v[i]>c[i]:
    xlist.append(v[i])
    ylist.append(c[i])
ans=0
ans=sum(xlist)-sum(ylist)
print(ans)

Measured memory_bytes: 3064
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define MP(a,b) make_pair(a,b)
#define debug(x)       cerr<< #x << " : " << x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[i].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll gcd (ll x , ll y){
    if (x < y) swap (x , y);
    while (y){
        ll temp = y;
        y = x % y;
        x = temp; 
    }
    return x;
}

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
   ll a , b;
   cin >> a >> b;
   cout << a*b<<endl;
}
int main(){
    IOS;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
}


Measured memory_bytes: 3804
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int index = int.Parse(Console.ReadLine());
            double oddCount = 0;
            double answer = 0;
            if(index % 2 == 0)
            {
                oddCount = index / 2;
                answer = oddCount / index;
            }
            else
            {
                oddCount = index / 2 + 1;
                answer = oddCount / index;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    list<int> b;
    if(n%2==0){
        for(int i=0; i<n-1; i+=2){
            b.PB(a.at(i));
            b.PF(a.at(i+1));
        }
    }
    if(n%2==1){
        rep(i,n){
            if(i%2==0){
                b.PF(a.at(i));
            }
            else{
                b.PB(a.at(i));
            }
        }
    }
    for(auto i=b.begin(); i!=b.end(); i++){
        cout << *(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 9216
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool Same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};


signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,m;
  cin >> n >> m;
  UnionFindTree uf(n+10);
  for(int i=1;i<=m;i++){
    int x,y;
    cin >> x >> y;
    uf.unite(x,y);
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    if(uf.find(i)==i)cnt++;
  }
  cout << (cnt-1) << endl;
  


return 0;
}
///....


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

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

	return 0;
}

Measured memory_bytes: 128
a,b = map(int, input().split())

def gcd(x, y):
    if y < x:
        x,y = y,x
    while x%y != 0:
        x,y = y,x%y
    return y

def lcm(x, y):
    return (x*y)//gcd(x,y)

print(lcm(a,b))

Measured memory_bytes: 3060
#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)
#define MOD 1000000007

int main(){
    int n, m;
    cin >> n >> m;
    pair<int, int> p[n];
    rep(i, n){
        p[i] = pair<int, int>(0,0);
    }
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a==0){
            p[b].first= 1;
        }
        if(b==n-1){
            p[a].second=1;
        }
    }
    rep(i, n){
        if(p[i]==P(1,1)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

        String nr = sc.nextLine();

        int N = Integer.parseInt(nr.split(" ")[0]);
        int R = Integer.parseInt(nr.split(" ")[1]);

        if(10 <= N){
            System.out.println(R);
        } else {
            System.out.println(R + (100 * (10 - N)));
        }

    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    if(s[0]=='S'){
        cout << "Cloudy" << endl;
    }else if(s[0]=='C'){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}


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

int main (void)
{
	char input[200];
	char before_shuffle[200],after_shuffle[200];
	char result[10][200];
	int loop_count,shuffle_count,data_num;
	int i,j;
	
	data_num = 0;
	
	for(i = 0 ; i < 200 ; i++)
	{
		input[i] = '\0';
		before_shuffle[i] = '\0';
		after_shuffle[i] = '\0';
		for(j = 0 ; j < 10 ; j++)
		{
			result[j][i] = '\0';
		}
	}
	
	while(1)
	{
		scanf("%s",input);
		if(strcmp(input,"-") == 0)
		{
			break;
		}
		scanf("%d",&loop_count);
		for(i = 0 ; i < loop_count ; i++)
		{
			scanf("%d",&shuffle_count);
			strncpy(before_shuffle,input,shuffle_count);
			strncpy(after_shuffle,&input[shuffle_count],200-shuffle_count);
			strcat(after_shuffle,before_shuffle);
			strcpy(input,after_shuffle);
			
			for(j = 0 ; j < 200 ; j++)
			{
				before_shuffle[j] = '\0';
				after_shuffle[j] = '\0';
			}
		}
		strcpy(result[data_num],input);
		data_num++;
	}
	for(i = 0 ; i < data_num ; i++)
	{
		printf("%s\n",result[i]);
	}
	return 0;
}


Measured memory_bytes: 2060
import copy

s = input()
n = len(s)-1
ans = 0

for i in range(2 ** n):
    x = copy.deepcopy(s)
    y = 1
    for j in range(n):
        if ((i >> j) & 1): #フラグが立っていたら
            x = x[:j+y] + "+" + x[j+y:]
            y += 1
    ans += eval(x)

print(ans)

Measured memory_bytes: 3444
#!/usr/bin/env python3
import sys
import heapq


inf = float("inf")

def solve(N: int, a: "List[int]"):
    L = a[:N]
    R = [-x for x in a[2*N:]]
    heapq.heapify(L)
    heapq.heapify(R)
    M = a[N:2*N]
    sumL = [0 for _ in range(N+1)] # sumL[i]: a[0]からa[N-1+i]までの大きい順にN個の和
    sumR = [0 for _ in range(N+1)] # sumR[i]: -(a[N-1+i]からa[3*N-1]までの小さい順にN個の和)

    sumL[0] = sum(L)
    sumR[N] = sum(R)

    for i in range(N):
        heapq.heappush(L, M[i])
        l = heapq.heappop(L)
        diff = M[i] - l
        sumL[i+1] = sumL[i] + diff
    
    for i in range(N-1, -1, -1):
        heapq.heappush(R, -M[i])
        r = heapq.heappop(R)
        diff = -M[i] - r
        sumR[i] = sumR[i+1] + diff
    
    res = max(suml + sumr for suml, sumr in zip(sumL, sumR))
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(3*N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	const int d = abs(b - a);
	cout << (d % 2 == 0 ? "Alice" : "Borys") << endl;
	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    for (auto p : v) cout << p << ",";
    cout << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __DJKIM613
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

const int MAXN = 1e5 + 10;
int N;
int H[MAXN];
int D[MAXN];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> N;
    for(int i = 1 ; i <= N ; i++) cin >> H[i];

    for(int i = 2 ; i <= N ; i++) {
        D[i] = D[i - 1] + abs(H[i] - H[i - 1]);
        if(i > 2) D[i] = min(D[i], D[i - 2] + abs(H[i] - H[i- 2]));
    } 

    cout << D[N];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    const string pl[] = {"First", "Second"};

    string s;
    cin >> s;

    cout << pl[(s[0] == s.back()) ^ (SZ(s) & 1) ^ 1] << '\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int p[10],c[10],dp[1001],d,g;
int main(){

  cin>>d>>g;
  for(int i=0;i<d;i++){
    cin>>p[i]>>c[i];
  }
  for(int i=0;i<d;i++){
    for(int k=1000;k>=1;k--){
      for(int j=1;j<=p[i]&&j<=k;j++){
        dp[k]=max(dp[k],dp[k-j]+j*100*(i+1)+(j==p[i]?c[i]:0));
      }
    }
  }
  for(int i=0;i<=1000;i++){
    if(dp[i]>=g){cout<<i<<endl;return 0;}
  }
}


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


int main(){
    int a[9];
    int mask[8];
    mask[0] = (1<<0) | (1<<1) | (1<<2);
    mask[1] = (1<<3) | (1<<4) | (1<<5);
    mask[2] = (1<<6) | (1<<7) | (1<<8);
    mask[3] = (1<<0) | (1<<3) | (1<<6);
    mask[4] = (1<<1) | (1<<4) | (1<<7);
    mask[5] = (1<<2) | (1<<5) | (1<<8);
    mask[6] = (1<<0) | (1<<4) | (1<<8);
    mask[7] = (1<<2) | (1<<4) | (1<<6);

    for(int i=0; i<9; i++){
        cin >> a[i];
    }

    int n;
    cin >> n;
    int b[n];

    for(int i=0; i<n; i++){
        cin >> b[i];
    }

    int bmp = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<9; j++){
            if(b[i] == a[j]){
                bmp |= (1<<j);
            }
        }
    }
    
    int i;
    for(i=0; i<8; i++){
        if((mask[i] & bmp) == mask[i]){
            cout << "Yes" << endl;
            break;
        }
    }
    if(i==8){
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;cin>>s;
    string x ="";
    for(int i =0;i<3;i++){
        x+=s[i];
    }
    cout<<x<<endl;

}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N + 5);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
  }
  bool ok = true;
  int cur = 1, cnt = 0;
  while (cur != 2 and ok) {
    int next = A[cur];
    A[cur] = -1;
    ++cnt;
    if (next == -1) { ok = false; }
    cur = next;
  }
  printf("%d\n", ok ? cnt : -1);
  return 0;
}


Measured memory_bytes: 640
input=gets.to_i

array=[]
input.times{
    ss=gets.split
    array<<ss.map(&:to_i)
    
}
max=0
j=0
score=0
input.times{
    if array[j][0]>max
      max=array[j][0]
      score=j
     end
     
     j=j+1
    
}


puts array[score][0]+array[score][1]



Measured memory_bytes: 9596
#include<cstdio>
using namespace std;
int N,M,P[100005],bb[100005],ans;
int find(int x)
{
    if(bb[x]!=x)
   	bb[x]=find(bb[x]);
    return bb[x];
}
void hb(int x,int y)
{
	int a=find(x),b=find(y);
	if(a!=b)
	bb[b]=a;
	return ;
}
int main()
{
	scanf("%d %d",&N,&M);
	for(int i=1;i<=N;i++)
	{
		bb[i]=i;
		scanf("%d",&P[i]);
	}
	for(int i=1,a,b;i<=M;i++)
	{
		scanf("%d %d",&a,&b);
		hb(a,b);
	}
	for(int i=1;i<=N;i++)
	{
		if(find(i)==find(P[i]))
		ans++;
	}
	printf("%d",ans);
	return 0;
}

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

int main(int argc, char *argv[]){
  int A,B,C;
  cin>>A>>B>>C;
  vector<int> vec(3,0);
  vec[0]=A;
  vec[1]=B;
  vec[2]=C;
  int count=0;
  while(true){
    sort(vec.begin(),vec.end());
    if(vec[1]==vec[2]) break;
    vec[0]++;
    vec[1]++;
    count++;
  }
  while(true){
    if(vec[0]>=vec[1]) break;
    vec[0]+=2;
    count++;
  }
  if(vec[0]==vec[1]){
    cout<<count<<endl;
  }
  else if(vec[0]>vec[1]){
    cout<<count+1<<endl;
  }
}
			 
    
    


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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){

	cin >>n;
	int prev_dp[3];
	
	int dp[3];
	init(prev_dp);
	v.resize(3);
	for(int i =0;i<n;i++){
		init(dp);
		for(int j=0;j<3;j++){
			cin >> v[j];
		}
		for(int j =0;j<3;j++){
			for(int e= 0;e<3;e++){
				if(j==e)continue;
				dp[j]=max(prev_dp[e],dp[j]);
			}
			dp[j]+=v[j];
		}
		for(int j=0;j<3;j++){
			prev_dp[j] = dp[j];
		}
	}
	cout << max({dp[0],dp[1],dp[2]});

	
	return 0;
}

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

int isprime(int);

int main(){

  int seisu[10000],i,r,s=0,n;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&seisu[i]);
   
  }

  for(i=0;i<n;i++){
    r=isprime(seisu[i]);
    if(r==1) s++;
  }

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

  return 0;
}



int isprime(int x){
  int i;
   
  if(x==2) return 1;
  else if(x<2 || x%2==0) return 0;
  
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
      i=i+2;
  }
         return 1;
    
  } 

Measured memory_bytes: 628
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


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

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	ll ans = 0;
	for (int i = 0; i < n; i++){
		auto iter1 = lower_bound(a.begin(), a.end(), b[i]);
		auto iter2 = upper_bound(c.begin(), c.end(), b[i]);
		ll temp1 = iter1 - a.begin();
		ll temp2 = c.end() - iter2;
		ans += temp1*temp2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
def main():
    n, *a, = map(int, open(0).read().split())
    m = max(a)

    d = [0] * (m + 1)
    d[1] = 1
    for i in range(2, m + 1):
        for j in range(i, m + 1, i):
            if d[j] == 0:
                d[j] = i

    def primes(x):
        ps = set()
        while x != 1:
            p = d[x]
            ps.add(p)
            x = x // d[x]
        return ps

    b = set()
    c = primes(a[0])
    f = 0
    for i in a:
        ps = primes(i)
        if f == 0:
            if b & ps:
                f = 1
            b |= ps
        c &= ps
    else:
        if f == 1 and len(c) > 0:
            f = 2
    
    ans = ["pairwise coprime", "setwise coprime", "not coprime"][f]
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int a, b, c;
    cin >> a >> b >> c;

    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
len_li = [0]
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        cnt+=1
    else:
        len_li.append(cnt)
        cnt = 0 
len_li.append(cnt)
print(max(len_li))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

vector<string> vec = {
    "dreamer",
    "dream",
    "eraser",
    "erase"};

string string_check(int start, string s)
{
    for (int i = 0; i < 4; ++i)
    {
        if (vec[i] == s.substr(start, vec[i].length()))
        {
            if (start + vec[i].length() == s.length())
                return "YES";
            if (string_check(start + vec[i].length(), s) == "YES")
                return "YES";
        }
    }
    return "NO";
}
int main(void)
{
    string S;
    cin >> S;
    int count = 0;

    cout << string_check(0, S) << "\n";
}

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

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

    long long n=0, f=0;
    for(int i=0;i<s.size();i++){
        n=n*10+(s[i]-'0');
        f+=s[i]-'0';
    }

    if(n%f==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i<N; i++ ) {
    string a;
    cin >> a;
    if (a == "Y") {
      cout << "Four" << endl;
    break;
    }
    if (i == N-1) {
      cout << "Three" << endl;
    }
  }
}
    



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

int main() {
  int N, K ;
  cin >> N >> K;
  int b = 1;
  int u = K;
  int ans = 1;
  while (true){
    if (b <= N && N < u){
      break;
    }
    b *= K;
    u *= K;
    ans++;
}
  cout << ans << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> s(M),c(M),ans(N,0);
  map<int,int> m;
  for(int i=0;i<M;i++){
    cin >> s.at(i) >> c.at(i);
    if(m.count(s.at(i))){
      if(m.at(s.at(i))!=c.at(i)){
          cout << -1 << endl;
          return 0;
      }
    }else{
      m[s.at(i)]=c.at(i);
    }
    if(N!=1){
      if(s.at(i)==1){
        if(c.at(i)==0){
          cout << -1 << endl;
          return 0;
        }
      }
    }
    ans.at(s.at(i)-1)=c.at(i);
  }
  if(ans.size()!=1){
    if(ans.at(0)==0){
      ans.at(0)=1;
    }
  }
  for(int i=0;i<N;i++){
    cout << ans.at(i);
    if(i==N-1){
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//Shunji Lin 08-144505
#include <iostream>
#include <algorithm>

using namespace std;

struct item { // value and weight for each item
  int value; 
  int weight;
};


int grid[100][100001] = {{0}}; // table for DP
item items[100]; // array to store item properties

int main()
{
  int N, W; // no. of inputs, max weight
  cin >> N >> W;

  for (int i = 0; i < N; ++i) {
    cin >> items[i].value >> items[i].weight;
    grid[i][0] = 0; // initialize first column
  }

  for (int i = 0; i <= W; ++i) {
    grid[0][i] = (items[0].weight <= i)?items[0].value:0; //initialize first row
  }

  for(int i = 1; i < N; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (items[i].weight <= j) {
	grid[i][j] = max(items[i].value + grid[i-1][j-items[i].weight], grid[i-1][j]);
      } else {
	grid[i][j] = grid[i-1][j];
      }
    }
  }

    cout << grid[N-1][W] << endl;
  
  return 0;
}

Measured memory_bytes: 38280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// エラトステネスの篩
vector<LL> prime_list(LL max_val){
    vector<LL> memo(max_val+1);
    vector<LL> res;
    for(LL v = 2; v <= max_val; ++v){
        if(memo[v]) continue;
        res.push_back(v);
        for(LL k = v; k <= max_val; k += v) memo[k] = 1;
    }
    return res;
}


int main(){
    LL n;
    cin >> n;
    vector<LL> primes = prime_list(1000000);
    LL cur = 0;
    while(primes[cur] < n) ++cur;
    cout << primes[cur] << endl;
    return 0;
}



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


int main(){
    string w;
    cin >> w;
    int n = w.size();
    unordered_map<char, int> counter;
    rep(i,n) counter[w[i]]++;
    bool flag = true;
    for(auto itr = counter.begin(); itr != counter.end(); ++itr){
        if(itr->second&1) flag = false;
    }
    cout << (flag ? "Yes\n" : "No\n");

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    D = int(input().strip())
    C = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    S = np.empty((D, 26), dtype=np.int32)
    for i in range(D):
        s = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
        S[i, :] = s[:]
    return D, C, S


@njit
def satisfaction(d, C, last):
    v = 0
    for i in range(26):
        v -= C[i] * ((d+1) - last[i])
    return v


@njit
def solve(D, C, S):
    last = np.zeros(26, dtype=np.int32)
    cumsat = 0
    for i in range(D):
        maxt = 0
        maxsat = -999999999
        basesat = satisfaction(i, C, last)
        for t in range(26):
            u = S[i, t] + C[t] * ((i+1) - last[t])
            sat = basesat + u
            if maxsat < sat:
                maxt = t
                maxsat = sat
        last[maxt] = i+1
        cumsat += sat
        print(maxt + 1)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main()
{
    int r;

    cin >> r;
    float l = 2 * 3.1415926535 * r;
    cout << l;
    return 0;
}


Measured memory_bytes: 3788
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
  l[i] = l[i] * 3
c = 0
for i in range(n):
  t = l[i]
  j = 0
  while True:
    if not t % 2 == 0:
      c += j
      break
    else:
      t = t // 2
    j += 1
print(c)

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

int main() {
  int A,B;
  cin >> A >> B;
  int count = 0;
  for(int i=A;i<=B;++i){
    int s=i%10,t=i/10000%10;
    int u=i/10%10,v=i/1000%10;
    if(s==t&&u==v) count++;    
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    hl = list(map(int, input().split()))
    counts = [0] * n

    for i in range(n-1,0,-1):
        if hl[i-1] >= hl[i]:
            counts[i-1] = counts[i] + 1
    # print(counts)
    print(max(counts))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63984
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N, K;
  cin >> N >> K;
  int ans = INF;
  for (int i = 0; i < 1 << N; i++) {
    int now = 1;
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        now *= 2;
      } else {
        now += K;
      }
    }
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int c = 0;
        for (int i = 0 ; i < n ; i++) {
            if (i % 2 == 0 && a[i] % 2 == 1) {
                c++;
            }
        }
        System.out.println(c);
    }

}

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

int main(){
	const long long MOD = 1000000007LL;
	
	string s;
	cin >> s;
	vector<vector<long long>> dp(100005,vector<long long>(13));

	int i,j,ki;
	long long res = 0;

	int n = s.size();
	dp[0][0] = 1;
	for(i=0; i<n; i++){
		int c;
		if(s[i]=='?') c = -1;
		else c = s[i] - '0';

		for(j=0; j<10; j++){
			if(c!=-1 && c!=j) continue;
			for(ki=0; ki<13; ki++){
				dp[i+1][(ki*10+j)%13] += dp[i][ki];
			}
		}
		for(j=0; j<13; j++) dp[i+1][j] %= MOD;
	}
	res = dp[n][5];

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 16604