akhauriyash/Code-Regression huggingface dataset:
import java.util.*;  

public class Main {	
    public static Long gcd(Long x,Long y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
    public static Long lcm(Long x,Long y){                                                              
        return x*y/gcd(x,y);                                                                                                                                                                                                                
    }
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
        Long b = sc.nextLong();
		System.out.println(lcm(a,b));   
	}   
}



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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

string S, T;

signed main() {
    IOS;

    cin >> S >> T;

    int ans = LLINF;
    for(int i = 0; i + T.length() <= (ll)S.length(); ++i) {
        string s_s = S.substr(i, T.length());
        int diff = 0;
        REP(j, (ll)T.length()) {
            if(s_s[j] != T[j]) { diff++; }
        }
        chmin(ans, diff);
    }
    print(ans);

    return 0;
}


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############
a,b = inputIL()

print(math.ceil((a+b)/2))


Measured memory_bytes: 63980
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#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>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;

int par[100100];
int ranks[100100];

void init(int n){
	for(int i=1;i<=n;i++){
		par[i]=i;
		ranks[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(ranks[x] < ranks[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(ranks[x]==ranks[y])ranks[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}

int to[100100];

int main(){
	int n,m;
	int p[100100];
	int ans=0;
	cin>>n>>m;
	init(n);
	REP(i,n){
		cin>>p[i+1];
		to[p[i+1]]=i+1;
	}
	REP(i,m){
		int a,b;
		cin>>a>>b;
		unite(a,b);
	}
	for(int i=n;i>=1;i--){
		if(same(i,to[i])){
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

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

  sort (s.begin(),s.end());
  if (s[0] ==s[1] &&s[2]==s[3] && s[0]!=s[3]){
    cout <<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
#include<stdio.h>
#define rep(i,n) for(int i = 0 ; i < int(n) ; i++)
int main(){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    int a = x,b = y,c = z;
    int temp;

    temp = a;
    a = b;
    b = temp;
    
    temp = a;
    a = c;
    c = temp;

    printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 128
// agrawal117
//chahatagrawal117  
#include<bits/stdc++.h>
#define mod 998244353
#define endl '\n'
typedef  long long int ll ; 
using namespace std;
#define MAX 200006
ll dp[MAX]; ll jmp[MAX];
ll n=0;
ll tree[400009];

ll combine(ll a,ll b)					// 1 based indexing remember;
{
	return max(a,b);
}
ll rec(int i)
{
    if(i==n) return 1;
    if(dp[i]!=-1) return dp[i]%mod;
    dp[i]=(rec(i+1) %mod) + (rec(jmp[i]) % mod);
    dp[i]%=mod;
    return dp[i]%mod;
}
ll query(ll start,ll end,ll node,ll l,ll r)
{
	if(start>r || l>end) {				//no overlap case  return that value which does not affect the ans 
		return LLONG_MIN;							// as in case of sum we can return 0;
	}
	else if(l<=start && r>=end) {
		return tree[node];           // case of fully overlap
	}
	else{
		ll mid=(start+end)>>1;								//partial overlap so call both children
		ll child1=query(start,mid,2*node,l,r);
		ll child2=query(mid+1,end,(2*node)+1,l,r);
		return combine(child1,child2);
	}
}

void update(ll start,ll end,ll node,ll idx,ll value)
{
	 if(start==end){
		tree[node]=value;
		return;
	}
	ll mid=(start+end)>>1;	
	if(start<=idx && idx<=mid){
	 update(start,mid,2*node,idx,value);
	}
	 else{
		update(mid+1,end,(2*node)+1,idx,value);
	 }
	tree[node]=combine(tree[2*node],tree[(2*node)+1]);
}
#define ar array
const int mxN=2e5, M=998244353;
ar<int, 2> a[mxN];

int main()
{
     cin>>n;
    vector<pair<ll,ll> > v;
    for(int i=1;i<=n;i++){
        ll a, b; cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    jmp[n-1]=n;
    update(1,n,1,n,n);
    vector<ar<int, 2>> st{{n, (int)2e9}};
    for(int i=n-1;i>=0;i--){
        while(st.back()[1]<v[i].first+v[i].second)
			st.pop_back();
		int p=st.back()[0];
		jmp[i]=p;
		st.push_back({i, v[i].first});
		//cout << i << " " << p << endl;
// 		dp[i]=(dp[i]+dp[i+1])%M;
        // ll val= v[i].first+v[i].second;
        // if(val<=v[i+1].first) jmp[i]=i+1;
        // else {
        //     pair<ll,ll> pp; pp.first=val; pp.second=LLONG_MIN;
        //     int j= lower_bound(v.begin()+i+1,v.end(),pp)-v.begin();
        //     j--;
        //     // cout<<i<<" J "<<j<<endl;
        //     ll mx= query(1,n,1,i+2,j+1);
        //     jmp[i]=mx;
        // }
        // update(1,n,1,i+1,jmp[i]);
    }
    // for(int i=0;i<n;i++) cout<<jmp[i]<<" ";
    // cout<<endl;
    for(int i=0;i<=n-1;i++) dp[i]=-1;
    dp[n]=1;
    cout<<rec(0)%mod<<endl;
    
    
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define scan(x) cin >>x;
#define print(x) cout << x << endl;
#define Endl endl
#define inf 99999999
#define llinf 1LL << 32

int main() {

	string s;	scan(s);
	int c[26] = { 0 }, maxc = -inf, ans = inf;

	int n = s.length()-1;

	for (int i = 0; i < 26; i++) {
		int end = 0;
		for (int j = 0; j < s.length(); j++) {
			if (s[j] - 'a' == i) {
				c[i] = max(c[i], j - end);
				end = j+1;
			}
			if (j == n) {
				c[i] = max(c[i], n+1 - end);
			}
			
		}
	
	}
	
	for (int i = 0; i < 26; i++) {
		ans = min(c[i], ans);
	}

	print(ans);
	
	
	return 0;
}

Measured memory_bytes: 256
#coding: utf-8
import sys
def input():
    return sys.stdin.readline()[:-1]
"""
N人が1列に並んでおり、前からi番目の人の身長は A_iです。
それぞれの人の足元に、高さが0以上の踏み台を設置し、全ての人が次の条件を満たすようにしたいです。
条件：踏み台を込めて身長を比較したとき、自分より前に、自分より背の高い人が存在しない
この条件を満たす時の、踏み台の高さの合計の最小値を求めてください。
"""
N = int(input())
A = list(map(int, input().split()))
out = 0
# for x, a in enumerate(A):
#     if x==0:
#         continue
#     out += max(0, max(A[:x])-a)
vmax = 0
for a in A:
    vmax = max(vmax, a)
    out += vmax - a
print(out)

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

int main() {
	int N;
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		if (x % 2) {
			puts("first");
			return 0;
		}
	}
	puts("second");
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val s = io.StdIn.readLine()
  val t = io.StdIn.readLine()
  val (m, n) = (s.length, t.length)
  val dp = Array.ofDim[Int](m+1, n+1)

  for (i <- 0 until m)
    for (j <- 0 until n) {
      if (s(i) == t(j) && dp(i+1)(j+1) < dp(i)(j) + 1) dp(i+1)(j+1) = dp(i)(j) + 1
      if (dp(i+1)(j+1) < dp(i+1)(j)) dp(i+1)(j+1) = dp(i+1)(j)
      if (dp(i+1)(j+1) < dp(i)(j+1)) dp(i+1)(j+1) = dp(i)(j+1)
    }

  var (i, j) = (m, n)
  val buf = StringBuilder.newBuilder
  while (i > 0 && j > 0) {
    if (dp(i)(j) == dp(i)(j-1)) {j -= 1}
    else if (dp(i)(j) == dp(i-1)(j)) {i -= 1}
    else {i-= 1; j -= 1; buf += s(i)}
  }

  println(buf.reverse)
}

Measured memory_bytes: 90440
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
int n,a[N];
inline int gcd(int x,int y) { return y?gcd(y,x%y):x; }
inline bool solve() {
	int i,odd=0,even=0;
	bool s=0;
	for (i=1;i<=n;i++)
		(a[i]&1?odd:even)++,s|=a[i]==1;
	if (s) return even&1;
	if (even&1)
		return true;
	else if (odd>=2) return false;
	else {
		even=0;
		for (i=1;i<=n;i++) even=gcd(even,a[i]-=a[i]&1);
		for (i=1;i<=n;i++) a[i]/=even;
		return !solve();
	}
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	if (n==1) return puts(a[1]==1?"Second":"First"),0;
	puts(solve()?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define se second
//ll string_inp() {cin.get(); for(int i =0;i<n;i++){ getline(cin,s[i]);}}

ll power(ll x, ll y, ll mod = 2e18) {ll ans = 1;x %= mod;while(y){if(y&1) ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}

ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m,a = t; t = y; y = x - q * y; x = t; } if(x < 0) x += m0;return x;}

int takemod(int a, int mod = MOD){a%=mod;if(a<0)a+=mod;return a;}

ll binsearch(std::vector<ll>& nums, ll target) {ll n = nums.size();ll l = 0;ll r = n-1;while(l<=r){ll mid = l+ (r-l)/2;if(nums[mid]==target)return mid;else if(nums[mid]>target)r = mid-1;else l = mid+1;}return -1;}


using namespace std;

int main()
{
   fastio
   ll t;
   cin>>t;
   if(t%10==3)
   {
       cout<<"bon"<<endl;
   }
   else if(t%10==0||t%10==1||t%10==6||t%10==8)
    cout<<"pon"<<endl;
    else cout<<"hon"<<endl;

}




Measured memory_bytes: 3648
#include<stdio.h>
#define N 2000000

int inNumber(int[]);
void countingSort(int[],int[],int);

int n=0;
int B[N];

int main(){

  int k=0,i;
  int A[N];
  A[0]=0; 
  
  scanf("%d",&n);
  k = inNumber(A);
  countingSort(A,B,k);
  
  return 0;
}

int inNumber(int A[]){

  int i,k=0;

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }  
  for(i=1;i<=n;i++){
    if(k<A[i]){
      k=A[i];
    }
  } 
  return k;

}

void countingSort(int A[],int B[],int k){

   int i,j;
   int C[k+1];
 
   for(i=0;i<=k;i++){
     C[i]=0;
   } 
 
   for(j=1;j<=n;j++){
     C[A[j]]++;
   }
 
   for(i=1;i<=k;i++){
     C[i]+= C[i-1];
   }

   for(j = n; j > 0; j--){
     B[C[A[j]]]=A[j];
     C[A[j]]--; 
   }
   for(i=1;i<=n;i++){
     
     if(i > 1){
       printf(" ");
     }
     printf("%d",B[i]);
   }
   
   printf("\n");
}

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

int main()
{
	int n;
	int ans;
	cin >> n;
	for(int i=n;i<1000;i++)
	{
		if(i%111==0)
		{
			ans=i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
    int n;
    std::cin >> n;
    int r[4];
    for (int i = 0; i < 4; i++) {
        r[i] = 0;
    }
    std::string a[n];
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if (a[i] == "AC") {
            r[0]++;
        } else if (a[i] == "WA") {
            r[1]++;
        } else if (a[i] == "TLE") {
            r[2]++;
        } else {
            r[3]++;
        }
    }
    std::cout << "AC x " << r[0] << std::endl;
    std::cout << "WA x " << r[1] << std::endl;
    std::cout << "TLE x " << r[2] << std::endl;
    std::cout << "RE x " << r[3] << std::endl;

    return 0;
}

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

using namespace std;

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *node = (Node *)malloc(sizeof(Node));
  node->key = key;
  node->next = nil->next;
  nil->next->prev = node;
  nil->next = node;
  node->prev = nil;
}

Node *listSearch(int key) {
  Node *current = nil->next;
  while(current != nil && current->key != key) {
    current = current->next;
  }
  return current;
}

void deleteNode(Node *target) {
  if (target == nil) {
    return;
  }

  target->prev->next = target->next;
  target->next->prev = target->prev;
  free(target);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  Node *target = listSearch(key);
  deleteNode(target);
}

void command_executor(string str) {
  if (str == "insert") {
    int x;
    cin >> x;
    insert(x);
  } else if (str == "delete") {
    int x;
    cin >> x;
    deleteKey(x);
  } else if (str == "deleteFirst") {
    deleteFirst();
  } else {
    deleteLast();
  } 
}


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

  init();
  string command;
  for (int i = 0; i < n; i++) {
    cin >> command;
    command_executor(command);
  }

  Node *current = nil->next;
  while(current != nil) {
    cout << current->key;
    current = current->next;
    if (current != nil) {
      cout << " ";
    }
  }
  cout << endl;
}



Measured memory_bytes: 34444
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int h, w;
string s[50];

#define MAX_V 2500
struct edge{int to, cost;};

vector<edge> G[MAX_V];
int d[MAX_V]; //sからの最短距離(dはINFで初期化する)

void dijkstra(int s){
  priority_queue<pii, vector<pii>, greater<pii>> que;
  d[s] = 0;
  que.push(pii(0,s));

  while(!que.empty()){
    pii p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    REP(i,(int)G[v].size()){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(pii(d[e.to], e.to));
      }
    }
  }
}

int main(){

  cin >> h >> w;

  REP(i,h){
    cin >> s[i];
  }

  int ans = 0;
  REP(i,h){
    REP(j,w){
      d[i * w + j] = INF;
      if(s[i][j] == '.'){
        ans++;
        REP(k,4){
          int nx = j + dx[k], ny = i + dy[k];
          if(nx >= 0 && nx < w && ny >= 0 && ny < h){
            if(s[ny][nx] == '.'){
              G[i * w + j].push_back({ny * w + nx, 1});
            }
          }
        }
      }
    }
  }
  dijkstra(0);
  if(d[h * w - 1] == INF){
    printf("-1\n");
  }else{
    printf("%d\n", ans - d[h * w - 1] - 1);
  }
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>
#include <unordered_map>

int main()
{
    long long n;
    std::vector<long long> nums;
    std::cin >> n;

    for(long long i = 0; i < n; i++)
    {
        long long temp;
        std::cin >> temp;
        nums.push_back(temp);
    }

    long long ans = 1;

    if(std::find(nums.begin(), nums.end(), 0) != nums.end())
        ans = 0;
    std::sort(nums.begin(), nums.end());
    for(auto elem : nums)
    {
        if(std::log10(ans) + std::log10(elem) > 18)
        {
            ans = -1;
            break;
        }
        ans *= elem;
        if(ans > 1E18L)
        {
            ans = -1;
            break;
        }

        if(ans == 0)
        break;
    }

    std::cout << ans;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 3796
#include <iostream>

using namespace std;

int main(void) {
    long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int ar[4];
    ar[0] = a * c;
    ar[1] = a * d;
    ar[2] = b * c;
    ar[3] = b * d;
    long long int m = ar[0];
    for (int i = 1; i < 4; i++) {
        if (ar[i] > m) {
            m = ar[i];
        }
    }
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream> 
#include <cstring> 
using namespace std;
char val(long long int num) 
{ 
	if (num >= 0 && num <= 9) 
		return (char)(num + '0'); 
	else
		return (char)(num - 10 + 'A'); 
}

int fromDeci(char res[], long long int base, long long int inputNum) 
{ 
	long long int index=0,ans=0;
	while(inputNum > 0) 
	{ 
		res[index++] = val(inputNum % base); 
		inputNum /= base; 
		ans++;
	} 
	res[index] = '\0'; 
	return ans; 
} 
int main() 
{ 
	long long int n,k;
	cin>>n>>k;
	char res[100000]; 
	cout << fromDeci(res,k, n) <<endl; 
	return 0; 
} 


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<string> v, w;
	rep(i, n) {
		string s;
		cin >> s;
		v.push_back(s);
	}
	rep(i, m) {
		string s;
		cin >> s;
		w.push_back(s);
	}
	rep(i, 1 + n - m) {
		rep(j, 1 + n - m) {
			bool flag = true;
			rep(k, m) {
				if (v[i + k].substr(j, m) != w[k]) {
					flag = false;
				}
			}
			if (flag) {
				P("Yes");
				return;
			}
		}
	}
	P("No");
}

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


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

int64_t cnt[50][50];
int main() {
	int n; cin >> n;
	int64_t a[n];
	for(int i = 0; i < n; ++i) {
		double aa; cin >> aa;
		a[i] = llround(aa * 1e9);
		int t = 0;
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			t++;
		}
		int f = 0;
		while(a[i] % 5 == 0) {
			a[i] /= 5;
			f++;
		}
		++cnt[t][f];
	}
	int64_t ans = 0;
	for(int i = 0; i < 50 * 50; ++i) {
		int il = i / 50, ir = i % 50;
		for(int j = i; j < 50 * 50; ++j) {
			int jl = j / 50, jr = j % 50;
			if(il + jl >= 18 and ir + jr >= 18) {
				if(i == j) {
					ans += cnt[il][ir] * (cnt[il][ir] - 1) / 2;
				} else {
					ans += cnt[il][ir] * cnt[jl][jr];
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5204
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array([lr() for i in range(N)])
INF = 10 ** 10
np.fill_diagonal(A, INF)
answer = 0
for i in range(N):
    for j in range(i+1, N):
        detour = np.min(A[i] + A[j])
        if A[i, j] < detour:
            # 最短距離としてこの道路は必要
            answer += A[i, j]
        elif A[i, j] > detour:
            print(-1)
            exit()

print(answer)
# 05 hint


Measured memory_bytes: 16404
import sys
import collections
sys.setrecursionlimit(100000)
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
memo = [1 for _ in range(max(n, m) + 1)]
mod = 10 ** 9 + 7

for i in range(1, max(n, m) + 1):
    memo[i] = memo[i - 1] * i % mod

if abs(n - m) >= 2:
    print(0)
else:
    nn = memo[n] % mod
    mm = memo[m] % mod
    if n == m:
        print(2 * nn * mm % mod)
    else:
        print(nn * mm % mod)


Measured memory_bytes: 7412
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n / 2 + n % 2);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#define swap(type,x,y) do{type val=x;x=y;y=val;}while(0)
int sum=0;
void BubbleSort(int a[],int n){
    int loop,loop2;
    for(loop=0;loop<n-1;loop++){
        for(loop2=n-1;loop2>loop;loop2--){
            if(a[loop2-1]>a[loop2]){
                swap(int,a[loop2-1],a[loop2]);
                ++sum;
            }
        }
    }
}
int main(void){
    int loop,n;
    int *num;
    scanf("%d",&n);
    num=calloc(n,sizeof(int));
    for(loop=0;loop<n;loop++){
        scanf("%d",&num[loop]);
    }
    BubbleSort(num,n);
    for(loop=0;loop<n;loop++){
        printf("%d",num[loop]);
        if(loop!=n-1){
            putchar(' ');
        }else{
            putchar('\n');
        }
    }
    printf("%d\n",sum);
    free(num);
    return 0;
}


Measured memory_bytes: 2104
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 63392
N, M = map(int, input().split())
A = list(reversed(sorted(map(int, input().split()))))
c = [2,5,5,4,5,6,3,7,6]
x = [0]*(N+1)
for i in range(1,N+1):
    x[i] = max([-1]+[x[i-c[a-1]]+1 for a in A if i >= c[a-1]])
n = N
for _ in range(N):
    for a in A:
        if n >= c[a-1] and x[n-c[a-1]] == x[n]-1:
            print(a, end="")
            n -= c[a-1]
            break
print("")

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int g[MAXN][30], prvi[MAXN], prvj[MAXN], dp[MAXN];

char s[MAXN];

vector<int> vv;

int last[30];

queue<int> qq;

pii bfs(){
	qq.push(0);
	while(1){
		int s = qq.front();
		qq.pop();
		REPN(j, 1, 26){
			int to = g[s][j];
			if (!to){
				// printf("%d %d\n", s, j);
				return mp(s, j);
			}
			if (!dp[to]){
				dp[to] = dp[s] + 1;
				prvi[to] = s;
				prvj[to] = j;
				qq.push(to);
			}
		}
	}
}

void solve(){
	scanf("%s", &s[1]);
	int n = strlen(&s[1]);
	REPN(i, 1, n){
		s[i] -= ('a' - 1);
		for(int j = last[s[i]]; j < i; j++){
			g[j][s[i]] = i;
		}
		last[s[i]] = i;
	}
	pii pp = bfs();
	for(int i = pp._1, j = pp._2; ; ){
		vv.pb(j);
		if (!i){
			break;
		}
		int i1 = prvi[i];
		int j1 = prvj[i];
		i = i1;
		j = j1;
	}
	for(int i = SZ(vv) - 1; i >= 0; i--){
		putchar((char)(vv[i] + 'a' - 1));
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    odd = ""
    even = ""
    for i in range(len(S)):
        if i % 2 == 0:
            odd += S[i]
        else:
            even += S[i]
    alloddok = "L" not in odd
    allevenok = "R" not in even
    if allevenok and alloddok:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, a, b;
        cin >> n >> a >> b;
        if(n == 0)
            return 0;

        vector<bool> check(n+1, false);
        check[0] = true;
        int ret = 0;
        for(int i=0; i<=n; ++i){
            if(!check[i]){
                ++ ret;
                continue;
            }
            if(i+a <= n)
                check[i+a] = true;
            if(i+b <= n)
                check[i+b] = true;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    cout << S;
    if (S.back() == 's') {
        cout << "es" << endl;
    } else {
        cout << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

  int N;
  int res=0;
  cin >> N;
  REPS(i, N){
    res += i;
  }
  cout << res << '\n';
}


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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    COMinit();

    ll x = mod_pow(2,n,MOD) - 1;
    ll y = 1;
    rep(i,a){
        ll ii = i;
        y = y * (n - ii) % MOD;
    }
    y = y * finv[a] % MOD;
    ll z = 1;
    rep(i,b){
        ll ii = i;
        z = z * (n - ii) % MOD;
    }
    z = z * finv[b] % MOD;

    ll ans = x + MOD - y + MOD - z;
    ans %= MOD;
    

    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 12160
# scipy使う場合
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n,m,l = map(int,input().split())

# m行の入力から距離を値に持つ隣接行列を作成 0-indexed
# directed:無向グラフならFalse、有向グラフならTrue
def make_d_matrix(n,m,directed=False):
    inf = 10**13
    d = [[inf] * n for _ in range(n)]
    if(directed):
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
    else:
        for _ in range(m):
            a,b,c = map(int, input().split())
            d[a-1][b-1] = c
            d[b-1][a-1] = c
    return d

d = make_d_matrix(n,m)
csr_graph = csr_matrix(d)
d1 = floyd_warshall(csr_graph,directed=False)

inf = 10**3
for i in range(n):
    for j in range(n):
        d1[i][j] = 1 if (d1[i][j] <= l) else inf

csr_graph = csr_matrix(d1)
d2 = floyd_warshall(csr_graph,directed=False)

q = int(input())

for _ in range(q):
    s,t = map(int, input().split())
    tmp = d2[s-1][t-1]
    if(tmp >= inf):
        print(-1)
    else:
        print(int(tmp-1))


Measured memory_bytes: 20584
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_V = 100000;

class Edge{
    public:
    int to, dis;
    Edge(){}
    Edge(int to, int dis): to(to), dis(dis)  {}
};

vector<Edge> g[MAX_V];
int dis[MAX_V];

void bfs(int s, int n){
    queue<int> q;

    rep(i,n) dis[i] = INF;
    dis[s] = 0;
    q.push(s);

    int u;
    while(not q.empty()){
        u = q.front(); q.pop();
        rep(i,g[u].size()){
            Edge e = g[u][i];
            if(dis[e.to] == INF){
                dis[e.to] = dis[u] + e.dis;
                q.push(e.to);
            }
        }
    }
}

void solve(int n){
    int maxi = 0;
    int tgt = 0; //?????????s?????????????????????

    bfs(0, n);
    rep(i,n){
        if(dis[i] == INF) continue;
        if(maxi < dis[i]){
            maxi  = dis[i];
            tgt = i;
        }
    }

    bfs(tgt, n);
    maxi = 0; //tgt????????????????????\???????????¢maxi
    rep(i,n){
        if(dis[i] == INF) continue;
        maxi = max(maxi, dis[i]);
    }

    cout << maxi << endl;
}

int main(){
    int n;
    cin >> n;
    rep(i,n - 1){
        int s, t, w;
        cin >> s >> t >> w;
        g[s].emplace_back(t, w);
        g[t].emplace_back(s, w);
    }
    solve(n);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n;
    cin >> n;
    vector<vector<pair<Int, Int>>> v(n);
    for (Int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        for (Int j = 0; j < a; j++) {
            pair<Int, Int> p;
            cin >> p.fi >> p.se;
            p.fi--;
            v[i].push_back(p);
        }
    }
    Int res = 0;
    for (Int bit = 0; bit < (1<<n); bit++) {
        bool check = true;
        for (Int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                for (Int j = 0; j < v[i].size(); j++) {
                    if (v[i][j].se != ((bit>>v[i][j].fi) & 1)) {
                        check = false;
                    }
                }
            }
        }
        if (check) {
            Int cnt = 0;
            for (Int i = 0; i < n; i++) {
                if (bit & (1<<i)) {
                    cnt++;
                }
            }
            res = max(res, cnt);
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>

using namespace std;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

bool has_ncycle(const Graph &g) {
    /* Bellman-Ford */
    size_t V=g.size();
    vector<Weight> d(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (d[e.dst] > d[e.src] + e.weight) {
                    d[e.dst] = d[e.src] + e.weight;
                    if (k == V-1)
                        return true;
                }

    return false;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        scanf("%zu %zu", &s, &t);

        connect(g, s, t, -1);
    }

    printf("%d\n", has_ncycle(g));

    return 0;
}

Measured memory_bytes: 2772
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef pair< pair<string, int>, int> P;
int main(){
  int N;
  cin >> N;
  string S;
  int point;

  P list[N];

  for(int i=0;i<N;i++){
  	cin >> S >> point;
  	list[i] = make_pair(make_pair(S,-point),i+1);
  }
  sort(list, list+N);

  for(int i=0;i<N;i++){
  	cout << list[i].second <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var K, N int
  fmt.Scan(&K, &N)
  A := make([]int, N)
  dist := make([]int, N)
  for i:= range A {
    fmt.Scan(&A[i])
  }
  maxlen := 0
  for i := range dist {
    if i < len(dist)-1 {
      dist[i] = A[i+1] - A[i]
    } else {
      dist[len(dist)-1] = A[0] + K - A[len(dist)-1]
    }
    
    if maxlen < dist[i]{
      maxlen = dist[i]
    }
  }
  fmt.Println(K-maxlen)

}

Measured memory_bytes: 7808
/*
by.YXH_XianYu
 */
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define MXN 100003

int n,m,ans,
	x,y,
	f[MXN];
bool
	t[MXN];

int main(){

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		f[i]=1;
	t[1]=1;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		f[x]--;
		f[y]++;
		if(t[x])
			t[y]=1;
		if(f[x]==0)
			t[x]=0;
	}
	for(int i=1;i<=n;i++)
		if(t[i])
			ans++;
	printf("%d\n",ans);
	//system("pause");
	return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll la;string b;cin >> la >> b;
    ll lb;
    reverse(b.begin(), b.end());
    ll mul = 1;
    for (auto &&i : b)
    {
        if(i=='.')continue;
        lb += mul*(i-'0');
        mul *= 10; 
    }
    
    ll res = lb*la;

    cout << res/100 << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
 
namespace IO{
    const int insiz = 1 << 12, outsiz = 1 << 18;
    char in[insiz], *A(in), *B(in); char out[outsiz], *ptr(out);
    inline char getc(){
    	#ifndef LOCAL
        return (A == B) && (B = (A = in) + fread(in, 1, insiz, stdin), A == B) ? EOF : *A++;
        #endif
        return getchar();
    }
    template <typename T> inline T read(){
        T ret(0), p(1); char ch(getc());
        while(ch < '0' || ch > '9'){
            if(ch == '-') p = -1; ch = getc();
        }
        while(ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getc();
        return ret*p;
    }
    inline void flush(){ fwrite(out, 1, ptr - out, stdout); ptr = out; }
    template <typename T> inline void write(T x, char cmd = '\n'){
        if(x < 0) *ptr++ = '-', x = -x;
        if(x == 0) *ptr++ = '0';
        static char s[123]; int cnt = 0;
        for(; x; x /= 10) s[++cnt] = x % 10 + '0';
        for(; cnt; --cnt) *ptr++ = s[cnt];
        *ptr++ = cmd;
        if((outsiz >> 1) > ptr - out) flush();
    }
} using IO::getc; using IO::read; using IO::write; using IO::flush;
 
int main(){
	char ch = getc(), c1('0'), c2('1');
	int ans1(0), ans2(0);
	while(ch == '0' || ch == '1'){
		if(ch == c1) ++ans2; else ++ans1;
		std::swap(c1, c2); ch = getc();
	}
	write(std::min(ans1, ans2));
	flush(); return 0;
}
 
 

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include <iomanip>

using namespace std;



int main() {

	int H, A;
	cin >> H >> A;

	if (H%A == 0) {
		cout << H / A;
		return 0;

	}
	else {
		cout << H / A + 1;
		return 0;
	}



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#define MAX 10000
using namespace std;

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node* y = NIL; //xの親
    Node* x = root;
    Node* z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL){
        y = x; //親の設定
        if(z->key < x->key) x = x->left;//左の子へ移動
        else x = x->right;
    }
    z->parent = y;

    if( y == NIL) root = z;
    else if(z->key < y->key ) y->left = z; //z を y の左の子にする
    else y->right = z; //z を y の右の子にする
}

void preorder(Node* z){//先行順巡回
    printf(" %d", z->key);
    if(z->left != NIL) preorder(z->left);
    if(z->right != NIL) preorder(z->right);
}

void inorder(Node* z){
    if(z->left != NIL) inorder(z->left);
    printf(" %d", z->key);
    if(z->right != NIL) inorder(z->right);
}

void print(){
    Node* z = root;
    inorder(z);
    printf("\n");
    preorder(z);
    printf("\n");
}

Node* find(int k, Node *z){
    while( z != NIL && z->key != k){
        if( k < z->key) z = z->left;
        else z = z->right;
    }
    return z;
}

int main(){
    int n, k;
    string com;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &k);
            insert(k);
        }else if( com == "print"){
            print();
        }else if( com == "find"){
            scanf("%d", &k);
            if(find(k, root) != NIL) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22052
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll N, A, B;
    cin >> N >> A >> B;
    ll diff = B - A;
    cout << max(0LL, (B - A) * N - diff * 2 + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
# import itertools
S = input()[::-1]
# l = len(S)
# nums = range(1, l+1)
count = [0]*2019
count[0] = 1
num = 0
d = 1
for i in S:
    num += int(i)*d
    num %= 2019
    count[num] += 1
    d *= 10
    d %= 2019

ans = 0
for i in count:
    ans += i*(i-1)//2
print(ans)


Measured memory_bytes: 74212
#include<iostream>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		string line;
		cin>>line;
		string sol = "NA";
		if(line.find('#')!=string::npos){
			bool flag = false;
			string a = "";
			string b = "";
			for(int x=2;x<line.size()-1;++x){
				if(line[x] == '#'){
					flag = true;
					continue;
				}
				if(!flag){
					a += line[x];
				}else{
					b += line[x];
				}
			}
			if(line.size()> 3 && line[0]=='>' && line[1]=='\'' && line[line.size()-1]=='~' && a==b && a!="")sol = "A";
		}else{
			bool flag = true;
			for(int x=2;line.size()>4 && x<(line.size()-3);x+=2){
				if(line[x] !='Q' || line[x+1] != '=')flag = false;
			}
			if(line.size()>4 && line[0]=='>' && line[1]=='^' && line[line.size()-1]=='~' && line[line.size()-2]=='~' && flag)sol="B";	}
		cout<<sol<<endl;
	}
	return 0;
}

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

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

  vector<pair<ll, ll>> v;
  for (int i = 0; i < n; ++i) {
    ll a, b;
    cin >> a >> b;
    v.emplace_back(a + b, b);
  }

  sort(v.rbegin(), v.rend());

  ll x = 0, y = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      x += v[i].first - v[i].second;
    } else {
      y += v[i].second;
    }
  }
  cout << x - y << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
long long K,A,B;
int main(){
	cin>>K>>A>>B;
	for(int i=A;i<=B;i++){
		if(i%K==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
}

Measured memory_bytes: 3660