akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
#define vecvec(a) vector<vector<(a)>>
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
struct edge{ll to,cost;};
ll N;const ll NMAX = 100005LL;
vector<edge> G[NMAX];
vector<ll> dist(NMAX,INF);
void dfs(ll from,ll par,ll d){
    dist[from] = d;
    for(auto x : G[from]){
        if(x.to != par){
            dfs(x.to,from,d + x.cost);
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    string T = S;
    reverse(all(T));
    if(T == S)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 6148
fun main() = Thread(null, ::abc174c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc174c() {
    val k = readLine()!!.toLong()

    if (k % 2 == 0L) return println(-1)

    var rem = 0L
    var answer = 0L

    repeat(k.toInt()) {
        rem = (rem * 10 + 7) % k
        rem %= k
        answer++
        if (rem == 0L) return println(answer)
    }

    println(-1)
}


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

//highlight color RGB = [70,70,70]
#define asll unsigned long long
#define ll long long
#define ld long double
#define imt int
#define pii pair<int,int>
#define st first
#define nd second
#define kj <<" "<<
#define kjb <<" ";
#define dg <<","<<
#define ml <<endl;
#define co cout<<
#define ter cout<<endl;
#define sibi cout<<"TES"<<endl;
#define tes(x) cout<<"TES "<<x<<endl;
#define psbk(x) push_back(x);
#define For(x,a,b) for(int x=(a);x<(b);x++)
#define FOR(x,n) for(int x=0;x<(n);x++)
#define kera(x,m) for( int i = 0;i < m ; i++ ){ cout<<"x["<< i <<"] =" kj x[i] ml}
#define kpr(x) cout<<"("<<x.st dg x.nd <<")" ml
#define kkor(p) cout<<"("<<p.x dg p.y <<")" ml
#define m_p make_pair
asll M=1e9+7;
int n,m,tc;
int p,q,r;
int juta=1000005;
int faktor[1000005];

void sieve(){
	FOR(i,juta){
		faktor[i]=0;
	}
	int temp;
	FOR(i,juta){
		if(i==0){
			continue;
		}
		temp=i;
		while(temp<juta){
			faktor[temp]++;
			temp+=i;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	int hasil=0;
	sieve();
	cin>>m;
	For(i,1,m){
		hasil+=faktor[i];
		
	}
	co hasil ml
}


Measured memory_bytes: 7540
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    for(int c = 0; c < q; c++){
        int k;
        cin >> k;
        ll a = 0, b = 0, r = 0, ans = 0;
        for(int i = 0; i < n; i++){
            if(i >= k){
                if(s[i - k] == 'D'){
                    a--;
                    r -= b;
                }
                if(s[i - k] == 'M') b--;
            }
            if(s[i] == 'D') a++;
            if(s[i] == 'M'){
                b++;
                r += a;
            }
            if(s[i] == 'C') ans += r;
        }
        cout << ans << endl;
    }
}

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

using namespace std;
using ll = long long;

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

int main() {
  ll n;
  cin >> n;
  ll a[5];
  rep(i, 5) cin >> a[i];

  ll mn = 1e15 + 1;
  rep(i, 5) mn = min(mn, a[i]);
  ll g = (n + mn - 1) / mn;
  cout << 5 + g - 1 << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 入力値の取得
		int K = sc.nextInt();
		
		// 結果の出力
		long sum = 0;
		for (int i = 1; i <= K; i++) {
			for (int j = 1; j <= K; j++) {
				int r = euclid(i, j);
				for (int k = 1; k <= K; k++) {
					sum += euclid(r, k);
				}
			}
		}
		System.out.println(sum);

		sc.close();
	}
	
	// ユークリッドの互除法で最大公約数を求める
	static int euclid( int a, int b ) {
		//引数の大小入替
		if (a < b) {
			int temp = a;
			a = b;
			b = temp;
		}
		
		int r = a % b;
		if (r == 0) {
			return b;
		}
		return euclid(b, r);
	}
}


Measured memory_bytes: 27244
import math

A, B, H, M = map(int, input().split())

r_h = H * 30 + M * 0.5
r_m = M * 6

r = abs(r_h-r_m)
s = math.cos(math.radians(r))

C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * s)

print(C)

Measured memory_bytes: 9492
N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))

A_right = max(X, max(x))
B_left = min(Y, min(y))

if A_right < B_left:
    ans = "No War"
else:
    ans = "War"
print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class Mod{
  public:
    ll mod;
    ll kaijou[200005];
    ll inv[200005];
    // mod must be a prime number
    Mod(ll m){
        mod = m;
        kaijou[0] = 1;
        for (ll i = 1;i <= 200003;i++){
            kaijou[i] = kaijou[i-1]*i%mod;
            inv[i] = modpow(kaijou[i],mod-2);
        }
    }
    //a^p
    ll modpow(ll a, ll p){
        if(p == 0) return 1;
        if(p%2 == 0){
            ll half = modpow(a, p/2);
            return half * half % mod;
        }
        else return a * modpow(a,p-1) % mod;
    }

    //nCr
    ll comb(ll n, ll r){
        if(r > n-r) return comb(n,n-r);
        ll mul = 1;
        ll div = 1;
        for (int i = 0;i < r;i++){
            mul *= n-i;
            mul %= mod;
            div *= i+1;
            div %= mod;
        }
        return mul * modpow(div,mod-2) % mod;
    }

    ll fcomb(ll n, ll r){
        if(r > n-r) return fcomb(n,n-r);
        if(r == 0) return 1;
        return (kaijou[n]*inv[n-r]%mod)*inv[r]%mod;
    }
};

ll dp[5000][5000];

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

    ll N; cin >> N;
    ll S; cin >> S;

    ll A[100005];

    Mod md(998244353);

    ll tmp = md.modpow(2,N);

    dp[0][0] = tmp;

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

    ll inv2 = md.modpow(2LL,md.mod-2);

    for (int i = 0;i < N;i++){
        for (int j = 0;j <= S;j++){
            if(dp[i][j] == 0) continue;
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= md.mod;
            if(j+A[i] > S) continue;
            dp[i+1][j+A[i]] += (dp[i][j]*inv2)%md.mod;
            dp[i+1][j+A[i]] %= md.mod;
        }
    }

    cout << dp[N][S] << endl;

    return 0;

}

Measured memory_bytes: 88988
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx          exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll a[300005],dp[300005], n,k;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll m,i,j,l,h,w,q,ans,x,y;
    	cin>>n>>k;
    	rep(i,0,n) cin>>a[i], dp[i]=1;
    	x=1;
		rep(i,1,n)
    	{
    		for(j=i-1;j>=0 && i-j<=100 ; j--)
    		{
    			if(abs(a[i]-a[j])<=k) dp[i]=max(dp[i],dp[j]+1);
			}
			x=max(x,dp[i]);
		}
    	cout<<x;
	}
	return 0;
}

Measured memory_bytes: 8360
import java.util.*;
import java.io.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String str = "";
		
		int alf[];
		char line;
		alf = new int[26];
		
				
		while(as.hasNext()){
			
			str = str + as.nextLine();
			
		}
		
		
		for(int i=0;i<str.length();i++){      //
            
            line = str.charAt(i);
   
        	if(line > '@' && line < '['){

    			alf[line-'A'] += 1;
        		
        	}
        	else if(line > '\u0060' & line < '{'){
        	
        		alf[line-'a'] += 1;
        		
        	}
            	
           
             
        }
		
		line = 'a';
		
		for(int i=0;i<26;i++){
		
			str = (line++) + " : " + alf[i];
			System.out.println(str);
			
		}
		
		
		

	}

}

Measured memory_bytes: 25916
while True:
    T, D, L = map(int, input().split())
    if T == D == L == 0:
        break
    X = [int(input()) for i in range(T)]
    S = [0 for i in range(T)]
    for i in range(T):
        if X[i] >= L:
            S[i] += 1
            if i + D < T:
                S[i+D] += -1
    s = 0
    ans = 0
    for i in range(T-1):
        s += S[i]
        if s >= 1:
            ans += 1
    print(ans)


Measured memory_bytes: 14800
using System;
using System.Linq;
using System.Collections.Generic;

namespace Atcoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int x = int.Parse(input[1]);
            string[] childs = Console.ReadLine().Split(' ');
            int[] childsInt = new int[childs.Length];
            for (int i = 0; i < childs.Length;i++){
                childsInt[i] = int.Parse(childs[i]);
            }
            Array.Sort(childsInt);
            int num=0;
            for (int i = 0; i < N;i++){
                if(childsInt[i]<=x){
                    num++;
                    x = x - childsInt[i];
                }else{
                    Console.WriteLine(num);
                    return;
                }
            }
            if (x != 0)
            {
                Console.WriteLine(num - 1);
            }else{
                Console.WriteLine(num);
            }
                   
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
   // vector<int>ans;
    int ans = 0;
    for(int i = 1; i <= 100000; i++){
        ans += 1;
        int p = floor(i*0.08);
        int q = floor(i*0.1);
        if(p == a && q == b){
            cout << i;
            break;
        }
    }
    if(ans == 100000) cout << -1;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main{

	static int ans = Integer.MAX_VALUE;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		ArrayList<Integer> data = new ArrayList<Integer>();
		data.add(1);
		for(int i = 1;i < 9;i++){
			data.add((int)(Math.pow(6, i)));
		}
		for(int i = 1;i < 9;i++){
			data.add((int)(Math.pow(9, i)));
		}
		Collections.sort(data);
//		for(int i = 0;i < data.size();i++){
//			System.out.println(data.get(i));
//		}
		int p = 0;
		while(n >= data.get(p)){
			p++;
		}
		p--;
//		System.out.println("p "+p+" data "+data.get(p));
		dfs(n,p,0,data);
		System.out.println(ans);
		
	}
	static void dfs(int n,int p,int count,ArrayList<Integer> data){
	//	System.out.println(n);
		if(n < 0 || count >= ans){
			return;
		}
		if(n == 0){
			ans = Math.min(ans, count);
			return;
		}
		for(int i = p;i >= 0;i--){
			if(n-data.get(i) >= 0){
			dfs(n-data.get(i), i, count+1, data);
			}
		}
		
		
		
		
	}

}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  c -= a-b;
  chmax(c,0);
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
struct mint {
    int x;
    mint(int x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

//modintCompare

mint F[2100010];
void fact(void) {
	F[0] = mint(1);
	F[1] = mint(1);
	for (int i = 2; i <= 2100000; i++) {
        mint x(i);
		F[i] = x * F[i - 1];
	}
}

mint square(mint x) {
    return x * x;
}

mint power(mint x, int y) {
    if (y == 0) return mint(1);
    else if (y == 1) return x;
    else if (y % 2 == 0) return square(power(x, y / 2));
    else return square(power(x, y / 2)) * x;
}

mint P(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	return F[n]/F[n - r];
}

mint C(int n, int r) {
	if (n < r || n < 0 || r < 0) return mint(0);
	mint ret;
	ret = F[n]/(F[n - r] * F[r]);
	return ret;
}
mint H(int n, int r) {
	if (n == 0 && r == 0) return mint(1);
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    fact();
    cin >> n >> m;
    if(abs(n - m) > 1) {
        cout << 0 << endl;
    } else if(abs(n - m) == 1) {
        cout << (F[n] * F[m]).x << endl;
    } else {
        cout << ((F[n] * F[m]) * mint(2)).x << endl;
    }

    return 0;
}


Measured memory_bytes: 16640
#include<stdio.h>
int main(void){
    int N,ans=0,rm=0;
    scanf("%d",&N);
    int A[N],B[N],C[N-1];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
    for(int i=0;i<N-1;i++){
        scanf("%d",&C[i]);
    }
    for(int i=0;i<N;i++){
        if(A[i]==A[i+1]-1){
            rm=A[i]-1;
            ans+=C[rm];
        }
        ans+=B[i];
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 128
S = input()
T = input()

def combocount(st):
    res = []
    count = 0
    tmp = {}
    for c in st:
        # tukatta koto ga aru
        if c in tmp:
            res.append(tmp[c])
        # hazimete
        else:
            tmp[c] = count
            res.append(count)
            count += 1
    return res


print('Yes' if combocount(S)==combocount(T) else 'No')


Measured memory_bytes: 6832
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int P = scan.nextInt();
			long[]A = new long[N];
			long[][]d = new long[N+1][2];
			long[][]s = new long[N+1][2];
			for(int i = 0;i<N;i++)A[i] = scan.nextInt();



			int ok = 0;
			for(int i = 0;i<N;i++) {

				if(A[i]%2==1)ok=1;


			}

			if(ok==0)
				if(P==0)
				System.out.println((long)Math.pow(2, N));
				else
					System.out.println(0);
			else {
				System.out.println((long)Math.pow(2, N-1));
			}






		}


	}


}


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

int main() {
  int N;
  int d[110];
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> d[i];

  int num[110] = {0};
  for (int i = 0; i < N; ++i) ++num[d[i]];

  int res = 0;
  for (int i = 1; i <= 100; ++i) {
    if (num[i]) ++res;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mkp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll H, W, D;
ll a[400][400];
ll Q;
ll l[MAX], r[MAX];
ll cost[MAX];

int main(void) {
    ll i, j;
    cin >> H >> W >> D;
    map<ll, P> mp;
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            cin >> a[i][j];
            mp[a[i][j]]=mkp(i, j);
        }
    }
    
    for(i=1; i<=D; i++) {
        for(j=i; j+D<=H*W; j+=D) {
            cost[j+D]=cost[j]+abs(mp[j].first-mp[j+D].first)+abs(mp[j].second-mp[j+D].second);
        }
    }
    
    
    cin >> Q;
    for(i=0; i<Q; i++) {
        cin >> l[i] >> r[i];
    }
    
    for(i=0; i<Q; i++) {
        pr(cost[r[i]]-cost[l[i]]);
    }
    
    
    
}




















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

using namespace std;

const int N = 18 + 1;

typedef pair<string, string> pss;

map<pss, int> mp;
string s, t;
long long ans, n;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	for (int mask = 0; mask < (1 << n); mask++) {
		string a, b;
		a = b = "";
		for (int i = 2 * n - 1; i >= n; i--) {
			if (mask >> (i - n) & 1)
				a += s[i];
			else
				b += s[i];
		}
		mp[{a, b}]++;
	}
	for (int mask = 0; mask < (1 << n); mask++) {
		string a, b;
		a = b = "";
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1)
				a += s[i];
			else
				b += s[i];
		}
		ans += mp[{a, b}];
	}
	return cout << ans, 0;
}

Measured memory_bytes: 91904
n, k = map(int, input().split())
s = input()
x = 0
y = 0
unhappy = 0
for i in range(n):
    if s[i-1:i+1] == "LR":
            x += 1
    elif s[i-1:i+1] == "RL":
            y += 1
unhappy = x + y
if k > min(x,y):
    unhappy = 0
else:
    unhappy -= 2 * k
print(n - 1 - unhappy)


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

ll dp[51][51][2510];

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

  int X = 0;
  for ( int i = 0; i < N; i++ ) {
    X = max(X,x[i]);
  }
  dp[0][0][0] = 1;
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) {
      for ( int k = 0; k <= N*X; k++ ) {
	dp[i+1][j][k] += dp[i][j][k];
	dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  for ( int t = 1; t <= N; t++ ) {
    ans += dp[N][t][t*A];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 50304
n, m = map(int, input().split())
b1 = [1] * n
b2 = [0] * n
b2[0] = 1
for i in range(m):
	x, y = map(int, input().split())
	if (1 <= b1[x-1]):
		b1[x-1] -= 1;
		b1[y-1] += 1;
		if 1 <= b2[x-1]:
			b2[y-1] = 1
		if 0 == b1[x-1]:
			b2[x-1] = 0
print(sum(b2))

Measured memory_bytes: 4596
from functools import lru_cache
from math import gcd

cgcd = lru_cache(maxsize=None)(gcd)

k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        d = cgcd(a, b)
        if d == 1:
            ans += k
            continue
        for c in range(1, k + 1):
            ans += cgcd(d, c)
print(ans)


Measured memory_bytes: 13376
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
	x = 0;
	T f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
inline void d_read(double &x) {
	x = 0.0;
	int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
	if (c == '.'){
		double num = 1.0;
		c = getchar();
		for (; isdigit(c); c = getchar()) x = x + (num /= 10) * (c ^ 48);
	}
	x *= f;
}

template <typename T>
inline void w(T x) {
	if (x > 9) w(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
	if (x < 0){
		putchar('-');
		x = -x;
	}
	w(x);
	putchar(c);
}
long long a[100005];
int main(){
	int n;
	read(n);
	long long s = 0;
	for(int i = 1; i <= n; i ++) {
		long long x;
		read(x);
		a[x] ++;
		s += x;
	}
	int m;
	read(m);
	for (int i = 1; i <= m; i ++) {
		long long x, y;
		read(x); read(y);
		s -= a[x] * x;
		s += a[x] * y;
		a[y] += a[x];
		a[x] = 0;
		write(s, '\n');
	}
	return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  vector<string> A(N);
  set<string> S;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
    S.insert(A.at(i));
  }
  cout << S.size() << endl;
}


Measured memory_bytes: 25020
N= int(input())
num_list = []
max_num = 0
chk = 0
for i in range(N):
	k = int(input())
	max_num=max(k,max_num)
	num_list.append(k)
for i in range(N):
	if num_list[i] == max_num:
		chk += 1
if chk != 1:
	for i in range(N):
		print(max_num)
else:
	for i in range(N):
		if num_list[i] != max_num:
			print(max_num)
		else:
			chk_list = num_list[0:i] + num_list[i+1:N]
			chk_list.sort()
			print(chk_list[N-2])

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

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

	vector<int> v;
	for (int i = 1; i <= max(a, b); i++) {
		if (a % i == 0 && b % i == 0) v.push_back(i);
	}

	cout << v[v.size() - k] << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

c = [-1, -1 ,-1]

sum = 1
tmp = 0
for i in range(N):
    sum = sum * c.count(A[i]-1) % 1000000007
    if (A[i]-1) == c[0]:
        c[0] += 1
        tmp = c.count(c[0] - 1) + 1
    elif (A[i]-1) == c[1]:
        c[1] += 1
        tmp = c.count(c[1]-1) + 1
    elif (A[i]-1) == c[2]:
        c[2] += 1
        tmp = c.count(c[2] - 1) + 1
print(sum)


Measured memory_bytes: 14396
#include <iostream>
using namespace std;
int main (){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout  << x2 + y1 - y2 << " " << x2 - x1 + y2 << " " << x1 - y2 + y1 << " " << x2 - x1 + y1;
}

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

int n,m;
int dd,i,j;
char str[1000],com[1000],res[1000];
char str2[1001],str3[1001],str4[1001];
int main(void){
	scanf("%d%*c",&n);
	for(dd=0;dd<n;dd++){
		memset(str,'\0',sizeof(str));
		fgets(str,999,stdin);
		scanf("%d%*c",&m);
		int len=strlen(str)-1;
		int point=0;
		for(i=0;i<m;i++){
			memset(com,'\0',sizeof(com));
			fgets(com,999,stdin);
			int comlen=strlen(com)-1;
			if(com[0]=='f' && com[8]=='c'){
				if(point<len){
					point++;
				}
			}
			if(com[0]=='f' && com[8]=='w'){
				if(point<len){
					while(point<len && str[point]==' ')point++;
					while(point<len && str[point]!=' ')point++;
				}
			}
			if(com[0]=='b' && com[9]=='c'){
				if(point>0){
					point--;
				}
			}
			if(com[0]=='b' && com[9]=='w'){
				if(point>0){
					while(point>0 && str[point-1]==' ')point--;
					while(point>0 && str[point-1]!=' ')point--;
				}
			}
			if(com[0]=='i'){
				memset(str2,'\0',sizeof(str2));
				memset(str3,'\0',sizeof(str3));
				memset(str4,'\0',sizeof(str4));
				for(j=0;j<point;j++){
					str2[j]=str[j];
				}
				for(j=point;j<len;j++){
					str3[j-point]=str[j];
				}
				for(j=8;j<comlen-1;j++){
					str4[j-8]=com[j];
				}
				memset(str,'\0',sizeof(str));
				for(j=0;j<point;j++){
					str[j]=str2[j];
				}
				for(j=0;j<comlen-9;j++){
					str[j+point]=str4[j];
				}
				for(j=0;j<len-point;j++){
					str[j+point+comlen-9]=str3[j];
				}
				len=len+comlen-9;
				point+=comlen-9;
			}
			if(com[0]=='d' && com[7]=='c'){
				if(len==point)continue;
				memset(str2,'\0',sizeof(str2));
				memset(str3,'\0',sizeof(str3));
				for(j=0;j<point;j++){
					str2[j]=str[j];
				}
				for(j=point+1;j<len;j++){
					str3[j]=str[j];
				}
				memset(str,'\0',sizeof(str));
				for(j=0;j<point;j++){
					str[j]=str2[j];
				}
				for(j=point+1;j<len;j++){
					str[j-1]=str3[j];
				}
				len--;
			}
			if(com[0]=='d' && com[7]=='w'){
				if(len==point)continue;
				int e=1;
				if(str[point]==' '){
					while(point+e<len && str[point+e]==' ')e++;
				}
				int flag2=0;
				while(point+e<len && str[point+e]!=' '){
					e++;
					flag2=1;
				}
				if(flag2==0)continue;
				memset(str2,'\0',sizeof(str2));
				memset(str3,'\0',sizeof(str3));
				for(j=0;j<point;j++){
					str2[j]=str[j];
				}
				for(j=point+e;j<len;j++){
					str3[j-point-e]=str[j];
				}
				memset(str,'\0',sizeof(str));
				for(j=0;j<point;j++){
					str[j]=str2[j];
				}
				for(j=point+e;j<len;j++){
					str[j-e]=str3[j-point-e];
				}
				len=len-e;
			}
		}
		int reslen=0;
		memset(res,'\0',sizeof(res));
		for(i=0;i<len;i++){
			if(i==point)res[reslen++]='^';
			res[reslen++]=str[i];
		}
		if(len==point)res[reslen++]='^';
		printf("%s\n",res);
	}
	return 0;
}

Measured memory_bytes: 592
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(){
    val(h1, m1, h2, m2, k) = readInts()
    var time = 0

    if(m1 > m2){
        time = (h2 - h1 -1) * 60 + (60 - (m1 - m2))
    }
    else{
        time = (h2 - h1) * 60 + (m2 - m1)
    }

    println(time - k)
}

Measured memory_bytes: 36336
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

string S;
string s;

void solve() {
    cin >> S;
    int Q;
    cin >> Q;
    int hanten = 0;
    while (Q--) {
        int T;
        cin >> T;
        if (T == 1) {
            hanten++;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if ((f + hanten) % 2 == 0) {
                S.pb(c);
            } else {
                s.pb(c);
            }
        }
    }
    if (hanten % 2 == 1) {

        for (int i = S.size() - 1; i >= 0; i--) {
            cout << S[i];
        }

        cout << s << endl;

    } else {
        for (int i = s.size() - 1; i >= 0; i--) {
            cout << s[i];
        }
        cout << S << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 980
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def solve(gen):
    l = gen.get_input().rstrip()
    x = int(l)
    if x >= 30:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    test_flag = len(sys.argv) > 1

    if test_flag == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        solve(gen)


Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N; cin >> N;
    ld sum = 0.0;
    rep(i,N) {
        ld x;
        string u;
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else sum += 380000 * x;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll elem[1050];
int main()
{
    ll a,b,sum=0;
    cin>>a>>b;
    for(ll i=0;i<a;i++)
    {
       cin>>elem[i];
    }
    sort(elem,elem+a);
    for(ll i=0;i<b;i++)
    {
        sum+=elem[i];
    }
    cout<<sum;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <math.h>

int sample;
std::vector<int> weight;
std::vector<int> answer;

void dfs(int i, std::vector<int> choice){
	int sum = 0;
	for(unsigned int j=0; j<choice.size(); j++){
		sum += choice[j];
	}
	if(sum==sample) { answer = choice; }
	if(i>9 || sum > sample) return;

	dfs(i+1, choice);
	choice.insert(choice.end(), weight[i]);
	dfs(i+1, choice);
}

int main(void){
	int i;
	for(i=0;i<10;i++){
		weight.insert(weight.end(), (int)pow(2.0, i));
	}
	while( (std::cin >> sample)!=NULL ){
		answer.clear();
		dfs(0,answer);
		for(unsigned int i=0; i<answer.size(); i++){
			std::cout << answer[i];
			if(i==answer.size()-1) { break; }
			else { std::cout << " "; }
		}
		std::cout << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3316
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-06-01 17:27:34
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

#if __cplusplus >= 201703L
template <class Ch, class Tr, class Tuple, std::size_t... Is>
void tuple_out(std::basic_ostream<Ch, Tr>& os, const Tuple& tp, std::index_sequence<Is...>) {
  ((os << (Is ? ", " : "(") << std::get<Is>(tp)), ...) << ")";
}

template <class Ch, class Tr, class... Args>
auto& operator<<(std::basic_ostream<Ch, Tr>& os, const std::tuple<Args...>& tp) {
  tuple_out(os, tp, std::index_sequence_for<Args...>{});
  return os;
}
#endif

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class Compare>
std::ostream& operator<<(std::ostream& os, const std::set<T, Compare>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U, class Compare>
std::ostream& operator<<(std::ostream& os, const std::map<T, U, Compare>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int64 a; cin >> a;
  double b; cin >> b;
  b *= 100;
  b += 0.0001;
  int c = static_cast<int>(b);
  cout << a * c / 100 << endl;

  return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>
#define YOSHI 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[YOSHI];
int n;

void preParse(int u){
    if(u == NIL) return;
    
    printf(" %d",u);
    
    preParse(T[u].l);
    
    preParse(T[u].r);
}


void inParse(int u){
    if(u == NIL) return;
    
    inParse(T[u].l);
    
    printf(" %d",u);
    
    inParse(T[u].r);
}


void postParse(int u){
    if(u == NIL) return;
    
    postParse(T[u].l);
    
    postParse(T[u].r);
    
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;
    
    scanf("%d",&n);
    
    for(i = 0;i < n;i++){
        T[i].p = NIL;
    }
    
    for(i = 0;i < n;i++){
        scanf("%d %d %d",&v,&l,&r);
        
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }
    
    for(i = 0;i < n;i++){
        if(T[i].p == NIL) root = i;
    }
    
    printf("Preorder\n");
    
    preParse(root);
    
    printf("\n");
    
    printf("Inorder\n");
    
    inParse(root);
    
    printf("\n");
    
    printf("Postorder\n");
    
    postParse(root);
    
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2108
import sys
input = sys.stdin.readline

import bisect
from itertools import accumulate

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()

left = -1
right = 10 ** 6

def shake(x):
    cnt = 0
    for i in A:
        cnt += N - bisect.bisect_left(A, x - i)
    if cnt >= M:
        return 1
    else:
        return 0

while True:
    mid = (left + right) // 2
    if shake(mid):
        if not shake(mid + 1):
            X = mid
            break
        else:
            left = mid
    else:
        if shake(mid - 1):
            X = mid - 1
            break
        else:
            right = mid

happy = 0
cumsum_A = list(accumulate(A))

for j in A:
    idx = bisect.bisect_right(A, X - j)
    cnt = N - idx
    if cnt == N:
        happy += cumsum_A[-1] + cnt * j
    else:
        happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j
    M -= cnt

happy += M * X

print(happy)


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


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    u=[]#min(A)とmin(B)を使おうね
    for i in range(M):
        u.append(a[x[i]-1]+b[y[i]-1]-c[i])
    o=min(u)
    if min(a)+min(b)<o:
        print(min(a)+min(b))
    else:
        print(o)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


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

typedef long long ll; 
const ll mod = 1000000007; 
ll my_pow(ll ds,ll cf) { 
   ll sum=1; 
   while(cf>0) 
    { 
       if(cf%2==1) 
           sum=(sum*ds)%mod; 
       ds=(ds*ds)%mod; 
       cf/=2; 
    } 
   return sum; 
} 
ll inv(ll x) { 
   return my_pow(x,mod-2); 
} 


int main()
{
	ll n,k,a[2005];
	cin >> n >> k;
	for(int i = 1;i <= n;i++) scanf("%lld",&a[i]);
	
	k %= mod;
	ll k1 = ((k*(k+1)) % mod) * inv(2) %mod;
	ll k2 = ((k*(k-1)) % mod) * inv(2) %mod;
	
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		ll sum = 0;
		for(int j = i + 1;j <= n;j++){
			if(a[i] > a[j]) sum++;
		}
		sum %= mod;
		ans = (ans + (sum * k1) % mod) % mod;
		
		sum = 0;
		for(int j = i - 1;j >= 1;j--){
			if(a[i] > a[j]) sum++;
		}
		sum %= mod;
		ans = (ans + (sum * k2) % mod) % mod;
	}
	
	cout << ans << endl;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	int a, b; cin >> a >> b;
	int x = a*pow(10, 1+floor(log10(b)))+b;
	int y = sqrt(x);
	debug(x);
	debug(y);
	cout << (y*y==x?"Yes":"No");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main() {
	string a;
	cin >> a;
	sort(a.begin(),a.end());
	if ((a[0]==a[1])&&(a[2]==a[3])&&(a[1]!=a[2])){
		cout << "Yes";
		return 0;
	}
	cout << "No";
}	


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string s;
    cin >> s;
    string p = "2019/04/30";
    if (s > p)cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int a[3];
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    
    int b = a[2]-a[1]+a[2]-a[0];
    if(b % 2 == 1) b += 3;
    
    cout << b/2 << endl;
}

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

int main(){
    class matrix{
        public:
        int x;
        int y;
    };

    matrix p[90001];
    int H,W,D,tmp;
    cin>>H>>W>>D;

    //O(HW)=O(10^5)
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>tmp;
            p[tmp].x=i;
            p[tmp].y=j;
        }
    }
    
    //O(HW)=O(10^5)
    int d[90001]={0};
    for(int i=D+1;i<=H*W;i++){
        d[i]=d[i-D]+abs(p[i].x-p[i-D].x)+abs(p[i].y-p[i-D].y);
    }

    int Q;
    cin>>Q;

    //O(Q)=O(10^5)
    for(int i=0;i<Q;i++){
        int L,R;
        cin>>L>>R;
        cout<<d[R]-d[L]<<endl;
    }

    return 0;
}

Measured memory_bytes: 2176
N=int(input())
a=list(map(int,input().split()))
#print(a)
counter=1
bk=0
for i in range(N):
  if a[i]==counter:
    counter+=1
  else:
    bk+=1
#  print (a[i],bk)
#print(counter-1,bk)
ans=bk
if counter-1==0:
  ans=-1
print(ans)

Measured memory_bytes: 26268
#include <cstdio>
#include <cstdlib>
#include <algorithm>

const int N = 100 + 10, MOD = 1000000007;

int n, a[N];
int f[N][N][N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n - 1; ++i) scanf("%d", &a[i]);
  std::sort(a + 1, a + 2 * n);
  f[0][1][0] = 1;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < 2 * n; ++j) {
      for (int k = 0; k < j; ++k) {
        int cur = f[i][j][k];
        if (!cur) continue;
        if (i == n - 1) {
          (ans += cur) %= MOD;
          continue;
        }
        int x = j, y = k;
        if (a[n - i - 1] != a[n - i]) ++x, ++y;
        if (a[n + i + 1] != a[n + i]) ++x;
        for (int p = 0; p < x; ++p) (f[i + 1][x - std::max(abs(p - y) - 1, 0)][p <= y ? p : (y + 1)] += cur) %= MOD;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
int a[505][505];
int main(){
	int k;
	read(k);
	int n=(k+1)/2;
	if(k==1)return puts("1\n1"),0;
	if(n&1)++n;
	printf("%d\n",n);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(i&1)a[i][j]=(i+j)%n+1;else a[i][j]=(i+j)%n+1+n;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(a[i][j]<=k)printf("%d ",a[i][j]);
			else printf("%d ",a[i][j]-n);
		}putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2176
N, H = map(int, input().split())

A = []
B = []
Amax = 0
for _ in range(N):
    a, b = map(int, input().split())
    Amax = max(a, Amax)
    B.append(b)

B.sort(reverse=True)

res = 0
for b in B:
    if b > Amax:
        res += 1
        if H <= b:
            print(res)
            exit()
        H -= b
    else:
        break

print(res + (H // Amax + int(H % Amax != 0)))

Measured memory_bytes: 13320