akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P =pair<int,int>;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    int ans;
    ans=t/a*b;
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n<=m)
    {
        for(int i=1;i<=m;i++)
        cout<<n;
    }
    else
    {
        for(int j=1;j<=n;j++)
        cout<<m;
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

int solve(int a,int b){
    if(b>a){
        swap(a,b);
    }
    if (b==0){
        return 0;
    } else if (b==1){
        return a;
    } else{
        return b*(a/b) + solve(a%b,b);
    }
}

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n,x;
    cin >> n >> x;
    if (x>n/2){
        x = n-x;
    }

    cout << 3*solve(n-x,x) << ENDL;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#define endl '\n'
using namespace std;

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

    int N, M, a, b;
    cin >> N >> M;
    int *H = new int[N];
    set<int> NGset;


    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    for(int i=0; i<M; i++){
        cin >> a >> b;
        if(H[a-1]>H[b-1]){
            NGset.insert(b-1);
        }else if(H[a-1]<H[b-1]){
            NGset.insert(a-1);
        }else{
            NGset.insert(a-1);
            NGset.insert(b-1);
        }
    }
    cout << N - NGset.size();

    return 0;
}



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

int main(){
    int n,k,c=0;
    cin>>n>>k;
    vector<int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>=k){
            c++;
        }
    }
    cout<<c<<endl;

   return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
    char ch[10000],m,n;
    int i,j,k,p,q,r,l;
    scanf("%d",&k);
   // printf("%d",'Z');
   scanf("%s",&ch);
     //gets(ch);
    for(i=0;ch[i]!='\0';i++)
    {
         p=(int)ch[i];
         p=p+k;
        //m=ch[i]+k;
         if(p>=65 && p<=90)
         {
            m=(char)p;
            printf("%c",m);
         }
        //printf("%c",ch[i]);
        else if(p>90)
        {
            q=p-90;
            r=q+64;
            m=(char)r;
            printf("%c",m);
        }
   }
   printf("\n");
   return 0;
}


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

int main(){
    ll w,h,x,y; cin >> w >> h >> x >> y;
    bool t=0;
    if(w/2==x && (w+1)/2==x && h/2==y && (h+1)/2==y){
        t=1;
    }
    
    double s=(double)w*(double)h/2;
    // if(w%2==1 & h%2==1) s+=0.5;
    cout << s << " " << t << endl;
}

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

int main() {
    int k;
    int a, b, c;

    cin >> k;
    vector<vector<vector<int>>> gcd_table(k, vector<vector<int>>(k, vector<int>(k, 0)));

    long ans = 0;
    for (int a = 0; a < k; a++) {
        for (int b = 0; b < k; b++) {
            for (int c = 0; c < k; c++) {
                if (gcd_table[a][b][c] == 0) {
                    gcd_table[a][b][c] = __gcd(__gcd(a+1, b+1), c+1);
                }
                ans += gcd_table[a][b][c];
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 36220
N = int(input())

L = ["3","5","7"]
A = [L]
for i in range(8):
    B = []
    for a in A[i]:
        for l in L:
            B.append(a+l)
    A.append(B)
c = 0
for i in range(9):
    for a in A[i]:
        if "3" in a and "5" in a and "7" in a:
            if int(a) <= N:
                c += 1
            
print(c)


Measured memory_bytes: 5228
"use strict"
function main(arg) {
    let S = arg.trim().split("\n")[0]
    let T = arg.trim().split("\n")[1]
    let ans = 0
    for (let i = 0; i < S.length; i++) {
        if (S[i] != T[i]) {
            ans++
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32952
from collections import*
h,w,m=map(int,input().split())
d=defaultdict(int)
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=map(int,input().split())
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[x*10**6+y]+=1

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if d[x*10**6+y]==0:
      print(ma+mb)
      exit()
print(ma+mb-1)


Measured memory_bytes: 174512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>
#include <cmath>
#include <queue>

using namespace std;
using ll = long long;

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);

    for (auto&& Ai : A) {
        cin >> Ai;
    }

    for (auto&& Bi : B) {
        cin >> Bi;
    }

    for (auto&& Ci : C) {
        cin >> Ci;
    }

    vector<ll> AB;
    for (const auto& Ai: A) {
        for (const auto& Bi: B) {
            AB.emplace_back(Ai + Bi);
        }
    }

    sort(begin(AB), end(AB), greater<ll>());
    sort(begin(C), end(C), greater<ll>());

    vector<ll> ABC;

    for (int i = 0; i < min(K, (int)AB.size()); ++i) {
        for (int j = 0; j < Z; ++j) {
            ABC.emplace_back(AB[i] + C[j]);
        }
    }

    sort(begin(ABC), end(ABC), greater<ll>());

    for (int i = 0; i < K; ++i) {
        cout << ABC[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 43240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll k;
    cin >> k;
    ll ans = 1;
    ll na = 7;
    if(k == 1 || k == 7){
        cout << 1 << endl;
        return 0;
    }
    rep(i,10000000){
        if(na == 0){
            cout << ans << endl;
            return 0;
        }
        na *= 10;
        na += 7;
        na = na%k;
        ans++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3632
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, x := float64(getInt()),
		float64(getInt()),
		float64(getInt())

	x /= a
	// out(x, a*b)
	if a*b < 2*x {
		y := 2 * (a*b - x) / a
		th := math.Atan2(y, a) * 180.0 / math.Pi
		out(th)
	} else {
		// out("pass")
		y := 2 * x / b
		th := math.Atan2(b, y) * 180.0 / math.Pi
		out(th)
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
signed main() {
    int N, M;
    cin >> N >> M;
    int H[N];
    rep(i, N) cin >> H[i];
    vector<int> Graph[N];
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    int ans = 0;
    rep(i, N) {
        int d = H[i];
        bool judge = true;
        for(auto next : Graph[i]) {
            if(H[next] >= d) judge = false;
        }
        if(judge) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10220
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    ll N; cin >> N;
    ll t = (N - 1) / 2;
    ll c = 0;
    REP(i, 0, t)
    {
        c += i + 1 + (N - 1 - i);
    }
    if ((N - 1) % 2 != 0) c += t + 1;

    cout << c << endl;
}


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

using namespace std;
typedef long long int ll;

#define debug(val) "{ " << #val " : " << (val) << " } "
#define space " "
#define vi vector<int>
#define PI atan(1)*4
#define pb push_back
#define ff first
#define ss second
#define PI atan(1)*4

const int maxN = 1000000 ; 
int f[maxN + 3] ;
int dp[maxN + 3 ] ; 
void solve() {
	int n ; 
	cin >> n ; 
	for(int i=0;i<=maxN ;i++ ){
		f[i] = 0 ;
		dp[i] = 0 ;
	}
	for(int i=0;i<n;i++ ){
		int t ; 
		cin >> t ;
		f[t] ++ ;  
	}
	for(int i=1;i<=maxN;i++){
		if(f[i] == 0 ) continue ;
		for(int j =i+i ;j<=maxN;j+=i){
			dp[j] =1  ;  
		}
		if(f[i] > 1 ) dp[i] =1 ; 
	}
	int res =0;
	for(int i=1;i<=maxN;i++){
		if(f[i]== 1 && dp[i] == 0 ) res++ ;
	}
	cout << res << endl; 
		
}


int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int q = 1;
   // cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }
}



Measured memory_bytes: 11408
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, b, e = 1000000001;
	cin >> n >> b;
	long long a[123456];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n); 
	for (int h = 0; h < n - b + 1; h++) {
		e = min(a[h + b - 1] - a[h], e);
	}
	cout << e << endl;
	cin >> e;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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() 
{
  long long N,D; cin>>N>>D;
  ll ans=0;
  rep(i,N){
    long long X,Y; cin>>X>>Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3612
def main
  while nums = gets
    nums = nums.chomp.split(/\s/).collect { |x| x.to_i}
    x, y = solves nums
    puts "%.3f %.3f" % [x, y]
  end
end

def solves nums
  a, b, c, d, e, f = nums
  x = (1.0 * c * e - f * b) / (a * e - d * b)
  y = (1.0 * c * d - f * a) / (b * d - a * e)
  x = 0.000 if x.abs <= 0.000001
  y = 0.000 if y.abs <= 0.000001
  [x, y]   
end

main

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int T;
int L[111111],R[111111],C[111111],nex[111111];

int N;
void solve(){
    T=1;
    L[0]=0;R[0]=1111111111;
    nex[0]=-1;C[0]=-1;
    rep(i,N){
        char c;cin>>c;
        if(c=='W'){
            int t=0;
            int l,s;
            cin>>l>>s;
            for(;s;t=nex[t]){
                if(C[t]!=-1)continue;
                if(R[t]-L[t]<=s){
                    C[t]=l;
                    s-=R[t]-L[t];
                }
                else{
                    L[T]=L[t]+s;
                    R[T]=R[t];
                    C[T]=-1;
                    nex[T]=nex[t];

                    R[t]=L[t]+s;
                    C[t]=l;
                    nex[t]=T;
                    s=0;
                    T++;
                }
            }
        }
        else if(c=='D'){
            int t=0;
            int l;cin>>l;
            for(;t>=0;t=nex[t])if(C[t]==l)C[t]=-1;
        }
        else{
            int s;cin>>s;
            int t=0;
            for(;;t=nex[t]){
                if(L[t]<=s&&s<R[t]){
                    cout<<C[t]<<endl;
                    break;
                }
            }
        }
    }
    cout<<endl;
}
signed main(){
    while(cin>>N,N)solve();
}

Measured memory_bytes: 3172
n, a, b = gets.chomp.split.map(&:to_i)

# 端に行かないと一緒にできない
if (a + b) % 2 != 0
  min_t, max_t = [a, b].sort
  # 端に行って折り返した方が早い場合
  if (max_t - 1) > n - min_t
    # nテーブルに行くほうが早い
    puts (n - max_t) + 1 + ((n - (min_t + (n - max_t) + 1)) / 2)
  else
    puts (min_t - 1) + 1 + ((max_t - (min_t - 1 + 1)) / 2)
  end
else
  c = (a + b).abs / 2
  puts (c - a).abs
end

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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a % 2 != 0 && b % 2 != 0 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

int main() {
	long long N; std::cin >> N;
	std::vector<int> H(N);
	for (auto& r : H) std::cin >> r;
	for (int i = 1; i < N; ++i) {
		if(H[i-1] > H[i])
			if (H[i - 1] > H[i] + 1) {
				std::cout << "No" << std::endl;
				return 0;
			}
			else {
				++H[i];
			}
	}
	std::cout << "Yes" << std::endl;

	return 0;
}


Measured memory_bytes: 3728
B[3000];
p;
main()
{
	scanf("%d",&p);
	for(int i=0;i<p;i++)
	{
		int a;scanf("%d",&a);
		if(a)
		{
			B[p-1]+=p-1;
			if(i==0)
			{
				B[0]=1;
			}
			else
			{
				int now=p-1;
				for(int j=p-2;j>0;j--)
				{
					B[j]+=now=now*i%p;
				}
			}
		}
	}
	for(int i=0;i<p;i++)printf("%d\n",B[i]%p);
}

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

int main(){
    int i;
    string S, T ,R;
    int l_S;
    bool ans = false;

    cin >> S >> T;
    l_S = S.length();
    
    for (i=0; i<l_S; i++){
        R = S[l_S-1];
        R.insert(1,S.substr(0,l_S-1));
        if (R == T){
            ans = true;
            break;
            }
        S = R;
        }
    if (ans == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    }




Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<numeric>
#include<unordered_map>

using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}

string check(vector<string> ar){
    unordered_map<string, bool>  ma;

    ma[ar[0]] = true;
    for(int i = 1; i <  ar.size(); i ++){
        if( ma[ar[i]] ) 
            return "No";
       if( ar[i-1].back() != ar[i].front() ) 
            return "No";
        
        ma[ar[i]] = true;
        
    }
    return "Yes";

}

int main(){
    int n;
    cin>>n;
    vector<string> ar(n) ;
    for(auto &a : ar) cin>>a;
    cout<<check(ar);


    return 0;
}

Measured memory_bytes: 512
function Main(input) {
  const num = parseInt(input.split(" ").join(""), 10);

  if(num % 4 === 0){
    console.log("YES");
  } else {
    console.log("NO");
  }
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

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


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

int N, M;
typedef pair<int,int> pint;

vector<pint> A;
bool cmp(pint a, pint b) { return a.second < b.second; }

int main() {
    cin >> N >> M;
    A.resize(M);
    for (int i = 0; i < M; ++i) cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end(), cmp);
    int res = 0;
    int endtime = 0;
    for (int i = 0; i < M; ++i) {
        if (A[i].first >= endtime) {
            endtime = A[i].second;
            ++res;
        }
    }
    cout << res << endl;
}


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

int main(){
	int N;
	while(cin >> N, N){
		int ans = 0;
		for(int i = 1; i < N; i++){
			int sum = 0;
			for(int j = i; j < N; j++){
				sum += j;
				if(sum == N) ++ans;
			}
		}
		cout << ans << endl;
	}	
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    double t,x;
    cin >> t >> x;
    cout << t/x << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++){
  	if(s.at(i) == ','){
    	s.at(i) = ' ';
    }
  }
  
  cout << s << endl;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int N; std::cin >> N;
    long long K; std::cin >> K;
    std::vector<int> A(N), reach(N+1);
    for(int i(0); i < N; ++i){
        std::cin >> A[i];
        --A[i];
    }
    std::vector<int> d(N, -1);
    d[0] = 0; reach[0] = 0;
    int cur(0), loop(INF), st(INF);
    for(int i(0); i < N; ++i){
        int nxt(A[cur]);
        if(d[nxt] != -1){
            st = d[nxt];
            loop = d[cur] + 1 - d[nxt];
            break;
        }
        reach[i+1] = nxt;
        d[nxt] = d[cur] + 1;
        cur = nxt;
    }
    int ans(-1);
    if(K <= st) ans = reach[K];
    else{
        int id((K-st) % loop);
        ans = reach[id + st];
    }
    std::cout << ans + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int count = 1;
    for(int i = 1; i < n; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            if(h[i] < h[j]){
                flag = false;
                break;
            }
        }
        if(flag) count++;
    }
    cout << count << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    ld A, B;
    cin >> A >> B;

    ld ans = A * B;
    cout << (ll)floor(ans) << endl;
    return 0;
}

Measured memory_bytes: 3748
import sys
n = int(sys.stdin.readline())
lines = sys.stdin.readlines()
#n = int(input())
#import collections
#dll = collections.deque()
class Node:
  def __init__(self,v):
    self.val = v
    self.prev = None
    self.next = None
class DLL():
  def __init__(self):
    self.tail = Node(None)
    self.tail.next = self.tail
    self.tail.prev = self.tail
  def insert(self,x):
    n = Node(x)
    pre = self.tail.next
    n.next = pre
    n.prev = self.tail
    pre.prev = n
    self.tail.next = n
  def delete(self,x):
    node = self.tail.next
    while node != self.tail:
      if node.val == x:
        p = node.prev
        n = node.next
        p.next = n
        n.prev = p
        return
      node = node.next
  def deleteFirst(self):
    pre = self.tail.next
    if pre == self.tail:
      return
    node = self.tail.next
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def deleteLast(self):
    if self.tail.next == self.tail:
      return
    node = self.tail.prev
    p = node.prev
    n = node.next
    p.next = n
    n.prev = p
  def inspect(self):
    node = self.tail.next
    ret = []
    while node != self.tail:
      ret.append(str(node.val))
      node = node.next
    print(" ".join(ret))
dll=DLL()
for i in range(n):
  q = lines[i]
  if q[0] == "i":
      dll.insert(int(q.split()[1]))
  elif q[6] == " ":
      dll.delete(int(q.split()[1]))
  elif q[6] == "L":
      dll.deleteLast()
  elif q[6] == "F":
      dll.deleteFirst()
dll.inspect()
#print(" ".join(map(str,dll)))


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

int main() {
  int n, k;
  cin >> n >> k;
  int res = 1;
  for (int i = 0; i < n; i++) {
    if (res * 2 < res + k) {
      res *= 2;
    } else {
      res += k;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
A = sorted(map(int, input().split()), reverse=True)
if n % 2 == 0:
    ans = A[0] + 2 * sum(A[1:n//2])
else:
    ans = A[0] + 2 * sum(A[1:n//2]) + A[n//2]
print(ans)

Measured memory_bytes: 31612
N,M,C =map(int,input().split())

B = list(map(int,input().split()))
A = [list(map(int, input().split())) for i in range(N)]

count=0
for i in range(N):
  
  sum=0
  for j in range(M):
    sum=sum+A[i][j]*B[j]
  sum=sum+C
  if sum>0:
    count=count+1
    
print(count)
  


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

vector<ll> vec;
void bt(ll x, ll cur, ll l) {
	vec.pb(cur);
	if (x > 11 )
		return;
	for (int i = max(0ll, l - 1); i <= min(9ll, l + 1); i ++) {
		bt(x + 1, cur * 10 + i, i);
	}
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    for (int i = 1; i < 10; i ++)
    	bt(1, i, i);
    sort(all(vec));
    ll k;
    cin >> k; 
    k --;
    cout << vec[k];
    return (0);
}

Measured memory_bytes: 18792
s = input()
l = 0
r = len(s)-1

flag = True
ans = 0
while l < r:
  if s[l] == s[r]:
    l += 1
    r -= 1
  elif s[l] == "x":
    l += 1
    ans += 1
  elif s[r] == "x":
    r -= 1
    ans += 1
  else:
    flag = False
    break

if flag:
  print(ans)
else:
  print(-1)


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  int S,W;
  cin >> S >> W;
  if(W>=S)cout << "unsafe";
  else cout << "safe";
  return 0;
}


Measured memory_bytes: 3636
import java.math.BigDecimal;
import java.util.*;

public class Main {

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

    public static void main(String[] args) {
        String S = sc.next();
        char[] chars = S.toCharArray();

        long sum = 0;
        for (int mask = 0; mask < (1 << (S.length() - 1)); mask++) {
            int prev = 0;
            for (int i = 0; i < S.length(); i++) {
                if (((mask >> i) & 1) == 1) {
                    String num = new String(Arrays.copyOfRange(chars, prev, i + 1));
                    sum += Long.parseLong(num);
                    prev = i + 1;
                }
            }
            String num = new String(Arrays.copyOfRange(chars, prev, S.length()));
            sum += Long.parseLong(num);
        }

        System.out.println(sum);
    }

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int ans;
bool vis[5];

int calc(int t) {
	int a = t % 10;
	if (a > 0)
		t += 10-a;
	return t;
}

void dfs(int idx, int curTime, vector<int> &d) {
	if (idx == 4) {
		for (int i = 0; i < 5; ++i)
			if (!vis[i]) {
				curTime += d[i];
				break;
			}
			
		ans = min(ans, curTime);
		return;
	}

	for (int i = 0; i < 5; ++i)
		if (!vis[i]) {
			vis[i] = true;
			dfs(idx+1, calc(curTime + d[i]), d);
			vis[i] = false;
		}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ans = INT_MAX;

	vector<int> d(5);
	for (int i = 0; i < 5; ++i)
		cin >> d[i];

	dfs(0, 0, d);

	cout << ans << endl;

	return 0;
}

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

import math

if x <= a*a*b*0.5:
  print(90-math.atan(x/b/b/a*2)*180/math.pi)
else:
  y = a*a*b-x
  print(math.atan(y/a/a/a*2)*180/math.pi)

Measured memory_bytes: 3188
#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+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;
    if((a-b)%2 ){
        cout << min(a-1,n-b)+1+(b-a)/2 << endl;
    }
    else cout << (b-a)/2 << endl;
 }

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        a: [u16; n],
    }

    let mut ans = 0;
    for i in 0..n {
        // println!("i: {}", i);
        if i % 2 != 0 {
            // println!("{}", n);
            continue;
        }

        if a[i as usize] % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <iomanip>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        int x=0,y=0,z=0;
        m-=1000*n;
        if(m<0) printf("-1 -1 -1\n");
        else{
            bool flag=false;
            for(x=0;x<=n;x++){
                for(y=0;y<=n;y++){
                    if(x+y<=n&&9000*x+4000*y==m){
                        flag=true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(flag) printf("%d %d %d\n",x,y,n-x-y);
            else printf("-1 -1 -1\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
//const int MOD = 1000000007;
const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	if (s.size() == 2) {
		if (s[0] == s[1])cout << 1 << endl;
		else cout << 2 << endl;
		return 0;
	}
	vector<int>v;
	for (auto i : s)v.push_back(i - 'a');
	if (s.size() == 3) {
		set<vector<int>>st;
		st.insert(v);
		for (int i = 0; i < 20; i++) {
			for (auto j : st) {
				for (int k = 0; k < 2; k++) {
					if (j[k] != j[k + 1]) {
						int a = j[k];
						int b = j[k + 1];
						j[k] = 3 - a - b;
						j[k + 1] = 3 - a - b;
						st.insert(j);
						j[k] = a;
						j[k + 1] = b;
					}
				}
			}
		}
		cout << st.size() << endl;
		return 0;
	}
	N = s.size();
	K = accumulate(v.begin(), v.end(), 0) % 3;
	set<int>box;
	for (auto i : v)box.insert(i);
	if (box.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<vector<vector<vector<long long int>>>>dp(N, vector<vector<vector<long long int>>>(3, vector<vector<long long int>>(2, vector<long long int>(3))));
	for (int i = 0; i < 3; i++)dp[0][i][0][i] = 1;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 2; k++) {
			//	cout << i << " " << j << " " << k << endl;
				for (int l = 0; l < 3; l++) {
					dp[i][j][k][l] %= MOD;
					for (int m = 0; m < 3; m++) {
						if (j != m) {
							dp[i + 1][m][k][(l + m) % 3] += dp[i][j][k][l];
						}
						else {
							dp[i + 1][m][1][(l + m) % 3] += dp[i][j][k][l];
						}
					}
				}
			}
		}
	}
	long long int ans = 1;
	for (int i = 0; i < 3; i++)ans += dp.back()[i][1][K];
	ans %= MOD;
	for (int i = 1; i < N; i++) {
		if (v[i] == v[i - 1]) {
			ans--;
			break;
		}
	}
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 96524
c1 = list(input())
c2 = list(input())
d1 = c1[0] == c2[2]
d2 = c1[1] == c2[1]
d3 = c1[2] == c2[0]
if d1 and d2 and d3:
    print('YES')
else:
    print('NO')

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

int main() {
 	long long int N, M;
  	cin >> N >> M;
  
  	if (N % 2 == 1){
      	for (int i = 0; i < M; i++){
          	cout << i + 1 << " " << M * 2 - i << endl;
        }
    }
  
  	if (N % 2 == 0){
      	for (int i = 0; i < M; i++){
          	if (M * 2 - i * 2 + 1 > N / 2) cout << i + 1 << " " << M * 2 - i + 2 << endl;
          	else cout << i + 1 << " " << M * 2 - i + 1 << endl;
        }
    }
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <vector>
using namespace std;
int main(){
  /*int H,W,K;
  cin>>H>>W>>K;
  string c[6];
  int ver[6],hol[6];
  int black=0;
  for(int i=0;i<H;i++) hol[i]=0;
  for(int i=0;i<H;i++) cin>>c[i];
  for(int j=0;j<W;j++){
    ver[j]=0;
    for(int i=0;i<H;i++){
      if(c[i][j]=='#'){
        ver[j]++;
        hol[i]++;
      }
    }
    black+=ver[j];
  }
  int answer=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(c[i][j]=='.'){
        if(black-hol[i]-ver[j]==K) answer++;
      }
      else{
        if(black-hol[i]-ver[j]+1==K) answer++;
      }
    }
  }
  cout<<answer<<endl;*/
  int N;
  cin>>N;
  long long A[200000];
  for(int i=0;i<N;i++) cin>>A[i];
  sort(A,A+N);
  priority_queue<long long> que;
  que.push(A[N-1]);
  long long com=0;
  for(int i=N-2;i>=0;i--){
    com+=que.top();
    que.pop();
    que.push(A[i]);
    que.push(A[i]);
  }
  cout<<com<<endl;
  
  return 0;
}

Measured memory_bytes: 6524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;


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


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
long long g=0,n,a,mx=0,k;
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>a;
    mx=max(mx,a);
    g=__gcd(g,a);
}
if(k>mx){
    cout<<"IMPOSSIBLE";
}
else{
 if(k%g==0){
 cout<<"POSSIBLE";
}
else{
    cout<<"IMPOSSIBLE";
}
}
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main(){
  int n;
  cin >> n;
  set<int> s;
  REP(i,n){
    int tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  int m;
  cin >> m;
  set<int> t;
  REP(i,m){
    int tmp;
    cin >> tmp;
    t.insert(tmp);
  }
  set<int> ans;
  set_symmetric_difference(ALL(s),ALL(t),inserter(ans,ans.end()));
  for(auto i:ans){
    cout << i << endl;
  }
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> time2(51,1);
vector<ll> time10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){//yがいくつ集まったらx以上になるか
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
  string s,t; cin>>s>>t;
  if(s[0]==t[0]) cout<<"H";
	else cout<<"D";
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for n in range(N):
    value = 0
    for m in range(M):
        value += A[n][m]*B[m]
    value += C
    if value > 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 9116
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $C);
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$A = [];
$ans = 0;
for ($n=0; $n<$N; $n++){
    $A[] = array_map("intval", explode(" ", trim(fgets(STDIN))));
}

for ($n=0; $n<$N; $n++){
    $mul = 0;
    for ($i=0; $i<$M; $i++){
        $mul += $A[$n][$i] * $B[$i];
    }
    if ($mul + $C > 0) {
        $ans++;
    }
}

echo $ans;



Measured memory_bytes: 4728
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
typedef long long ll;

using namespace std;

const int maxn = 2e5 + 5;
ll fa[maxn], siz[maxn], n, m, ans;
vector<ll> e[maxn];

inline ll getfa(ll x) {
    if (fa[x] != x) fa[x] = getfa(fa[x]);
    return fa[x];
}

inline void merge(ll a, ll b) {
    ll faa = getfa(a), fab = getfa(b);
    if (faa == fab) return ;
    siz[faa] += siz[fab];
    siz[fab] = 0;
    fa[fab] = faa;
}

int main() {
    scanf("%lld%lld", &n, &m);
    for (ll i = 1; i <= n; i++) {
        fa[i] = i;
        siz[i] = 1;
    }
    for (ll i = 0; i < m; i++) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
        merge(x, y);
    }

    for (ll i = 1; i <= n; i++) {
        if (fa[i] == i) {
            ans = max(ans, siz[i]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
  int n,d,ans=0; cin >> n;
  std::vector<int> vec(100,0);
  for (int i = 0; i < n; i++) {
    std::cin >> d;
    vec[d-1] = 1;
  }
  for(int i : vec){
    ans += i;
  }
  std::cout << ans << '\n';
}


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

#define fo(i, t) for(int i = 0; i < t; i++)
#define rfo(i, t) for(int i = n - 1; i > 0; i--)
#define pb push_back

/*typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vector<int>> mi;*/

using namespace std;

int main()
{
	int t = 1;
	cin >> t;
    int tempa;
    int tempb;
    string result = "No";
    int count = 0;
    int mx = 0;
    for(int i = 0; i < t; i++)
	{
       cin >> tempa;
       cin >> tempb;
       if(tempa == tempb)
       {
       count += 1;
       mx = max(mx, count);
       }
       else
       {
           count  = 0;
       }
    }
    if(mx > 2)
        cout << "Yes";
    else
    {
        cout << "No";
    }
    
}


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

long long x, a, b;

int main() {
  cin >> x;
  for (long long i = -300; i <= 300; ++i)
    for (long long j = -300; j <= 300; ++j) {
      long long now = i * i * i * i * i;
      now -= j * j * j * j * j;
      if (now == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
bool isprime[MAXN];
int c[MAXN];

void sieve(int n)
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;
    for(int i=2;i<=n;i++)
        if(isprime[i])
            for(int j=2*i;j<=n;j+=i)
                isprime[j]=false;
    memset(c,0,sizeof(c));
    for(int i=1;i<=n;i++)
        if((i&1)&&isprime[i]&&isprime[(i+1)/2])  c[i]++;
    for(int i=1;i<=n;i++)  c[i]+=c[i-1];
}

int main()
{
    sieve(1e5+5);
    int q;
    while(scanf("%d",&q)!=EOF)
    {
        int L,R;
        for(int i=1;i<=q;i++)
        {
            scanf("%d%d",&L,&R);
            printf("%d",c[R]-c[L-1]);
            if(i!=q) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
signed main(){
    int k;
    cin>>k;
    int a,b,flag=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            flag=1;
        }
    }
    if(flag) cout<<"OK";
    else cout<<"NG";
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  long a,b,ans;
  cin>>a>>b;
  if(a==1||b==1)ans=1;
  else if(a%2==0&&b%2==0)ans=a*b/2;
  else if(a%2==1&&b%2==1) ans=(a-1)*b/2+b/2+1;
  else ans=a*b/2;
  
  cout<<ans;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,h;
ll a[100005],b[100005];
 
int main() {

slld(n);slld(h);
for(int i=1;i<=n;i++)
slld(a[i]),slld(b[i]);

sort(a+1,a+n+1);
sort(b+1,b+n+1);
reverse(b+1,b+n+1);
ll x=a[n];
for(int i=1;i<=n;i++)
b[i]+=b[i-1];
ll ans=INF;
for(int i=0;i<=n;i++)
	ans=min(ans,(max(h-b[i],0ll)/x)+((max(h-b[i],0ll)%x)!=0)+i);
plld(ans);
	return 0;
           } 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long h[100100], dp[100100];
int main(){
   ios::sync_with_stdio(0);
   cin >> n >> k;
   for (int i=2; i<=n+1; i++) cin >> h[i];
   dp[2] = 0;
   dp[3] = abs(h[3] - h[2]);
   for (int i=4; i<=n+1; i++){
   		dp[i] = dp[i-1]+abs(h[i]-h[i-1]);
   	    for (int j=max(2, i-k); j<i; j++){
   	    	dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i]);	
		}
	}
//   for (int i=2; i<=n+1; i++) cout << dp[i] << ' ';
  // cout << endl;
 //  cout << dp[2] + abs(h[5] - h[2]) << endl;
  // cout << dp[5] << endl;
   cout << dp[n+1] << endl;
   return 0;
}

Measured memory_bytes: 1792
# 不親切な人の証言は、正しかろうが間違っていようが検証できないので無視する
# bit全探索で正直者を仮定・固定して、証言に矛盾が出なければ人数を数えて記録する
from itertools import product
n = int(input())
Ev = [[] for _ in range(n)]

for i in range(n):
    A = int(input())
    for a in range(A):
        x, y = map(int, input().split())
        Ev[i].append((x - 1, y))

bit = list(product([1, 0], repeat=n))

ans = 0
for b in bit:
    for i, v in enumerate(b):  # v == 1 or 0
        if v == 1:
            for x, y in Ev[i]:  # 証言１つ１つを取り出して検証
                if b[x] != y:  # bitで仮定している正直者リストと矛盾する証言を正直者が行ったらアウト
                    break
            else:
                continue
            break
    else:
        ans = max(b.count(1), ans)

print(ans)

Measured memory_bytes: 14536
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())
H = list(map(int, input().split()))

flag = True
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] > 1:
        flag = False
        break

    if H[i-1] > H[i] and H[i-1] - H[i] == 1:
        H[i-1] -= 1

    # if H[i] - H[i-1]) > 1:
    #     flag = False
    #     break

print('Yes' if flag else 'No')


Measured memory_bytes: 14736
#include<bits/stdc++.h>
#define endl "\n"
//#define int long  long 

using namespace std ; 
	 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n ;
	cin >> n ; 
	vector<int> a(n) ; 
	for(int i = 0; i < n ; ++i)
	{
		cin >> a[i] ; 
	}
	int t = a[0] ; 
	for(int i = 1 ; i < n; ++i)
	{
		t ^= a[i] ; 
	}
	for(int i = 0;  i < n ; ++i)
		cout << (t^a[i]) << " " ;


}       





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

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

using namespace std;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int h,w; scanf("%d%d",&h,&w);
	static char B[1000][1001];
	rep(i,h) scanf("%s",B[i]);

	static int d[1000][1000];
	memset(d,-1,sizeof d);
	queue<pair<int,int>> Q;
	rep(i,h) rep(j,w) if(B[i][j]=='#') {
		d[i][j]=0;
		Q.emplace(i,j);
	}
	while(!Q.empty()){
		int y,x;
		tie(y,x)=Q.front(); Q.pop();

		rep(k,4){
			int yy=y+dy[k],xx=x+dx[k];
			if(0<=yy && yy<h && 0<=xx && xx<w && d[yy][xx]==-1){
				d[yy][xx]=d[y][x]+1;
				Q.emplace(yy,xx);
			}
		}
	}

	int ans=0;
	rep(i,h) rep(j,w) ans=max(ans,d[i][j]);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 13328
#include <bits/stdc++.h>
#define nl '\n'

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	setprecision(10);
	cout << fixed;
	int a,b;
	cin >> a >> b;
	cout << a * b << endl;
}

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

int main()
{
    int S;
    cin >> S;
    
    set<int> A;
    int X = S;
    while (A.count(X) == 0) {
        A.insert(X);
        if (X % 2 == 0) {
            X /= 2;
        }else{
            X = X * 3 + 1;
        }
    }
    cout << A.size()+1 << endl;
    
}

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

#define MAX_M 200000

int  n, m;
bool flag = false;
std::string   res;
std::set<int> from_n, from_1;

int main () {
    std::cin >> n >> m;
    for (int i=0; i<m; ++i) {
        int a, b;
        std::cin >> a >> b;
        if (a == n) from_n.insert(b);
        else if (b == n) from_n.insert(a);
        else if (a == 1) from_1.insert(b);
        else if (b == 1) from_1.insert(a);
    }
    std::set<int>::iterator itr = from_n.begin();
    while (itr != from_n.end()) {
        if (from_1.find(*itr) != from_1.end()) flag = true;
        ++itr;
    }
    res = (flag) ? "POSSIBLE" : "IMPOSSIBLE";
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 9600
# -*- coding: utf-8 -*-

n = int(input())
#a = map(int, input().split())
a = input().split()
count = 0
odd = False
while(odd == False):
    for i,v in enumerate(a):
        if int(v) % 2 != 0:
            odd = True
            break
        a[i] = int(v) // 2
    if odd is not True:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    int ia = 1000000;
    int iz = 0;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A'){
            ia = min(ia, i);
        }
        
        if(s.at(i)=='Z'){
            iz = max(iz, i);
        } 
    }

    cout << iz - ia + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(){
  int a,b;
  scanf("%d",&a);
  for(int i=a; 0<a; i--){
    b=0;
    for(int j=(int)sqrt(i); j*j<=i; j++){
      if(j*j==i){b=1;}
    }
    if(b){printf("%d",i);break;}
  }
  return 0;}


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

int main() {
    long x;
    scanf("%ld", &x);
    long sum = 0; int ans;
    for (int i = 1; sum < x; i++) {
        sum += i;
        ans = i;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3828