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


const int MOD = 1000000007;

int main() {
  string S; cin>>S;
  int n=S.size();
  vector<vector<ll>> dp(n+1, vector<ll>(4));
  dp[0][0]=1;
  rep(i, n) {
    rep(j, 4) {
      if (S[i]=='?') dp[i+1][j]+=dp[i][j]*3;
      else dp[i+1][j]+=dp[i][j];
      dp[i+1][j]%=MOD;
    }
    if (S[i]=='A'||S[i]=='?') dp[i+1][1]+=dp[i][0];
    if (S[i]=='B'||S[i]=='?') dp[i+1][2]+=dp[i][1];
    if (S[i]=='C'||S[i]=='?') dp[i+1][3]+=dp[i][2];
  }
  dp[n][3]%=MOD;
  cout<<dp[n][3]<<endl;
}

Measured memory_bytes: 7424
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

bool comp(pair<string,pair<int,int> > &p1, pair<string,pair<int,int> > &p2){
	if ( p1.first < p2.first ) return true ; 
	else if ( p1.first == p2.first ) {
		return p1.second.first > p2.second.first ; 
	}
	return false ;
}

int main(){
	int n ; 
	cin >> n ; 
	vector<pair<string,pair<int,int> > > v ; 
	for(int i=0;i<n;i++){
		string x; 
		cin >> x; 
		int s ; 
		cin >> s ;
		v.push_back({x,{s,i+1}}) ; 
	}
	debug() << imie(v) ; 
	sort(v.begin(),v.end(),comp);
	debug() << imie(v) ; 
	for(int i=0;i<n;i++){
		cout << v[i].second.second << endl;
	}
    return 0 ;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
string a[64];

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int minv = 2 * C * 0 + max(X - 0, 0) * A + max(Y - 0, 0) * B;
    rrep(k, 1 , max(X + 1, Y + 1)){
        tmp = 2 * C * k + max(X - k, 0) * A + max(Y - k, 0) * B;
        minv = min(minv, tmp);
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int tmp=n%10;
    if(tmp==2||tmp==4||tmp==5||tmp==7||tmp==9)
        printf("hon\n");
    else if(tmp==0||tmp==1||tmp==6||tmp==8)
        printf("pon\n");
    else if(tmp==3)
        printf("bon\n");
    return 0;
}


Measured memory_bytes: 3644
fun main(args:Array<String>):Unit {
    val n = readLine()!!.toInt()
    val max = factorial(n)
    val narabi = readLine()!!.split(' ').map(String::toInt).toTypedArray()
    val rank = toRank(narabi)
    println(listOf(-1, 0, 1).map{it + rank}.filter{it in 0 until max}.joinToString ("\n"){
        toPermutation(n, it).joinToString(" ")
    })
}
fun factorial(n:Int):Int{
    return when(n){
        0 -> 1
        else -> n * factorial(n - 1)
    }
}
fun toPermutation(length:Int, value:Int):Array<Int>{
    val res = Array(length){it + 1}
    var num = value
    for (i in 0 until length){
        val n = num / factorial(length - 1 - i)
        val temp = res[i + n]
        for (j in n downTo 1) res[i + j] = res[i + j - 1]
        res[i] = temp
        num %= factorial(length - 1 - i)
    }
    return res
}
fun toRank(array:Array<Int>):Int {
    val res = Array(array.size){it + 1}
    var num = 0
    for (i in 0 until array.size){
        val n = res.indexOfFirst { it == array[i] } - i
        num += n * factorial(array.size - 1 - i)
        val temp = res[i + n]
        for (j in n downTo 1) res[i + j] = res[i + j - 1]
        res[i] = temp
    }
    return num
}


Measured memory_bytes: 32224
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define MAX 2000200
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,H,D,jc[MAX],f[MAX],s[MAX];
int fpow(int a,int b){int s=1;while(b){if(b&1)s=1ll*s*a%MOD;a=1ll*a*a%MOD;b>>=1;}return s;}
int main()
{
    cin>>n>>H>>D;
    jc[0]=1;for(int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%MOD;
    int sj=0;for(int i=1;i<=n;++i)sj=(sj+jc[i])%MOD;
    f[0]=s[0]=1;
    for(int i=1;i<=H;++i)f[i]=1ll*sj*(s[i-1]+MOD-(i-D<=0?0:s[i-D-1]))%MOD,s[i]=(s[i-1]+f[i])%MOD;
    int ans=1ll*f[H]*jc[n]%MOD*fpow(sj,MOD-2)%MOD;
    printf("%d\n",ans);
    return 0;
}


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

const ll mod=1000000007;

int main() {
  bool flag=true;
  ll x;
  cin >> x;
  ll a=0,b=0;
  while(flag){
    ll c,y;
    c=b*b*b*b*b;
    y=x+c;
    ll a=sqrt(sqrt(sqrt(y)));
    while(a*a*a*a*a<=y){
      if(a*a*a*a*a==y)flag=false;
      if(flag)a++;
      else {
        cout<<a <<" "<<b<<endl;
        return 0;
      }
    }
    if(flag){
      a=0;
      if(b==0)b=1;
      else if(b>0)b*=-1;
      else b=b*(-1)+1;
    }
  }
}

Measured memory_bytes: 3668
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

struct node{
    int pos,n,dist;
    
    node(int _pos, int _n, int _dist) : pos(_pos), n(_n), dist(_dist){}
    
    bool operator < (node X)const{
        return dist > X.dist;
    }
};

vector<int> L[100],W[100];
int dist[100][100];

int main(){
    int n,m,c;
    
    while(true){
        scanf("%d %d %d",&n,&m,&c);
        
        if(n == 0) break;
        
        for(int i = 0;i < n;++i){
            L[i].clear();
            W[i].clear();
        }
        
        for(int i = 0,u,v,w;i < m;++i){
            scanf("%d %d %d",&u,&v,&w);
            --u; --v;
            
            L[u].push_back(v);
            W[u].push_back(w);
        }
        
        int lo = 0,hi = n - 1,mi;
        
        while(lo < hi){
			mi = (lo + hi) >> 1;
			
			priority_queue<node> Q;
			memset(dist,-1,sizeof dist);
			bool ok = false;
			
			Q.push(node(0,mi,0));
			dist[0][mi] = 0;
			
			while(!Q.empty()){
				node cur = Q.top();
				Q.pop();
				
				if(cur.dist > dist[cur.pos][cur.n] || cur.dist > c) continue;
				
				if(cur.pos == n - 1){
                    ok = true;
                    break;
                }
				
				for(int i = L[cur.pos].size() - 1,to;i >= 0;--i){
					to = L[cur.pos][i];
					
					if(dist[to][cur.n] == -1 || W[cur.pos][i] + cur.dist < dist[to][cur.n]){
						Q.push(node(to,cur.n,W[cur.pos][i] + cur.dist));
						dist[to][cur.n] = W[cur.pos][i] + cur.dist;
					}
					
					if(cur.n > 0 && (dist[to][cur.n - 1] == -1 || cur.dist < dist[to][cur.n - 1])){
						Q.push(node(to,cur.n - 1,cur.dist));
						dist[to][cur.n - 1] = cur.dist;
					}
				}
			}
			
			if(ok) hi = mi;
			else lo = mi + 1;
        }
        
        printf("%d\n",lo);
    }
    
    return 0;
}

Measured memory_bytes: 952
#include <stdio.h>
#include <string.h>

int main(void) {
	int count[4] = {0};
	int number;
	int i;
	char blood[3];
	while (scanf("%d,%s", &number, blood) != EOF) {
		if (!strcmp(blood, "A"))
			count[0]++;
		else if (!strcmp(blood, "B"))
			count[1]++;
		else if (!strcmp(blood, "AB"))
			count[2]++;
		else if (!strcmp(blood, "O"))
			count[3]++;
	}
	for (i = 0; i < 4; i++) {
		printf("%d\n", count[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD 1000000007

int main(void)
{
  string str;
  cin >> str;

  if(str == "a" || str == "i" || str == "u" || str == "e" || str == "o")
    cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}

Measured memory_bytes: 384
import itertools

input_list = []

for _ in range(5):
    a = int(input())
    input_list.append(a)

k = int(input())

c_list = list(itertools.combinations(input_list, 2))
#print(c_list)
ans_list = []
for i in c_list:
    #print(i)
    ans = i[0] - i[1]
    ans = abs(ans)
    ans_list.append(ans)

for i in ans_list:
    if i > k:
        print(':(')
        exit()        
print('Yay!')

Measured memory_bytes: 3064
import sys
n,m = map(int,input().split())
if m < 2:
  print(0)
  sys.exit()
if 1 < m < n:
  print(m//2)
  sys.exit()
if 2*n > m >= n:
  print(m//2)
  sys.exit()
m -= 2*n
print(n+(m//4))

Measured memory_bytes: 9096
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int r;

int main(void)
{
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <limits>
typedef long long ll;

using namespace std;

// 10,000,000 -> 1s
long long enqueue(int n, int k, long long v[]) {
  ll ans = 0;
  for (int kk=0;kk<=k;kk++) {
    for(int num_pick = 0; num_pick <= kk; num_pick++) {
      //cout << "=====================================" << endl;
      if(n < num_pick) {
	continue;
      }
      int num_remove = kk - num_pick;
      if(num_pick < num_remove) {
	continue;
      }
      //cout << "num_pick: " << num_pick << " num_remove: " << num_remove << endl;
      for(int a = 0; a<=num_pick; a++) {
	priority_queue<ll, vector<ll>, greater<ll>> que;      
	for(int aa =0;aa<a;aa++) {
	  que.push(v[aa]);
	}
	int b= num_pick - a;
	for(int bb = 0;bb<b;bb++) {
	  que.push(v[n - 1 - bb]);
	}
	for(int i =0;i<num_remove;i++) {
	  que.pop();
	}
	ll temp = 0;
	while(!que.empty()) {
	  temp += que.top();
	  que.pop();
	}
	ans = max(ans, temp);
	//cout << "current -> " << temp << endl;
	//cout << "=====================================" << endl;
      }
    }
  }

  return ans;
}

int main() {
  int n, k;
  cin >> n >> k;
  ll v [n];
  for(int i=0;i<n;i++) {
    cin >> v[i];
  }
  cout << enqueue(n, k, v);
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N, l = 0, r, m;
	cin >> N;
	r = (int)sqrt(2 * N) + 1;
	while (r - l > 1) {
		m = (r + l) / 2;
		if (m * (m + 1) / 2 >= N) {
			r = m;
		}
		else {
			l = m;
		}
	}
	l = r * (r + 1) / 2 - N;
	rep(i, 1, r + 1) {
		if(l != i)printf("%d\n", i);
	}
	return 0;
}


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

using namespace std;

int taro[100], hanako[100];
int n, m;

int main() {
  int n, m;
  
  while(cin >> n >> m, (n|m)) {
    for(int i=0; i<n; i++)
      cin >> taro[i];
    for(int i=0; i<m; i++)
      cin >> hanako[i];
    
    int const staro = accumulate(taro, taro+n, 0);
    int const shanako = accumulate(hanako, hanako+m, 0);
    
    int mn = 1000;
    int ans1=-1, ans2;
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	int const a = -taro[i]+hanako[j];
	if(staro+a == shanako-a && mn > taro[i]+hanako[j]) {
	  ans1 = taro[i], ans2 = hanako[j];
	  mn = taro[i]+hanako[j];
	}
      }
    }
    if(ans1==-1) cout << "-1" << endl;
    else cout << ans1 << " " << ans2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1164
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		//int count=0;
		boolean sw=false;
		int answer=0;
		//String answer="NO";
		List<Integer> a=new ArrayList<Integer>();
		//int af=Integer.MAX_VALUE;
		int s;
		int n=1;
		int ai=0;
		int count=0;
		//入力
		Scanner sc = new Scanner(System.in);
		s=sc.nextInt();
		//int a=sc.nextInt();
		//String S=sc.next();
		//int [][] cost =new int[N-1][2];
		
		//処理
		while(sw==false)
		{
			if(count==0)
			{
				a.add(s);
				count++;
			}else
			{
				n=a.get(count-1);
				if(n%2==0)
				{
					ai=n/2;
					a.add(ai);
				}else
				{
					ai=3*n+1;
					a.add(ai);
				}
				//System.out.println("ai="+ai);
				count++;
			}
			for(int i=0;i<count-1;i++)
			{
				if(a.get(i)==ai)
				{
					answer=a.size();
					sw=true;
				}
			}
			//System.out.println(count);
			//System.out.println(Arrays.toString(a.toArray()));
			//if(count==10)
			//{
			//	sw=true;
			//}
		}
		//System.out.println(Arrays.toString(a.toArray()));
		// 出力
		System.out.println(answer);
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(void)
{
	//int a[13][2]={{0,0},{1,1},{2,2},{3,1},{4,3},{5,1},{6,3},{7,1},{8,1},{9,3},{10,1},{11,3},{12,1},};
	int a[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
	int x,y;
	scanf("%d%d",&x,&y);
	if(a[x]==a[y])  printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import heapq
import sys

h = []
n,m = list(map(int,input().split(" ")))



nums = []
for i in range(n):
    a,b = list(map(int,input().split(" ")))
    nums.append((a,b))
nums.sort(key=lambda x:x[0])

d = 1
ans = 0
st = 0
flag = True
for d in range(1,m+1):
    for i in range(st,n ):
        if nums[i][0] > d:
            st = i
            break
        else:
            if flag:
                heapq.heappush(h,-nums[i][1])
            if st == n-1:
                flag = False

    if h:
        ans -= heapq.heappop(h)


print(ans)




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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(string, s);

  int N = 0, W = 0, S = 0, E = 0;
  for (auto e : s) {
    if (e == 'N') ++N;
    if (e == 'W') ++W;
    if (e == 'S') ++S;
    if (e == 'E') ++E;
  }

  bool ok = true;
  if (N && !S) ok = false;
  if (S && !N) ok = false;
  if (W && !E) ok = false;
  if (E && !W) ok = false;

  outl(ok ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

use std::io::prelude::*;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let t: usize = input();
    let mut ts: Vec<usize> =
        (0..n).map(|_| input()).collect();
    let mut sum = 0;
    for i in 0..ts.len() - 1 {
        if ts[i + 1] - ts[i] > t {
            sum += t;
        } else {
            sum +=  ts[i + 1] - ts[i];
        }
    }
    println!("{}", sum + t);
}

Measured memory_bytes: 6396
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

d = [[-1] * w for _ in range(h)]
que = deque()
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((j, i))
            d[i][j] = 0

dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

ans = 0
while que:
    x, y = que.popleft()
    for dx, dy in dxdy:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and d[ny][nx] == -1:
            que.append((nx, ny))
            d[ny][nx] = d[y][x] + 1
            ans = max(ans, d[ny][nx])

print(ans)


Measured memory_bytes: 121564
N,K = map(int,input().split())
n = [0]*(int(1e5)+1)

for i in range(N):
    a,b = map(int,input().split())
    n[a] += b

for i in range(int(1e5)+1):
    K -= n[i]
    if K <= 0:
        print(i)
        break

Measured memory_bytes: 11720
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
int main() {
	cin >> N;
	vl A(N);
	map<ll, ll> B;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		B[A[i]]++;
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	for (i = 0; i < N; i++) {
		if (B[A[i]] > 0) {
			B[A[i]]--;
			for (j = 31; j >= 1; j--) {
				ll P = pow(2, j) - A[i];
				if (P >= 1) {
					//debug(P, B[P]);
					if (B[P] > 0) {
						ans++;
						B[P]--;
						break;
					}
				}
			}
		}
	}
	cout << ans;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

ll mypow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = mypow(a, n/2);
    return res * res;
  }
  return a * mypow(a, n-1);
}


signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, k;
  cin >> n >> k;
  ll ans = k*mypow(k-1, n-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0; i<(int)(n);i++)

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


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

long long GCD(long long A, long long B) {
	if (B == 0) return A;
	else return GCD(B, A % B);
}

int main() {
	long long N, M, L = 0, L2 = 0;
	vector<long long> A;
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	L = A[0], L2 = A[0] / 2;
	for (int i = 1; i < N; i++) L = (L / GCD(L, A[i])) * A[i], L2 = (L2 / GCD(L2, A[i] / 2)) * A[i] / 2;
	while (1) {
		bool check = true;
		for (int i = 0; i < N; i++) {
			A[i] /= 2;
			if (A[i] % 2 == 1) check = false;
		}
		if (!check) break;
	}
	bool check = true;
	for (int i = 0; i < N; i++) if (A[i] % 2 == 0) check = false;
	if (!check) cout << 0 << endl;
	else cout << M / L2 - M / L << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    string S;
    unsigned char s;
    cin >> S;
    int count = 0;
  	if(S.at(0) == '0' && S.size() == 1){
      cout << "Yes" << endl;
      return 0;
    }
    for(int i=0;i<S.size();i++){
        s = (unsigned char)S.at(i);
        a = (int)s;
        count += a - 48;
        //cout << a << endl;
        //cout << count << endl;
    }
    if(count%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3752
#include<iostream>
using namespace std;
bool check(int x)
{
	if(x%3==0||x%5==0) return true;
	else return false;
}
int main()
{
	int n,a[105],flag=0;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
		if(!check(a[i])) flag=1;
		}
		
	}
	if(flag==0) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s[3];
  rep(i,3)cin>>s[i];
  string res;
  rep(i,3){
    res+=s[i][0]+'A'-'a';
  }
  cout<<res<<"\n";
  return 0;
}


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

int main()
{
    int m,n,o,i,j,k;
    //float f,g,h;
    //char c,d;
    //string a;
    cin>>m>>n;
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    if(m==n) cout<<m+n;
    else if(m>n+1) cout<<m+m-1;
    else if(n>m+1) cout<<n+n-1;
    else cout<<m+n;
    return 0;
}


Measured memory_bytes: 888
def main():
    a = [int(input())-1 for _ in range(int(input()))]
    now = 0
    sumi = set()
    count = 0
    while now != 1:
        if now in sumi:
            print(-1)
            return
        sumi.add(now)
        now = a[now]
        count += 1
    print(count)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 13200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int a;
    cin>>a;
    double b= sqrt(a);
    a=(int)b;
    cout<<a*a<<endl;
}


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

int main() {
	int m, n;
	cin >> n >> m;
	vector <int> w;
	for(int i = 0; i<m; i++) w.push_back(0);
    int k, a, l=0;
    for(int i = 0; i<n; i++){
        cin >> k;
        for(int j=0; j<k; j++){
            cin >> a;
            w[a-1]++;
            if(w[a-1]==n) l++;
        }
    }
    
    cout << l << endl;
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll a,p;
  cin>>a>>p;
  cout<<(a*3+p)/2<<endl;
  return 0;
}


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

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

def solve(S: str):
    S = S[::-1]
    while len(S)>4:
        if S[:6]=="resare":
            S= S[6:]
        elif S[:5] == "esare" or S[:5]== "maerd":
            S=S[5:]
        elif S[:7] == "remaerd":
            S=S[7:]
        else:
            print(NO)
            return 
        
    
    if len(S) == 0:
        print(YES)
    else:
        print(NO)
    return


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: 3444
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;


int main(){
    int n;
    cin >> n;
    int ans = 0;
    int tmp = 0;
    ll h;
    cin >> h;
    for(int i = 1; i < n; i++){
        ll h_next;
        cin >> h_next;
        if(h >= h_next){
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
        h = h_next;
    }
    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, m;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld %lld", &n, &m);

  if (m >= n * 2) {
    ll remain = m - 2 * n;
    ans = (remain / 4) + n;
  }
  else {
    ans = m / 2;
  }

  printf("%lld\n", ans);

  return 0;
}


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

#define NEW 0
#define KIRI 1
#define KANAN 2

using namespace std;

int i,j,n,len,sum,nyan;
vector<int> a;
int mem[500007][4];
char s[500007];

int DP(int pos, int dari) {
	if (pos == n) return 0;
	if (mem[pos][dari] != -1) return mem[pos][dari];
	
	if (a[pos] == 0) {
		if (dari == KANAN || dari == KIRI) return mem[pos][dari] = 9999999;
		return mem[pos][dari] = DP(pos+1, NEW);
	}
	
	int sisa = a[pos];
	if (dari == NEW) {
		int ret = sisa + DP(pos+1, NEW);
		if (sisa >= 1) ret = min(ret, 1 + sisa - 1 + DP(pos+1,KIRI));
		if (sisa >= 1) ret = min(ret, 1 + DP(pos+1,KANAN));
		return mem[pos][dari] = ret;
	}
	
	if (dari == KANAN) {
		sisa--;
		int ret = sisa + DP(pos+1, NEW);
		if (sisa >= 1) ret = min(ret, 1 + sisa - 1 + DP(pos+1,KIRI));
		if (sisa >= 1) ret = min(ret, 1 + DP(pos+1,KANAN));
		return mem[pos][dari] = ret;
	}
	
	sisa--;
	sisa = min(sisa,1);
	int ret = sisa + DP(pos+1, NEW);
	if (sisa >= 1) ret = min(ret, 1 + sisa - 1 + DP(pos+1,KIRI));
	if (sisa >= 1) ret = min(ret, 1 + DP(pos+1,KANAN));
	
	if (sisa == 1) sisa = 0;
	ret = min(ret, sisa + DP(pos+1, NEW));
	if (sisa >= 1) ret = min(ret, 1 + sisa - 1 + DP(pos+1,KIRI));
	if (sisa >= 1) ret = min(ret, 1 + DP(pos+1,KANAN));
	
	return mem[pos][dari] = ret;
}

int main() {
	scanf("%d",&len);
	scanf("%s",s);
	
	for (i=0 ; i<len ; i++) {
		if (s[i] == '1') sum++,nyan++;
		else {
			a.push_back(sum);
			sum = 0;
		}
	}
	a.push_back(sum);
	a.push_back(0);
	
	n = a.size();
	
	//for (i=0 ; i<n ; i++) printf("%d ",a[i]);
	
	for (i=0 ; i<n ; i++) {
		for (j=0 ; j<=2 ; j++) {
			mem[i][j] = -1;
		}
	}
	
	printf("%d\n",nyan-DP(0,0));
}


Measured memory_bytes: 41840
#include <iostream>

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int taro[100];
	int hanako[100];
	int n, m;
	while(cin >> n >> m, n){
		for (int i = 0; i < n; i++)
			cin >> taro[i];
		for (int i = 0; i < m; i++)
			cin >> hanako[i];
		int sumtaro = 0, sumhanako = 0;
		for (int i = 0; i < n; i++)
			sumtaro += taro[i];
		for (int i = 0; i < m; i++)
			sumhanako += hanako[i];
		int diff = sumhanako - sumtaro;
		int pairsum = 1000;
		int extaro, exhanako;
		for(int i = 0; i < n; i++)
			for (int j = 0; j < m; j++) 
				if (diff == 2*(hanako[j] - taro[i]) )
					if (taro[i] + hanako[j] < pairsum) {
						extaro = taro[i];
						exhanako = hanako[j];
						pairsum = extaro + exhanako;
					}
		if (pairsum == 1000)
			cout << "-1" << endl;
		else
			cout << extaro << " " << exhanako << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.Runtime.InteropServices.ComTypes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NM[0];
        var M = NM[1];
        var ans = new long[N+1];

        for (int i = 1; i <= M; i++)
        {
            var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = AB[0];
            var B = AB[1];

            ans[A]++;
            ans[B]++;
        }

        var tmp = "YES";

        for (int i = 1; i <= N; i++)
        {
            if(ans[i]%2 == 1)
            {
                tmp = "NO";
                break;
            }
        }
        

        Console.WriteLine(tmp);
    }
}


Measured memory_bytes: 47628
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,y;
    cin>>n>>y;
    for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
    for(int k=0;k<=n,i+j+k<=n;k++)
    {
        if(i*10000+j*5000+k*1000==y&&i+j+k==n)
        {
            printf("%d %d %d",i,j,k);
             return 0;
        }
    }
    printf("-1 -1 -1");
    return 0;
}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    int w, h, nx, ny, cnt;
    cin >> h >> w;
    array<string, 100> v;
    rep(i, h)
    {
        cin >> v[i];
    }
    rep(i, h)
    {
        rep(j, w)
        {
            if (v[i][j] == '#')
            {
                continue;
            }
            cnt = 0;
            rep(k, 8)
            {
                nx = i + dx[k];
                ny = j + dy[k];
                try
                {
                    if (v.at(nx).at(ny) == '#')
                    {
                        cnt++;
                    }
                }
                catch (out_of_range &e)
                {
                    continue;
                }
            }
            v[i][j] = char(cnt + '0');
        }
    }
    rep(i, h)
    {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B)


if __name__ == '__main__':
    solve()


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

int main() {
  int h1, m1, h2, m2, k;
  scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);

  int ans = h2 * 60 + m2 - h1 * 60 - m1 - k;
  printf("%d\n", ans);

  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 	for (int i = 0; i < 5; ++i) {
 		int x;
 		cin >> x;
 		if (x != i + 1) {
 			cout << i + 1;
 			return 0;
 		}
 	}
	return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long k = scanner.nextLong();
    long a = scanner.nextLong();
    long b = scanner.nextLong();
    if (b - a <= 2 || k <= a) {
      System.out.println(k + 1);
      return;
    } else {
      long ans = a;
      long turn = k - a + 1;
      long syo = turn / 2;
      if (turn % 2 == 0) {
        System.out.println(ans + b * syo - a * syo);
      } else {
        System.out.println(ans + b * syo - a * syo + 1);
      }
    }
  }

}


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

int main() {
  string s;
  int ans = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    ans = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[i] == s[j])
        ans++;
    }
    if (ans > 1) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}


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

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

	string a, b;
	cin >> a >> b;
	if (a.size() > b.size())
		cout << "GREATER" << endl;
	else if (a.size() < b.size())
		cout << "LESS" << endl;
	else
	{
		if (a > b)
			cout << "GREATER" << endl;
		else if (a == b)
			cout << "EQUAL" << endl;
		else
			cout << "LESS" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e9;
const int Bmax=2e5;

int main(){
  int n; cin>>n;
  int a,x,y;
  vector<vector<int>> g(n,vector<int>(n)); // g[i][j]: iの人の証言でjの人に関して．
  rep(i,n) rep(j,n) g[i][j]=-1;

  rep(i,n){//入力
    cin>>a;
    rep(j,a){
      cin>>x>>y;
      x--;
      g[i][x]=y;
    }
  }
  // 10の表記
  int ans=0;
  rep(i,1<<n){
    vector<int>d(n);
    int num=0;
    rep(j,n) if(i>>j&1){
      d[j]=1;
      num++;
    }else{
      d[j]=0;
    }
    bool ok=true;


    rep(j,n){
      if(d[j]==1){
        rep(k,n){
          if(g[j][k]==1 && d[k]==0){
            ok=false;
            break;
          }
          if(g[j][k]==0 && d[k]==1){
            ok=false;
            break;
         }
        }
      }

      if(!ok) break;
    }
    if(ok) ans=max(ans,num);



  }
  cout<<ans<<endl;




}


Measured memory_bytes: 3632
a,b,k=(int(i) for i in input().split())
#print(a,b,k)
cnt=0
x=min(a,b)
for i in range(x,0,-1):
  if a%i==0 and b%i==0:
    cnt+=1
    if cnt==k:
      print(i)
      cnt+=1


Measured memory_bytes: 2940
import itertools
n = int(input())
s = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    s.append(array)
s = list(itertools.chain.from_iterable(s))
d = "No"
x = 0
while x+5 < len(s):
    if s[x] == s[x+1] and s[x+2] == s[x+3] and s[x+4] == s[x+5]:
        d = "Yes"
        break
    else:
        x += 1
print(d)

Measured memory_bytes: 9140
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		long NN = sc.nextLong();
		long a = 0;
		long b = 0; 
		String S = String.valueOf(NN);
		int R = S.length()/2+S.length()%2;  
		if( NN==1000000000000L ){
			R = 6;          
        }          
		long c = 1;
		for( int i=0; i<R; i++ ){
			c = c*10;
		}
		long A = 0,B = 0;      
		for( int i=1; i<=c; i++ ){
			a++;
			b = NN/a;
			if( NN%a==0 ){
				A = a;
				B = b;              
			}
			if( a>=b ){
				break;              
            }              
			if( i==c ){
				A = NN;
				B = 1;
			}
		}
		System.out.println((A-1)+(B-1));
	}
}


Measured memory_bytes: 21972
a[4],b[4];main(i,j,h,l){for(;~scanf("%d%d%d%d%d%d%d%d",a,a+1,a+2,a+3,b,b+1,b+2,b+3);printf("%d %d\n",h,l))for(i=h=l=0;i<4;i++)for(j=0;j<4;j++)if(a[i]==b[j])i==j?h++:l++;return 0;}

Measured memory_bytes: 596
using System;

namespace A114
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());

            if (A == 3 || A == 5 || A == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

vector<ll> divisors(ll N) {
  vector<ll> res;
  for (ll k = 1; k * k <= N; k++) {
    if (N % k == 0) {
      res.push_back(k);
      if (k != N / k) {
        res.push_back(N / k);
      }
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N;
  while (cin >> N) {
    ll res = 0;
    for (ll m1 : divisors(N)) {
      ll m = m1 - 1;
      if (m > 0 && N / m == N % m) {
        res += m;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <limits.h>

#define ll long long

using namespace std;

int main(){

    int n,k;
    cin >> n >> k;

    ll dp[2001][2001] = {};


    for(int i = 0; i <= n; i++) dp[i][0] = 1;

    dp[1][1] = 1;

    for(int i = 2; i <= n; i++){

        for(int j = 1; j <= i; j++){
            dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % 1000000007;
        }
    }

    for(int i = 1; i <= n; i++) dp[i][0] = 1;

    for(int i = 1; i <= k; i++){
        //int ans = (mycombo(n - k + 1, i) * mycombo(k - 1,i - 1)) % 1000000007;

        ll ans = (dp[n - k + 1][i] * dp[k - 1][i - 1]) % 1000000007;

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastt ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int main()
{
	fastt

	ll d,s,t;
	cin>>d>>s>>t;
	if(s*t>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}



Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner  = new Scanner(System.in);
		final int r = scanner.nextInt();
		final int D = scanner.nextInt();
		int x = scanner.nextInt();
		for(int i = 0; i < 10; i++) {
			x =  r * x - D;
			System.out.println(x);
		}
		scanner.close();
	}

}


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

using u64 = unsigned long long;
const u64 MOD = 1000000007;

int main(void) {
  u64 N, K;
  cin >> N >> K;
  u64 ans = 0;
  for (u64 k = K; k <= N + 1; k++) {
    u64 min = (0 + (k - 1)) * k / 2;
    u64 max = ((N - k + 1) + N) * k / 2;
    ans += max - min + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

int qsort_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int main(int argc, char *argv[])
{
    int n;
    int a[100000];
    int alive, offset;
    int check;
    int i;
    int ans;

    scanf("%d", &n);

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

    qsort(a, n, sizeof(int), qsort_int);

    alive = n;
    offset = 0;
    check = 0;
    while(alive > 1) {
        if (a[offset] == 1) {break;}
        check = 0;
        for (i = offset + 1; i < n; i++) {
            a[i] %= a[offset];
            if (a[i] < 1) {alive--;}
            if (a[i] > 0 && a[i] % a[offset] == 0) {check++;}
        }
        if (check == alive - 1) {break;}
        qsort(a + offset, n - offset, sizeof(int), qsort_int);
        offset = n - alive;
    }

    printf("%d\n", a[offset]);

    return 0;
}


Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep(i,n){
        if (h[i] >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
using namespace std;
int main() {
    fio;
    // freopen("input.txt", "r", stdin);
    int n, i;
    cin >> n >> i;
    cout << n - i + 1;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
 
 
public class Main {  
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Main m = new Main();
        String line = br.readLine();
        int num = Integer.parseInt(line);
        m.SecToTime(num);
    }
    
    public void SecToTime(int sec){
        int h = 0,m = 0;
         
        while(sec >= 3600){
            h++;
            sec -= 3600;
        }
         
        while(sec >= 60){
            m++;
            sec -= 60;
        }
         
        System.out.println(h+":"+m+":"+sec);
    }
 
}

Measured memory_bytes: 24332
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

int vv[MX] = {};
bool valid(int l, int r, int n) { return ((n >= l) && (n <= r)); }
void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; };
}
void solve() {
  // sort(all(A));
  map<int, int> mp;
  for (auto x : A) {
    mp[x]++;
  }
  for (auto x : mp) {
    vv[x.first] = x.second;
  }

  int ans = -INF;
  rep(i, 0, MX) {
    int tmp = 0;
    rep(j, -1, 1) {
      if (valid(0, MX - 1, i + j)) {
        tmp += vv[i + j];
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 5760
from fractions import gcd
n,m=map(int,input().split())
s = input()
t = input()
g = gcd(n,m)
ng = n//g
mg = m//g
for i in range(g):
    if s[ng*i]!=t[mg*i]:
        print("-1")
        break
else:
    print(n*m//g)

Measured memory_bytes: 5344