akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
struct vec{
    double x,y;
    vec(){x=y=0.0;};
    vec(double x, double y): x(x), y(y){};
    inline double add(double a, double b){
        return abs(a+b)<(1e-10)*(abs(a)+abs(b))?0.0:a+b;
    }
    vec operator-(vec b){
        return vec(add(x,-b.x),add(y,-b.y));
    }
    vec operator+(vec b){
        return vec(add(x,b.x),add(y,b.y));
    }
    vec operator*(double d){
        return vec(x*d,y*d);
    }
    bool operator==(vec b){
        return x==b.x&&y==b.y;
    }
    bool operator!=(vec b){
        return x!=b.x||y!=b.y;
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return hypot(x,y);
    }
};

pair<vec,vec> cross_point(vec&C1, vec&C2, double r1, double r2){
    vec e1,e2,P1,P2;
    double d=(C2-C1).norm();
    e1=(C2-C1)*(1/d);
    double theta = acos((r1*r1+(C2-C1).dot(C2-C1)-r2*r2)/(2*r1*d));
    e2.x=cos(theta)*e1.x-sin(theta)*e1.y, e2.y=sin(theta)*e1.x+cos(theta)*e1.y;
    P1=C1+e2*r1;
    e2.x=cos(theta)*e1.x+sin(theta)*e1.y, e2.y=-sin(theta)*e1.x+cos(theta)*e1.y;
    P2=C1+e2*r1;
    if(P1.x==P2.x){
        if(P1.y<P2.y) return make_pair(P1,P2);
        else return make_pair(P2,P1);
    }else{
        if(P1.x<P2.x)return make_pair(P1,P2);
        else return make_pair(P2,P1);
    }
}

double radius(double h, double l){
    return sqrt(l*l-h*h);
}
int n;
vector<vec> V;
vector<double> L;

bool iswrap(vec point, vector<double> &LL){
    for(int i=0;i<n;i++){
        double d = (V[i]-point).norm();
        if(LL[i]+1e-9<d) return false;
    }
    return true;
}

bool test(double h){
    vector<double> LL(n);
    for(int i=0;i<n;i++) LL[i]=radius(h,L[i]);
    for(int i=0;i<n;i++){
        if(iswrap(V[i],LL)) return true;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            //テゥツ崢「テ」ツつ古」ツ?ヲテ」ツつ?
            double d = (V[i]-V[j]).norm();
            if(d>LL[i]+LL[j]){
                return false;
            }
            //テ・ツ??・ツ個?
            if(d+min(LL[i],LL[j])<max(LL[i],LL[j])){
                continue;
            }
            //テ、ツコツ、テ・ツキツョ
            auto PP = cross_point(V[i],V[j],LL[i],LL[j]);
            if(iswrap(PP.first,LL)||iswrap(PP.second,LL)) return true;
        }
    }
    return false;
}

int main(){
    cout<<fixed;
    cout.precision(7);
    while(cin>>n,n){
        V.clear();
        L.clear();
        for(int i=0;i<n;i++){
            int x,y,l;
            cin>>x>>y>>l;
            V.emplace_back(x,y);
            L.push_back(l);
        }
        double lb=1,ub=1000;
        for(auto l:L) ub=min(ub,l);
        int cnt=50;
        while(cnt--){
            double mid=(ub+lb)/2;
            if(test(mid)){
                lb=mid;
            }else{
                ub=mid;
            }
        }
        cout<<ub<<endl;
    }

    return 0;
}

Measured memory_bytes: 3508
def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    *h, = map(int, input().split())

    g = tuple(set() for _ in range(N))

    g = [-1] * N
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        g[a] = max(g[a], h[b])
        g[b] = max(g[b], h[a])

    ans = 0
    for v in range(N):
        if (g[v] == -1) or (g[v] < h[v]):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 36900
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a, b, t = map(int, input().split())

print (t//a*b)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ul;
using namespace std;
int i,j,k;
int N,K;
int x[100000];
int a;
int s,t;
inline void solve(){
  INPUT2(N,K);
  INPUTS(i,N,x);
  a=INT_MAX;
  FOR(i,K,N+1){
    s=x[i-K];
    t=x[i-1];
    a=min(a,min(abs(s),abs(t))+t-s);
  }
  cout<<a<<endl;
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
char s[101];
int i,c=-1,f=-1;
int main()
{
	scanf("%s",s);
	int l=strlen(s);
	for(i=0;i<l;i++)
	{
		if(s[i]=='C')c=i;
		if(s[i]=='F')f=i;
	}
	if(c==-1||f==-1)
	{
		printf("No");
		return 0;
	}
	if(c<f)
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n>>x;
    string s;
    cin>>s;
    s[x-1] = tolower(s[x-1]);
    cout<<s;    

    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = MAP()
N = INT()
A = LIST()

# 使いやすいようにデータの持ち方を変える
B = []
for i, a in enumerate(A):
    for _ in range(a):
        B.append(i + 1)

grid = list2d(H, W, 0)
k = 0
for i in range(H):
    for j in range(W):
        # 左右ジグザグに行を進む
        if i % 2 == 1:
            j = W - j - 1
        grid[i][j] = B[k]
        k += 1

for i in range(H):
    print(*grid[i])


Measured memory_bytes: 3956
package main

import "fmt"

type submit struct {
	number int
	result string
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	submits := make([]submit, m)
	for i, s := range submits {
		fmt.Scan(&s.number, &s.result)
		s.number--
		submits[i] = s
	}
	ac, wa := cal(submits, n)
	fmt.Println(ac, wa)
}

func cal(submits []submit, n int) (int, int) {
	accepts := make([]bool, n)
	warongs := make([]int, n)
	cntAC, cntWA := 0, 0

	for _, submit := range submits {
		if accepts[submit.number] != true {
			if submit.result == "AC" {
				accepts[submit.number] = true
				cntAC++
				cntWA += warongs[submit.number]
			}
			if submit.result == "WA" {
				warongs[submit.number]++
			}
		}
	}

	// for _, a := range accepts {
	// 	if a {
	// 		cntAC++
	// 	}
	// }
	// for i := range warongs {
	// 	cntWA += warongs[i]
	// }

	return cntAC, cntWA
}


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

#define N 100005

int a[N], b[N], p[N], in[N], c[N], val[N];
int tot = 0, fir[N], nxt[N << 1], to[N << 1];

inline void Link(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i)
        scanf("%d%d", a + i, b + i),
        Link(a[i], b[i]), Link(b[i], a[i]),
        in[a[i]]++, in[b[i]]++;
    for (int i = 1; i <= n; ++i)
        scanf("%d", c + i);
    sort(c + 1, c + n + 1);
    queue<int> q;
    for (int i = 1; i <= n; ++i)
        if (in[i] == 1) q.push(i);
    long long ans = 0;
    int cnt = 0;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        val[u] = c[++cnt];
        ans += val[u];
        for (int i = fir[u], v; i; i = nxt[i]) {
            v = to[i];
            if (val[v]) continue;
            in[v]--;
            if (in[v] == 1) q.push(v);
        }
    }
    ans -= c[n];
    cout << ans << endl;
    for (int i = 1; i <= n; ++i)
        printf("%d ", val[i]);
    return 0;
}


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

Ds = []
for i in range(N):
    D1, D2 = map(int, input().split())
    Ds.append([D1, D2])

ans = 'No'

# print(Ds)
for i in range(N):
    if i == 0 or i ==1:
        continue
    elif Ds[i][0] == Ds[i][1] and Ds[i-1][0] == Ds[i-1][1] and Ds[i-2][0] == Ds[i-2][1]:
        ans = 'Yes'
        break

print(ans)

Measured memory_bytes: 9172
#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;

int main(){
  ll x, k, d; cin >> x >> k >> d;
  ll absx = abs(x);
  ll k2 = absx / d + 1;
  ll ans;
  if(k <= k2) ans = abs(absx - k * d);
  else{
    if((k - k2) % 2 == 0) ans = abs(absx - k2 * d);
    else ans = abs(absx - (k2 - 1) * d);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
ll x,y;
int main(){
	ll ans=0;
	cin>>x>>y;
	if(abs(x)==abs(y))
	{
		if(x*y<0)
		cout<<"1";
		else
		cout<<"0";
		return 0;
	}
	else
	{
		ans+=abs(abs(y)-abs(x));
		if((abs(y)>abs(x))&&x<0||(abs(y)<abs(x))&&x>0)
		ans++;
		if(abs(y)>abs(x)&&y<0||(abs(y)<abs(x)&&y>0))
		ans++;
		cout<<ans;
	}

}





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

using namespace std;

int main()
{
    int n;
    while (cin >> n) {
        vector<int> a;
        for (int i = 9; i >= 0; --i) {
            if (!n) break;
            if ((1 << i) <= n) {
                n -= 1 << i;
                a.push_back(1<<i);
            }
        }
        sort(a.begin(),a.end());
        for (int i = 0; i < a.size(); ++i) printf(i == a.size() - 1 ? "%d\n" : "%d ", a[i]);
    }
}

Measured memory_bytes: 1196
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; cin >> n;
    int cur = 0;
    while(cur < n) {
        cur += 1000;
    }
    cout << cur - n << endl;
    return 0;
}


Measured memory_bytes: 3612
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var (
	n    int
	memo []int
)

var max = 110000

func main() {
	sc.Split(bufio.ScanWords)

	n = nextInt()
	memo = make([]int, max)

	for i := 0; i < max; i++ {
		memo[i] = -1
	}

	fmt.Println(rec(n))
}

func rec(n int) int {
	// 終端条件
	if n == 0 {
		return 0
	}

	// すでに探索済みならリターン
	if memo[n] != -1 {
		return memo[n]
	}

	res := n

	// 1, 6, 6^2, ..., を試す（nを超えない範囲）
	for pow6 := 1; pow6 <= n; pow6 *= 6 {
		res = min(res, rec(n-pow6)+1)
	}

	// 1, 9, 9^2, ..., を試す（nを超えない範囲）
	for pow9 := 1; pow9 <= n; pow9 *= 9 {
		res = min(res, rec(n-pow9)+1)
	}

	// メモしながらリターン
	memo[n] = res
	return memo[n]
}

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


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main() {
   ll int s,w;
   cin>>s>>w;
   if(w>=s){
    cout<<"unsafe";
   }   
   else{
    cout<<"safe";
   }
   
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
int main() {
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    int dist1 = abs(a - x), dist2 = abs(b - x);
    if (dist1 > dist2) printf("B\n");
    else printf("A\n");
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll C[200005][30];

int main()
{
    string S;
    cin >> S;
    memset(C, 0, sizeof(C));
    for (int i = S.length() - 1; i >= 0; --i)
    {
        ll m = INF;
        REP(j, 26)
        {
            C[i][j] = C[i + 1][j];
            m = std::min(m, C[i][j]);
        }
        C[i][S[i] - 'a'] = m + 1;
    }

    string ans = "";
    ll minLen = 0;
    ll mi = 0;
    REP(i, S.length())
    {
        if (i != 0 && mi + 'a' != S[i - 1])
            continue;
        mi = 0;
        REP(j, 26)
        {
            if (C[i][mi] > C[i][j])
                mi = j;
        }
        minLen = std::max(minLen, C[i][mi] + 1);
        ans.push_back((char)(mi + 'a'));
    }
    // if (ans.length() < minLen)
    //     ans.push_back('a');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47492
n,k=map(int,input().split())

cost=[0 for i in range(n)]

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


for i in range(1,n):
    q=1e100
    r=1000
    for j in range(i-1,i-min(k,i)-1,-1):
        if q>cost[j]+abs(h[i]-h[j]) :
            q=abs(h[i]-h[j])+cost[j]
    cost[i]=q   


print(cost[-1])


Measured memory_bytes: 89704
#
import sys
import math
import numpy as np
import itertools

n = int(input())
a=1
ll = [int(i) for i in input().split()] 
ll.sort()

for i in range(n):
    a *= ll[i]
    if a == 0:
        print(0)
        exit()
    if a > 10**18:
        print(-1)
        exit()
else:
    print(a)




Measured memory_bytes: 40104
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main (){
    ll x;
    cin >> x;
    cout << (x - 1) / 11 * 2 + (x - 1) % 11 / 6 + 1 << endl;
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();
    
    int l = S.length() / 2;
    String s1 = S.substring(0, l);
    String s2 = S.substring(S.length() - l);
    
    int ans = 0;
    for (int i = 0; i < l; i++)
      if (s1.charAt(i) != s2.charAt(s2.length() - i - 1)) ans++;
    System.out.println(ans);
  }
}


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

typedef struct{
  int post;
  int count;
} myst;

int is_sevens(int x){
  int res=0;
  while(x){
    int mod=x%10;
    if(mod==7){
      x=(x-7)/10;
      res+=1;
    }
    else return 0;
  }
  return res;
}

int main() {
  int k;
  cin>>k;
  
  myst k0={0,0};
  queue<myst> que;
  que.push(k0);
  
  while(!que.empty()){
    myst sti=que.front(); que.pop();
    for(int n=0; n<=9; n++){
      int knp=k*n+sti.post;
      if(knp%10==7){
        int cntseven=is_sevens(knp);
        if(cntseven>0){
          cout<<(cntseven+sti.count)<<endl;
          return 0;
        }
        else{
          myst nextq={knp/10,sti.count+1};
          que.push(nextq);
        }
      }
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y)
{
    int large=max(x,y),small=min(x,y);
    if(large%small==0){return small;}
    else {return gcd(large%small,small);}
}
ll gcd(ll x, ll y)
{
    ll large=max(x,y),small=min(x,y);
    if(large%small==0){return small;}
    else {return gcd(large%small,small);}
}

ll n,m;
long long max1,max2;
int main()
{
    cin>>n>>m;
    cout<<3*(n-gcd(n,m))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
long long INF = 1e18;
int main(){
    long long N, K;
    std::cin >> N >> K;
    std::vector<long long> h(N), dp(N, INF);
    for(int i = 0; i < N; i++) std::cin >> h[i];
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < K + 1; j++){
            if(i + j >= N) break;
            dp[i + j] = std::min(dp[i+j], dp[i] + std::abs(h[i + j] - h[i]));
        }
    }
    std::cout << dp[N - 1] << std::endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char uc[100000];
	cin >> a>>b;
	if ((a + b) % 2== 1) {
		a = a + 1;
	}
	cout << (a + b) / 2 << endl;
		return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int hashFilter(char input){
    switch(input){
        case 'A': return 1;
        case 'C': return 2;
        case 'G': return 3;
        case 'T': return 4;
    }
}

int StrToHash(string input){
    int hash = 0;
    int level = 1;
    for(int i=0; i< input.length(); i++){
        hash += level * hashFilter(input[i]);
        level *= 5;
    }
    return hash;
}

int main(){
    static bool isAvailable[1220703125];
    int count = 0;

    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        string command;
        char word[12];
        cin >> command >> word;
        int wordHash = StrToHash(word);

        if(command == "insert"){
            isAvailable[wordHash] = true;
            count++;
        }else if(command == "find"){
            if(isAvailable[wordHash]){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }else{
            return 1;
        }
    }

    return 0;
}



Measured memory_bytes: 8408
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }

    let ans = match s.as_str() {
        "Sunny" => "Cloudy",
        "Cloudy" => "Rainy",
        "Rainy" => "Sunny",
        _ => ""
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(getline(cin, str))
	{
		if(str == "END OF INPUT")
		{
			break;
		}
		int count = 0;
		int size = str.size();
		for(int i = 0; i < size; ++i)
		{
			if(str[i] == ' ')
			{
				cout << count;
				count = 0;
			}
			else
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
#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 argc, const char * argv[]) {



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

    int n,cnt=1;
    cin>>n;
    string s[n];
    rep(i,n)cin>>s[i];
    sort(s,s+n);
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1])cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 9920
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;


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

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

	int ans = 1;
	for (int i = 1; i * i <= m; ++i) {
		if (m % i == 0) {
			if (m / i >= n) ans = max(ans, i);
			if (i >= n) ans = max(ans, m / i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N, A[100001];

	cin >> N;

	int ans = 0;

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

	sort(A, A + N);

	bool flag = true;

	for(int i = 0; i < N - 1; i++){
		if(A[i] == A[i + 1]){
			flag = !flag;
		}else{
			if(flag){
				ans++;
			}
			flag = true;
		}
	}

	if(flag){
		ans++;
	}

	cout << ans << endl;

	return 0;
}



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

using ll = long long;
#define INF 1000000000000000000

ll a[200010];

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

    int n;
    cin>>n;

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

    ll ans=INF;

    for(int i=1;i<n;i++)
    {
        ans=min(ans,abs(a[n]-a[i]-a[i]));
        if(a[n]-a[i]<a[i])break;
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 5192
# PROBLEM B
a, b, k = [int(arg) for arg in input().split()]
if a + k < b + 1 - k:
    for x in range(a, a + k):
        print(x)
    for x in range(b+1-k, b+1):
        print(x)
else:
    for x in range(a, b + 1):
        if x - a < k or b - x < k:
            print(x)

Measured memory_bytes: 3060
program Project1;
             
{$APPTYPE CONSOLE}
         
uses
  SysUtils,math;
var
  fx,g,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  l:array of Integer;
  //l,l1,l2:int64;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  c1,c2,c3:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Readln(b);

    c:=strtoint(inttostr(a)+inttostr(b));

    if power(trunc(sqrt(c)),2)=c then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>


using namespace std;



int main() {

	int n;
	cin >> n;
	vector<int> t(n);
	vector<string> s(n);

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

	string x;
	cin >> x;

	int sum = 0;
	bool isSleep = false;
	for (int i = 0; i < n;i++) {
		if (isSleep) {
			sum += t[i];
		}
		if (s[i] == x) {
			isSleep = true;
		}
	}

	cout << sum << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int x;
	int res = 0;
	cin >> x;
	if (400 <= x && x <= 599)res = 8;
	else if (600 <= x && x <= 799)res = 7;
	else if (800 <= x && x <= 999)res = 6;
	else if (1000 <= x && x <= 1199)res = 5;
	else if (1200 <= x && x <= 1399)res = 4;
	else if (1400 <= x && x <= 1599)res = 3;
	else if (1600 <= x && x <= 1799)res = 2;
	else if (1800 <= x && x <= 1999)res = 1;
	cout << res << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N, M, K;
	cin >> N >> M >> K;

	bool flag = false;

	REP(i, N + 1) {
		REP(j, M + 1) {
			LL score = j*N + i*M - 2*i*j;
			if (j*N + i*M - 2*i*j == K) {
				flag = true;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

    int cnt = 0;
    int d = __gcd(a, b);
    for(int i=d;i>=1;i--){
        if(d%i==0) cnt++;
        if(cnt==k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n,count=0,last,a;
  
  cin >> n;
  int p[n] ;
  for(int i=0;i<n;i++){
 	 cin >> p[i];
  }
  
  for(int i=0;i<n;i++){
 	 if(p[i] != (i+1)){
       count++;
      if(count == 1){
      	 a = i+1;
      }
     }
  }
    
   
  if(count == 0){
  	cout << "YES" << endl;
  }
     
  else if(count == 2){
  	cout << "YES" << endl;
  }
  else{
    cout <<"NO" << endl;
  }

}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;


int h, w;
string f[8];
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> h >> w;
  int cnt = 0;
  for(int i = 0; i < h; i++) {
    cin >> f[i];
    for(int j = 0; j < w; j++) cnt += f[i][j] == '#';
  }
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  int ok = 0;
  while(q.size()) {
    int y, x;
    tie(y, x) = q.front();
    q.pop();
    if(f[y][x] == '.') continue;
    if(y+1 < h) q.emplace(y+1,x);
    if(x+1 < w) q.emplace(y,x+1);
    if(y == h-1 && x == w-1) ok = 1;
  }
  Pos(ok && cnt == h + w - 1);
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class AServalVsMonster {
public:
    void solve(std::istream& in, std::ostream& out) {
        int H, A;
        in >> H >> A;
        out << (H / A + (H % A == 0 ? 0 : 1)) << "\n";
    }
};


signed main() {
    AServalVsMonster solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
using namespace std;
#define pi acos(-1.0)
   
int main ()  
{

ll a,b,d,n,k;
cin>>a>>b>>d;

n= min(a,b);
k= max(a,b);
ll cnt=0;

for(ll i=n;i<=k;i++)
{
	if(i%d==0)
	cnt++;
}
cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3632
from re import sub
LIST = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
K = int(input())
print(sub(r"[\s]", "", LIST).split(",")[K-1])

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
typedef double d;
d to_deg(d r){return r*180.0/(atan(1.0)*4.0);}
int main(void)
{
    int a,b,x;
    double h,v,rad;

    scanf("%d %d %d",&a,&b,&x);
    v=(d)a*(d)a*(d)b;
    if(v/2.0>x){
        h=(2.0*(d)x)/((d)a*(d)b);
        rad=atan2(h,(d)b);
        printf("%lf\n",90.0-to_deg(rad));
    }
    else{
        h=((2.0*(v-(d)x))/((d)a*(d)a));
        rad=atan2(h,(d)a);
        printf("%lf\n",to_deg(rad));
    }
    return 0;
}

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

int main() {
	int N;
	int count = 0;
	cin >> N;
	int a[100];
	for (int i = 0; i < N;i++) {
		cin>>a[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			
				count += a[i] * a[j];
			
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int k,s;
  int count =0;

  scanf("%d %d",&k,&s);
  for(int i=0; i<=k; i++){
    for(int j=0; j<=k; j++){
      if((s-i-j>=0) && (s-i-j)<=k){
        count++;
      }
    }
  }

  printf("%d",count);


  
  return 0;
}


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

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;

    if (A >= K) {
    	A = A - K;
    } else {
    	B = max(A + B - K, 0LL);
    	A = 0;
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

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

int h,w;
std::string m[2001];

int memox[2001][2001];
int memoy[2001][2001];

bool ok;
int dfs(int x, int y, int ix, int iy) {
    if(!IN(0,x,h) || !IN(0,y,w) || m[x][y] == '#') return 0;
    if((ix == 1 || ix == 3) && memox[x][y]) { ok = false; return memox[x][y]; }
    if((iy == 0 || iy == 2) && memoy[x][y]) { ok = false; return memoy[x][y]; }
    int res = dfs(x+dx[ix], y+dy[iy], ix, iy);
    return ok ? 1 + res : res;
}

int main(){
    INIT;
    cin >> h >> w;
    REP(i,h) {
        cin >> m[i];
    }
    int ans = 0;
    REP(i,h) {
        REP(j,w) {
            int cnt = 0;
            if(m[i][j] == '.') {
                ok = true; memox[i][j] = dfs(i+dx[1],j+dy[1],1,1);
                int resx = (!ok ? 0 : dfs(i+dx[3],j+dy[3],3,3));
                if(ok) memox[i][j] += resx + 1;
                ok = true; memoy[i][j] = dfs(i+dx[0],j+dy[0],0,0);
                int resy = (!ok ? 0 :dfs(i+dx[2],j+dy[2],2,2));
                if(ok) memoy[i][j] += resy + 1;
                cnt = memox[i][j] + memoy[i][j] - 1;
            }
            ans = std::max(ans,cnt);
        }
    }
    cout << ans << "\n";
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;



int a[305][305];

bool b[305];

int ans = INF;

int main() {

	int n, m;
	cin >> n >> m;
	REP(i, n)REP(j, m)cin >> a[i][j];

	REP(i, m) {
		VI v(m + 1, 0);
		int cur = 0;
		int d = 0;
		REP(j, n) {
			REP(k, m) {
				if (!b[a[j][k]]) {
					v[a[j][k]]++;
					break;
				}
			}
		}
		REP(i, m + 1) {
			if (d < v[i]) {
				d = v[i];
				cur = i;
			}
		}
		ans = min(ans, d);
		b[cur] = true;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include <stdlib.h>
int gcd(int m, int n) {
	if (n == 0)
		return m;
	else
		return (gcd(n, m%n));
}

int main()
{
	double x,m,n,y;
	while (scanf("%lf %lf",&m,&n)!=EOF)
	{
		x = gcd(m, n);
		y = (m * n) / x;
		printf("%.lf %.lf\n", x, y);
	}
return 0;
}

Measured memory_bytes: 1768
ab = input()  # "3 4"
s = input()  # "269-6650"

a, b = ab.split()  # "3", "4"
a = int(a)
b = int(b)

def is_zip_correct(a, b, s):
    if len(s) != a + b + 1:
        # print("invalid len")
        return False

    # ハイフンの前までが数字か
    for i in range(0, a):
        if not s[i].isdecimal():
            # print("invalid decimal(1) {}".format(s[i]))
            return False

    # 正しい位置にハイフンがあるか
    if s[a] != '-':
        # print("invalid hyphone".format(s[i]))
        return False

    # ハイフンの後ろが数字か
    for i in range(a + 1, a + b + 1):
        if not s[i].isdecimal():
            # print("invalid decimal".format(s[i]))
            return False

    return True

if is_zip_correct(a, b, s):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,C,K,T[100001];
	scan(N);scan(C);scan(K);
	rep(i,N){
		scan(T[i]);
	}
	sort(T,T+N);
	int nowc=0,begintime,ans=0;
	rep(i,N){
		if(nowc==0) begintime=T[i];
		nowc++;
		if(nowc==C||(i<N-1&&T[i+1]>begintime+K)||i==N-1){
			ans++;
			nowc=0;
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 640
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, K = MAP()

ans = K**N % MOD
print(ans)



Measured memory_bytes: 5644
#include<iostream>
using namespace std;
bool z(int n,int j,int k){
int s=0;
while(n!=0){
s+=n%10;
n/=10;}
if(s>=j&&s<=k) return 1;
return 0;}
int main(){
int n,a,b,s=0;
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
if(z(i,a,b)) s+=i;
cout<<s<<endl;}

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

int main(int argc, char *argv[]){
	int n;
	std::string s;

	std::cin >> n;
	std::cin >> s;

	int x = 0, max = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'I')x++;
		if(s[i] == 'D')x--;
		max = std::max(max, x);
	}
	std::cout << max << std::endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  for(int i=n;i>=1;i--){
    int a=i;
    while(a%2==0){
      a/=2;
    }
    if(a==1){
      cout<<i;
      break;
    }
  }
}

Measured memory_bytes: 256
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=2e5+5;

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

    vec v;

    for(int i=0;i<(int)s.length();i++)
    {
        if(s[i]=='B')
        {
            if(v.size())
            v.pop_back();
            else
            continue;
        }
        else if(s[i]=='0')
        {
            v.pb(0);
        }
        else
        {
            v.pb(1);
        }
    }

    for(auto it: v)
    cout<<it;
}



Measured memory_bytes: 3592
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	A, _ := strconv.ParseInt(scanner.Text(), 10, 0)
	scanner.Scan()
	B, _ := strconv.ParseInt(scanner.Text(), 10, 0)

	if A == 1 {
		A = 14
	}
	if B == 1 {
		B = 14
	}

	if A > B {
		fmt.Println("Alice")
	} else if A < B {
		fmt.Println("Bob")
	} else {
		fmt.Println("Draw")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<P> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;
    map<P,int> mp;
    sort(all(a));
    rep(i, n) srep(j, i+1, n) {
        ll p = a[j].first - a[i].first;
        ll q = a[j].second - a[i].second;
        mp[P(p, q)]++;
    }
    int ans = n;
    for(auto p : mp) {
        chmin(ans, n-p.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,n,s=0;
	cin>>n>>m;
	int a[n+1];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	sort(a,a+n);
	for(i=n-1;i>=n-m;i--)
	{
		if(a[i]*4*m<s)
		break;
	}
	if(i==(n-1-m))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> ans(n);
    rep(i, n){
        ans[a[i] - 1] = i + 1;
    }
    rep(i, n) cout << ans[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
 
int p=0;
int q[2000001];
 
void chg(int a,int b){
  int x;
  x=q[a];
  q[a]=q[b];
  q[b]=x;
}
 
int max(int a,int b){
  if(q[a]>q[b]) return a;
  else return b;
}
 
int extract(){
  int r=q[1];
  int i;
  int x;
  int M;
  q[1]=q[p];
  p--;
  i=1;
  while(i*2 <= p ){
    if(i*2+1 <= p)
      M=max(i*2,i*2+1);
    else M=i*2;
    if(max(M,i)==M){chg(M,i);i=M;}
    else break;
 
  }
  return r;
}
 
 
 
void insert(int k){
  int x;
  int i,j;
  p++;
  q[p]=k;
  i=p;
  while(q[i]>q[i/2] && i>1){
    chg(i,i/2);
    i=i/2;
  }
}
 
int main(){
  char c[10];
  int i,j,k;
 
  while(1){
    scanf("%s",c);
 
    if(c[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
 
    if(c[0]=='e'){
 
      if(c[1]=='x')
    printf("%d\n",extract());
 
      if(c[1]=='n') break;
    }
  }
  return 0;
}



Measured memory_bytes: 5564
A, B, Q = gets.split.map(&:to_i)
ss = [-10**18] + A.times.map{gets.to_i} + [10**18]
ts = [-10**18] + B.times.map{gets.to_i} + [10**18]
sr = ss.reverse
tr = ts.reverse
Q.times do
    x = gets.to_i
    ls = ss.bsearch{|y| y >= x} - x
    lt = ts.bsearch{|y| y >= x} - x
    rs = x - sr.bsearch{|y| y <= x}
    rt = x - tr.bsearch{|y| y <= x}
    ans = [[ls, lt].max, [rs, rt].max, ls*2+rt, ls+rt*2, lt*2+rs, lt+rs*2].min
    puts ans
end

Measured memory_bytes: 11316
import java.util.*;
import java.lang.Math;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int number_of_elements = sc.nextInt();
      	int intArray[] = new int[number_of_elements];
      	int index = 0;
      	while(sc.hasNextInt()){
          intArray[index++] = sc.nextInt();
        }
      int dpArray[] = new int[intArray.length];
      int cost = 0;
      dpArray[0]=0;
      dpArray[1]=Math.abs(intArray[1]-intArray[0]);
      for(int i =2 ;i<dpArray.length;i++){
      	dpArray[i]=Math.min(dpArray[i-2]+Math.abs(intArray[i]-intArray[i-2]),dpArray[i-1]+Math.abs(intArray[i]-intArray[i-1]));
      }
      System.out.println(dpArray[dpArray.length-1]);
	}
}


Measured memory_bytes: 50336
#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() {
  ll n,m;
  cin >>n >> m ;
  if(n==1 &m==1)
  cout<<1 <<endl;
  else if(n==1 ||m==1)
  cout<< n*m-2 <<endl;
else

cout << (n-2)*(m-2)<< endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 0; i--)
    {
        cout << a[i];
        if (i > 0)
        {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092