akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ws = []
ans = 'Yes'
for _ in range(n):
    w = input()
    if w in ws:
        ans = 'No'
        break
    else:
        if len(ws)>0:
            if ws[-1][-1] == w[0]:
                pass
            else:
                ans = 'No'
                break    
        ws.append(w)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>//printf("%.15f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字)
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	double a, b;
	cin >> a >> b;

	cout << 2 * b - a << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 256
import java.util.Scanner;

class ACGTHashList {
    private int M;
    private String[] H;

    public ACGTHashList(int M) {
        this.M = M;
        this.H = new String[M];
        for (int i = 0; i < M; i++) this.H[i] = "";
    }

    private static int ACGTtoInt(char c) {
        switch (c) {
            case 'A': return 1;
            case 'C': return 2;
            case 'G': return 3;
            case 'T': return 4;
        }
        return 0;
    }

    private int getKey(String str) {
        int sum = 0;
        for (int i = 0, p = 1; i < str.length(); i++, p *= 5) {
            sum += p * ACGTtoInt(str.charAt(i));
        }
        return sum;
    }

    private int h1(int key) {
        return key % this.M;
    }

    private int h2(int key) {
        return 1 + key % (this.M - 1);
    }

    public boolean find(String str) {
        int key = getKey(str);
        int h;
        int h1 = h1(key), h2 = h2(key);
        for (int i = 0;; i++) {
            h = (h1 + i* h2) % this.M;
            if (this.H[h].equals(str)) return true;
            else if (this.H[h].equals("")) return false;
        }
    }

    public boolean insert(String str) {
        int key = getKey(str);
        int h;
        int h1 = h1(key), h2 = h2(key);
        for (int i = 0;; i++) {
            h = (h1 + i * h2) % this.M;
            if (this.H[h].equals(str)) return false;
            else if (this.H[h].equals("")) {
                this.H[h] = str;
                return true;
            }
        }
    }
}


class Main {
    public static void main(String[] args) {
        ACGTHashList list = new ACGTHashList(1046527);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String command = sc.next();
            String key = sc.next();
            switch(command.charAt(0)) {
            case 'i':
                list.insert(key);
                break;
            case 'f':
                System.out.println(list.find(key) ? "yes" : "no");
            }
        }
    }
}



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

using namespace std;

int main() {
  long long inf = 1e18;
  int n, m;
  cin >> n >> m;
  long long d[n];
  d[0] = 0;
  for (int i = 1; i < n; ++i) d[i] = inf;
  vector< vector<int> > a(m, vector<int>(3));
  for (int i = 0; i < m; ++i) {
    int l, r, c;
    cin >> l >> r >> c;
    a[i][0] = l-1;
    a[i][1] = r-1;
    a[i][2] = c;
  }
  sort(a.begin(), a.end());
  for (const auto& e : a) {
    int l = e[0], r = e[1], c = e[2];
    for (int j = l; j < r; ++j) {
      long long t = d[j] + c;
      if (t < d[r]) d[r] = t;
    }
  }
  if (d[n-1] == inf) cout << -1 << endl;
  else cout << d[n-1] << endl;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int K;
int P[200010];
int s[200010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> P[i], s[i] = 1;
    
    set<int> st;
    for(int i = 0; i < N; i++){
        if(P[i + 1] > P[i]) s[i + 1] = s[i] + 1;
    }
    for(int i = 0; i < K; i++){
        st.insert(P[i]);
    }

    int res = !(s[K - 1] >= K);
    bool flag = s[K - 1] >= K;
    for(int i = K; i < N; i++){
        st.insert(P[i]);
        auto it1 = st.begin();
        auto it2 = st.rbegin();
        if(P[i - K] != *it1 || P[i] != *it2){
            if(s[i] < K) res++;
            else flag = true;
        }
        st.erase(P[i - K]);
    }

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

Measured memory_bytes: 11264
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String ans ="";
    for (int i=S.length()-1; i>0 ; i--) {
      if (i % 2 == 0) {
        String S1 = S.substring(0,i/2);
        String S2 = S.substring(i/2,i);
        if (S1.equals(S2)) {
          ans = S1 + S2;
          break;
        }
      }
    }
    System.out.println(ans.length());
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n, k;
  while (scanf("%d %d", &n, &k) != EOF)
  {
    bool has[n]; memset(has, false, sizeof(has));
    for (int i = 0; i < k; i++)
    {
      int di; scanf("%d", &di);
      for (int j = 0; j < di; j++)
      {
        int aij; scanf("%d", &aij); aij--;
        has[aij] = true;
      }
    }

    int ans = 0; for (int i = 0; i < n; i++) ans += !has[i];
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define LL long long

using namespace std;
const int maxn = 2e5+7;
char s[maxn];
int main()
{
    scanf("%s",s);
    int L=strlen(s);
    LL tmp=0,ans=0;
    for (int i=0;i<L;i++)
    {
        if (s[i]=='B') tmp++;
        else ans+=tmp;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384
# a_i + a_j = j-i
# a_i + i = j - a_j
# a[i]+i = i -a[i]となることはない

n=int(input())
a=list(map(int,input().split()))

ilis=[0]*n
jlis=[0]*n

for i in range(n):
  ilis[i]=a[i]+i
  jlis[i]=i-a[i]

from collections import defaultdict
idic=defaultdict(int)
jdic=defaultdict(int)
for i in range(n):
  idic[ilis[i]]+=1
  jdic[jlis[i]]+=1

ans=0
for item in idic.items():
  ans+=item[1] * jdic[item[0]]

print(ans)

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

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

	int a,b;

	cin >> a >> b;

	if(a+b==15)
	{
		cout << '+' << '\n';
	}
	else if(a*b==15)
	{
		cout << '*' << '\n';
	}
	else
	{
		cout << 'x' << '\n';
	}
	
	return 0;
}

Measured memory_bytes: 256
while(True):
    n = int(input())
    if n == 0 : exit()
    b = list(map(int, input().split()))
    even, odd = b[:n], b[n:]
    sq = even[0]*even[1]//odd[0]
    l, r = 1, 2**32
    while r-l > 1:
        mid = (l+r)//2
        if mid*mid <= sq : l = mid
        else             : r = mid
    print(l)
    print(" ".join(map(str, sorted([x//l for x in even]))))


Measured memory_bytes: 10276
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#define rep(i,x,y) for(int i=(x);i<=(y);i++)
using namespace std;
typedef long long ll;
int n;
const int N=200005;
map<long long,int> mp;
long long a[N];
int id[N];
int fa[N],size[N];
bool cmp(int x,int y){return a[x]>a[y];}
int main()
{
//freopen("input.txt","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >>n;
rep(i,1,n)cin >>a[i],id[i]=i,mp[a[i]]=i,size[i]=1;
sort(id+1,id+1+n,cmp);
rep(i,1,n-1)
	{
	int x=id[i];
	fa[x]=mp[a[x]-n+2*size[x]];
	if(!fa[x])return cout <<-1,0;
	size[fa[x]]+=size[x];
	}
rep(i,1,n-1)
	{
	a[id[n]]-=size[id[i]];
	}
if (a[id[n]]) return puts("-1"),0;
rep (i,1,n-1) cout <<id[i]<<' '<<fa[id[i]]<<'\n';
return 0;
}


Measured memory_bytes: 9600
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_string = "";

// Settings
var Y500 = 500;
//var Y100 = 100.0;
//var Y50  = 50.0;
//var Y10  = 10.0;
var Y5   = 5;
//var Y1   = 1.0;

var V500 = 1000;
var V5 = 5;
// output 
var value = 0;

var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

reader.on('line', (line) => {
    input_string = line;
    //convert number
    input_number = parseInt(input_string);

    var N500 = Math.floor(input_number / Y500); // 500円の枚数
    value += N500 * V500;
    input_number -= N500 * Y500;
    
    var N5 = Math.floor(input_number / Y5);
    value += N5 * V5;
    input_number -= N5 * Y5;

});

reader.on('close', () => {
    // output
    console.log(value);
});


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

int main() {
  int N, K, M = 1;
  cin >> N >> K;
  
  for (int i = 0; i <N; i++) {
    if (M >= K) {
      M += K;
    }
    if (M < K) {
      M += M;
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 256
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        x: usize
    };

    if x == 5 || x == 7 || x == 3 {
        println!("YES")
    } else {
        println!("NO")
    }
}


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

#define FOR(a, b) for (int i = a; i < b; ++i)
#define FOR_EACH(container) for (const auto& p: container)
#define SORT(container) sort(container.begin(), container.end())
#define DSORT(container) sort(container.begin(), container.end(), greater<>())

using namespace std;

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

    int N, K;
    string str;

    cin >> N >> str >> K;

    str.reserve(N);

    auto pivot = str[K - 1];

    for (auto& ch: str)
    {
        if (ch != pivot)
        {
            ch = '*';
        }
    }

    cout << str << "\n" << flush;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long[] cost = new long[M];
        int[][] index = new int[N][N];
        long[][] d = new long[N][N];
        long INF = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                index[i][j] = -1;
                if (i != j) {
                    d[i][j] = INF;
                }
            }
        }
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            int c = sc.nextInt();
            cost[i] = c;
            index[a][b] = i;
            index[b][a] = i;
            d[a][b] = c;
            d[b][a] = c;
        }
        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        boolean used[] = new boolean[M];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                for (int k = 0; k < N; k++) {
                    if (index[k][j] != -1 && d[i][j] == d[i][k] + cost[index[k][j]]) {
                        used[index[k][j]] = true;
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (!used[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 27744
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
llong N, K, ANS = 0;
int main() {
	cin >> N >> K;
	while (N != 0) {
		ANS += 1;
		N /= K;
	}
	cout << ANS;
}

Measured memory_bytes: 256
/*
	Auther:_Destiny
	time:2020.5.3
*/
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
bool b[M];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int main() {
	int ans = 0;
	int n = read(), k = read();
	for (int i = 1; i <= k; i++) {
		int a = read();
		for (int j = 1; j <= a; j++) {
			int s = read();b[s] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
		if (!b[i]) ans++;
	cout << ans << "\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++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 int INF=1e9;


int main(){
  int n,k;
  cin>>n>>k;
  vector<int> p(n), q(n); //q[i],,, i番目までの数の合計
  rep(i,n) {
    cin>>p[i];
    if(i>0) q[i]=q[i-1]+p[i]+1;
    else q[0]=p[0]+1;
   // cout<<q[i]<<endl;
  }
  
  int ans2=0;

  for(int i=0;i<=n-k;i++){//K個の最初の座標．
    int now2;
    if(i==0){
      now2=q[k-1];
    }else{
      now2=q[i+k-1]-q[i-1];      
    }
    ans2=max(now2,ans2);
  }
  
  printf("%f",double(ans2)/2.0);
  return 0;
  
    
    

    
  
}


Measured memory_bytes: 1792
s = input()
l = [chr(ord("a")+i) for i in range(26)]
arr = {}
for i in l:
  arr[i] = False
for j in s:
  arr[j] = True
for k, v in sorted(arr.items()):
  if v == False:
    print(k)
    exit()
print("None")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans;
  cin >> N;
  bool result = false;
  
  for (int i = 0; i < N; i++){
    string C;
    cin >> C;
    if (C == "Y") result = true;
  }
  
  if (result) cout << "Four" << endl;
  else cout << "Three" << endl;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
if x >= 0:
    if x - k * d >= 0:
        print(x - k * d)
    else:
        # 最初に負になってしまうところとその直前を巡回する
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ok + ng) // 2
            if x - mid * d <= 0:
                # いきすぎ
                ok = mid
            else:
                ng = mid
        # ok回目で負にたどり着く？
        rest = k - ok
        if rest % 2 == 0:
            # いまいるところに戻ってこれる
            print(abs(x - ok * d))
        else:
            # 一回正方向にいどうしたもの
            print(x - (ok - 1) * d)
else:
    if x + k * d <= 0:
        print(abs(x + k * d))
    else:
        # 最初に正になるところ
        ok, ng = k, 0
        while (ok - ng) > 1:
            mid = (ng + ok) // 2
            if x + mid * d >= 0:
                ok = mid
            else:
                ng = mid
        rest = k - ok
        if rest % 2 == 0:
            print(x + ok * d)
        else:
            print(abs(x + ok * d - d))

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<map> 
#include<vector>
using namespace std;

char c[10][10];
int main()
{
	for (int i=1;i<=3;i++)
	{
		for (int j=1;j<=3;j++) cin>>c[i][j];
	}
	cout<<c[1][1]<<c[2][2]<<c[3][3]<<endl;
	return 0;
}


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

template<class T> T in() {T a; cin >> a; return a;}
#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 << '\n';}
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 << (it == d.b ? "" : ", ") << *it;
	ris << "]";
}
#else
sim dor(const c&) {ris;}
#endif
};
#define imie(...) " [" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0);
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

LL com2(LL n){
  if(n<=0)return 0;
  return n*(n-1)/2;
}

int main(){
  LL N,i,ans=0,a=0;
  scanf("%lld",&N);
  LL A[N],c[200010]={0};
  rep(i,N)scanf("%lld",&A[i]);
  rep(i,N)c[A[i]]++;
  rep(i,N+1)a+=com2(c[i]);
  rep(i,N)printf("%lld\n",a-com2(c[A[i]])+com2(c[A[i]]-1));

  //printf("\n%lld\n",com2(2));
	return 0;
}


Measured memory_bytes: 5632
a = list(map(int,input().split()))
n = a[0]
k = a[1]

if 2*n <= k:
  n = n
elif (k<2*n)and(n<=k):
  n = k-n
elif k<n:
  n = n%k
  if 2*n<=k:
    n = n
  else:
    n = k-n
print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int MAX_N=10000; 
using namespace std;
int addx[MAX_N];int addy[MAX_N];int hash[1000];
int main(){
    int n,k;cin>>n>>k;int ans=1;
	while(n--){
		ans+=min(k,ans);
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
r = i = 0
while sum(h) != 0:
    if h[i] == 0:
        i += 1
    else:
        r += 1
        while i < n and h[i] > 0:
            h[i] -= 1
            i += 1
        i = 0
print(r)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
static inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main()
{
    fast_io();

    ll n;
    cin >> n;
    ll ans = 1;
    bool zero = false;
    for (ll i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        if (tmp == 0) {
            zero = true;
        }
        if (ans != 0 && (ll)1E18 / ans < tmp) {
            ans = 0;
        } else {
            ans *= tmp;
        }
    }
    if (zero || ans) {
        cout << ans;
    } else {
        cout << -1;
    }
}


Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc145/tasks/abc145_c

int main() {
    int N; cin >> N;
    int X[N];
    int Y[N];
    REP(i, N) {
        cin >> X[i];
        cin >> Y[i];
    }

    vector<int> perm;
    REP(i, N)perm.push_back(i);
    sort(perm.begin(), perm.end());

    double sum = 0.0;
    int p = 0;
    do {
        ll prevX = INF;
        ll prevY = INF;
        double dist = 0.0;
        for (int i = 0; i < perm.size(); i++) {
            int curX = X[perm[i]];
            int curY = Y[perm[i]];
            if (prevX != INF) {
                dist += sqrt((curX-prevX)*(curX-prevX)+(curY-prevY)*(curY-prevY));
            }
            prevX = curX;
            prevY = curY;
        }
        sum += dist;
        p++;
    } while(next_permutation(perm.begin(), perm.end()));


    cout << std::setprecision(12) << sum/p << "\n";

    return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
n = ii()

def get_head(x):
    while x:
        b = x%10
        x //= 10
    return b

dp = [[0] * 10 for i in range(10)]
for i in range(1,n+1):
    h = get_head(i)
    t = i%10
    dp[h][t] += 1

for i in range(10):
    dp[0][i] = 0
    dp[i][0] = 0

ans = 0
for i in range(1,n+1):
    h = get_head(i)
    t = i%10
    ans += dp[t][h]

print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int h, w, n;
	cin >> h >> w >> n;
	int a = max(h, w);
	if (n % a == 0) cout << n / a << endl;
	else cout << n / a + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 764
import scala.io.StdIn._
object Main extends App {

  val n = readInt()
  val price = readLine.trim.split(' ').map(_.toInt)
  val t = readLine.trim.split(' ').map(_.toInt)
  val memo = Array.fill(n + 1){Int.MaxValue}.also{_(0) = 0}
  for (i ← 0 until 4) {
    for (j ← memo.indices if memo(j) != Int.MaxValue) {
      val k =  if (j + t(i) > n) n else j + t(i)
      if (memo(k) > memo(j) + price(i)) {
        memo(k) = memo(j) + price(i)
      }
    }
  }
  println(memo.last)

  implicit class Scope[T](val value: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(value)
    def also(@inline func: T ⇒ Unit): T = {func(value);value}
  }
}



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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> c(N);
  for(int i=0;i<M;i++){
    cin >> a.at(i) >> b.at(i);   
    c.at(a.at(i)-1)++;
    c.at(b.at(i)-1)++;
  }
  for(int j=0;j<N;j++){
    cout << c.at(j) << endl;
  }
}


Measured memory_bytes: 3600
import collections
n = int(input())
a = list(map(int,input().split()))

used = collections.Counter(a)
a.sort()
a.reverse()

two = [2]
i = 0
while two[i]*2 <= 2*10**9:
    two.append(two[i]*2)
    i += 1

counter = 0
for i in range(n):
    if used[a[i]] > 0:
        used[a[i]] -= 1
        while two[-1] > 2*a[i]:
            two.pop(-1)

        if used[two[-1]-a[i]] >= 1:
            counter += 1
            used[two[-1]-a[i]] -= 1

print(counter)

Measured memory_bytes: 33296
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int64_t ans;
  
  if(K < A){
    ans = K;
  }
  else if(K < A+B){
    ans = A;
  }
  else{
    int64_t del = K - (A + B);
    ans = A - del;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

UnionFind tree(N);

rep(i,M){
    int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    tree.unite(x,y);
}
bool group[N+1]={};
rep(i,N){
    if(!group[tree.root(i)])
    {
    group[tree.root(i)]=true;
    }
}
int  ans=0;
rep(i,N){
    if(group[i])ans++;
}

cout<<ans<<endl;
 return 0;
}
/*
3 1
1 2 1

2


6 5
1 2 1
2 3 2
1 3 3
4 5 4
5 6 5

2

100000 1
1 100000 100

99999
*/

Measured memory_bytes: 1024
#include <stdio.h>
#define M 102
int main(void){
    int i,n,j,h;
    int u,k,v[M][M];
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v[i][j]);
        }
    }
    for(i=1;i<=n;i++){
        h=0;
        for(j=1;j<=n;j++){
            if(j== v[i][h]){
                printf("1");
                h++;
            }
            else printf("0");
            if(j!=n)printf(" ");
            }
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2072
def main():
    s = input()
    t = input()

    dp = [[0]*(len(t)+1) for i in range(len(s)+1)]


    check = 0
    for i in range(len(s)):
        
        for j in range(len(t)):
            if s[i]==t[j]:
                dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
            else:
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
        
    i = len(s)
    j = len(t)
    ans = ""
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans = s[i-1] + ans
            i -= 1
            j -= 1
    print(ans)        
if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int x; cin >> x;
  cout << 1-x << endl;
}

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

typedef long long ll;

int main() {
   vector<vector<int>> v(3, vector<int> (3));
   vector<vector<bool>> ch(3, vector<bool> (3));
   for (int i = 0; i < 3; ++i) {
	   for (int j = 0; j < 3; ++j) {
		   cin >> v[i][j];
	   }
   }
   int n;
   cin >> n;
   vector<int> val(n);
   for(int i = 0; i < n; ++i) {
	   cin >> val[i];
   }
   for(int i = 0; i < n; ++i) {
	   for (int j = 0; j < 3; ++j) {
		   for (int k = 0; k < 3; ++k) {
			   if (v[j][k] == val[i]) {
				   ch[j][k] = 1;
			   }
		   }
	   }
   }
   bool d = 0;
   for (int i = 0; i < 3; ++i) {
	   bool a = 1;
	   bool b = 1;
	   for (int j = 0; j < 3; ++j) {
		   if (ch[i][j] != 1) {
			   a = 0;
		   }
		   if (ch[j][i] != 1) {
			   b = 0;
		   }
	   }
	   if (a || b) {
			   d = 1;
		}
   }
   if (ch[0][0] == 1 && ch[1][1] == 1 && ch[2][2] == 1) {
	   d = 1;
   }
   if (ch[2][0] == 1 && ch[1][1] == 1 && ch[0][2] == 1) {
	   d = 1;
   }
   if (d) {
	   cout << "Yes";
   }else {
	   cout << "No";
   }
}



















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

int main(){
  int n;
  std::cin>>n;
  int minv,maxv;
  std::vector<int> vec(n);
  for(auto &v:vec)
    std::cin>>v;
  maxv=-1e9;
  minv=vec[0];
  for(int i=1;i<n;++i){
    maxv = std::max(maxv,vec[i]-minv);
    minv = std::min(minv,vec[i]);
  }

  std::cout<<maxv<<std::endl;
  return 0;
}

Measured memory_bytes: 3588
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, m = map(int, readline().split())
  left = 0
  right = 10**106
  for _ in range(m):
    l, r = map(int, readline().split())
    left = max(l, left)
    right = min(r, right)
  print(max(right-left+1, 0))
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var h, w int
	fmt.Fscan(r, &h)
	fmt.Fscan(r, &w)

	grid := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Fscan(r, &grid[i])
	}

	count := make([][]int, h)
	for i := 0; i < h; i++ {
		count[i] = make([]int, w)
	}

	// 横方向に連続する空白マスを数える
	for i := 0; i < h; i++ {
		done := make([]int, w)
		for j := 0; j < w; j++ {
			if grid[i][j] == '#' {
				continue
			}
			if done[j] == 1 {
				continue
			}
			l := 0
			for j+l < w {
				if grid[i][j+l] == '#' {
					break
				}
				l++
			}
			for k := 0; k < l; k++ {
				count[i][j+k] += l
				done[j+k] = 1
			}
		}
	}
	// 縦方向に連続する空白マスを数える
	for j := 0; j < w; j++ {
		done := make([]int, h)
		for i := 0; i < h; i++ {
			if grid[i][j] == '#' {
				continue
			}
			if done[i] == 1 {
				continue
			}
			l := 0
			for i+l < h {
				if grid[i+l][j] == '#' {
					break
				}
				l++
			}
			for k := 0; k < l; k++ {
				count[i+k][j] += l
				done[i+k] = 1
			}
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			ans = max(ans, count[i][j]-1)
		}
	}
	fmt.Println(ans)

	/* 愚直に書いたもの。TLE!!
	dx := []int{1, 0, -1, 0}
	dy := []int{0, 1, 0, -1}
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] == '#' {
				continue
			}
			tmp := 0
			for k := 0; k < 4; k++ {
				nx := j + dx[k]
				ny := i + dy[k]
				for 0 <= nx && nx < w && 0 <= ny && ny < h && grid[ny][nx] != '#' {
					tmp++
					nx += dx[k]
					ny += dy[k]
				}
			}
			ans = max(ans, tmp)
		}
	}
	fmt.Println(ans + 1)
	*/
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}


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

int N, M, A[200009], B[200009], pre[200009], low[200009], cnts;
vector<pair<int, int>> X[200009];
vector<int> G;

void dfs(int pos, int par) {
	cnts++;
	pre[pos] = cnts; low[pos] = cnts;
	for (int i = 0; i < X[pos].size(); i++) {
		int to = X[pos][i].first;
		if (low[to] == (1 << 30)) {
			dfs(to, pos);
			low[pos] = min(low[pos], low[to]);
			if (low[to] == pre[to]) {
				G.push_back(X[pos][i].second);
			}
		}
		else {
			if (to == par) continue;
			low[pos] = min(low[pos], low[to]);
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i]; if (A[i] > B[i]) swap(A[i], B[i]);
		X[A[i]].push_back(make_pair(B[i], i));
		X[B[i]].push_back(make_pair(A[i], i));
	}
	for (int i = 0; i <= N; i++) { pre[i] = (1 << 30); low[i] = (1 << 30); }
	dfs(0, -1);
	vector<pair<int, int>>F;
	for (int i = 0; i < G.size(); i++) {
		F.push_back(make_pair(A[G[i]], B[G[i]]));
	}
	sort(F.begin(), F.end());
	for (int i = 0; i < F.size(); i++) cout << F[i].first << " " << F[i].second << endl;
	return 0;
}


Measured memory_bytes: 10036
#include <iostream>

using namespace std;

int analyze(string s) {
    int sum = 0;
    for (int i = 0; i < s.length(); i++) {
        if ('a' > s[i] || s[i] > 'z')
            continue;
        int base = 0;
        switch (s[i]) {
        case 'm':
            base = 1000;
            break;
        case 'c':
            base = 100;
            break;
        case 'x':
            base = 10;
            break;
        case 'i':
            base = 1;
            break;
        }
        int mul = 1;
        if (i != 0 && ('2' <= s[i-1] && s[i-1] <= '9'))
            mul = s[i-1] - '0';
        sum += mul * base;
    }
    return sum;
}

string reverse(int i) {
    string out = "";
    for (int base = 1000; base > 0; base /= 10) {
        if (i / base == 0)
            continue;
        if (i / base >= 2)
            out.push_back('0' + i/base);
        char sign;
        switch (base) {
        case 1000:
            sign = 'm';
            break;
        case 100:
            sign = 'c';
            break;
        case 10:
            sign = 'x';
            break;
        case 1:
            sign = 'i';
            break;
        }
        out.push_back(sign);
        i %= base;
    }
    return out;
}

int main()
{
    int n;
    cin >> n;
    while (n--) {
        string s1, s2;
        cin >> s1 >> s2;
        int sum = analyze(s1) + analyze(s2);
        cout << reverse(sum) << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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); }

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

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

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    intmax_t a, b, c, d;
    cin >> a >> b >> c >> d;

    auto lcm = [&](intmax_t a, intmax_t b) { return a / __gcd(a, b) * b; };

    intmax_t common = lcm(c, d);

    intmax_t c_cnt = (b / c) - ((a - 1) / c);
    intmax_t d_cnt = (b / d) - ((a - 1) / d);
    intmax_t common_cnt = (b / common) - ((a - 1) / common);
    intmax_t all = (b - a + 1);

    cout << all - (c_cnt + d_cnt - common_cnt) << "\n";

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
#mの約数を調べる
temp=[]
i=1
while i*i<=m:
    if m%i==0:
        temp.append(i)
        if m//i!=i:
            temp.append(m//i)
    i+=1
temp.sort()
for i in temp:
    if i>=n:
        print(m//i)
        break

Measured memory_bytes: 63696
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  string line;
  string s = "Hoshina";
  //cin.ignore();
  cin >> ws;
  while(getline(cin, line)){
    while(line.find("Hoshino")!=string::npos){
      line.replace(line.find("Hoshino"), s.size(), s);
    }
    cout<<line<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
package main

import (
        "fmt"
)

func sum(n int) int {
        return n * (n + 1) / 2
}

func solution(n int) int {
        return sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1756
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    AIN(ll, b, N);
    ll M = *max_element(ALL(a));
    vector<bool> available(M + 1, false);
    ll r = M;
    ll ans = 0;
    auto ok = [&]() {
        bool ok = true;
        REP(i, N)
        {
            if (a[i] < b[i])
            {
                return false;
            }
            vector<bool> dp(a[i] + 1);
            dp[b[i]] = true;
            for (ll j = b[i] + 1; j <= a[i]; ++j)
            {
                REP1(k, j)
                {
                    if (available[k] && dp[j % k])
                    {
                        dp[j] = true;
                    }
                }
            }
            ok &= dp[a[i]];
        }
        return ok;
    };
    while (r > 0 and not ok())
    {
        ll i;
        for (i = 1; i <= r; ++i)
        {
            available[i] = true;
            if (ok())
            {
                ans += 1LL << i;
                break;
            }
        }
        if (i > r)
        {
            OUT(-1);
            return 0;
        }
        r = i - 1;
        REP1(j, r)
        {
            available[j] = false;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 3612
let () =
  let a,b,c,d = Scanf.scanf "%d %d %d %d " (fun a b c d -> a,b,c,d) in
  print_endline (
    if (abs(c - a) <= d) then "Yes" else
    if (abs(c - b) <= d) && (abs(b - a) <= d) then "Yes" else "No"
  )


Measured memory_bytes: 384
a = int(input())
i = list(map(int, input().split()))

ans = 1
flag = 0

if i.count(0) > 0:
    print(0)
    flag = 1

if flag == 0:
    for x in range(len(i)):
        ans = ans * i[x]
        if ans > 1000000000000000000:
            flag = 1
            break

    if flag == 1:
        print(-1)
    elif flag == 2:
        print(0)
    else:
        print(ans)

Measured memory_bytes: 84732
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

# dp[i] = 石の残り数がiの時の勝敗
# i個の状態から遷移できる場所に負けが存在したら、それを相手に回すことが出来るため勝ち
# i個の状態から遷移できる場所に勝ちが存在したら、それを相手に回す必要はないので更新なし

dp = [False] * (K + 1)
for i in range(1, K + 1): # 石がi個の状態
  for j in range(len(A)): # それを相手に回す元が存在するかチェック
    if i - A[j] >= 0 and not dp[i -A[j]]:
      dp[i] = True

print(("Second","First")[dp[K]])  

Measured memory_bytes: 74328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N, L;
string str[1000];

int main() {
    cin >> N >> L;
    for (int i = 0; i < N; ++i) cin >> str[i];
    sort(str, str+N);
    string res = "";
    for (int i = 0; i < N; ++i) res += str[i];
    cout << res << endl;
}











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

int main()
{
    string s, t;
    cin >> s >> t;
    bool flag = true;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            flag = false;
            break;
        }
    }
    if (flag == true)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3568