akhauriyash/Code-Regression huggingface dataset:
fun main(arr:Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    if(isSame(s,t)) {
        println("Yes")
    } else {
        println("No")
    }
}

fun isSame(s:String, t:String):Boolean {
    val map1 = getMap(s)
    val map2 = getMap(t)
    for(key in map1.keys) {
        if(!map2.containsKey(key)) {
            return false
        }
        val list1 = map1[key]!!
        val list2 = map2[key]!!
        if(list1.size != list2.size) {
            return false
        }
        for(idx in list1.indices) {
            if(list1[idx] != list2[idx]) {
                return false
            }
        }
    }
    return true
}

fun getMap(s:String):MutableMap<Int,MutableList<Int>> {
    val charMap = mutableMapOf<Char,Int>()
    val ret = mutableMapOf<Int, MutableList<Int>>()
    for(i in s.indices) {
        if(!charMap.containsKey(s[i])) {
            charMap[s[i]] = i
            ret[i] = mutableListOf()
        }
        val idx = charMap[s[i]]!!
        ret[idx]!!.add(i)
    }
    return ret
}

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

int main() {
  int n, l;
  cin >> n >> l;
  
  int a = n * (2 * l + n - 1) / 2;
  
  if(l > 0)
    cout << a - l << endl;
  else if(l + n - 1 < 0) 
    cout << a - (l + n - 1) << endl;
  else
    cout << a << endl;
}

Measured memory_bytes: 256
import sys
l,r = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>

using namespace std;

#define f(i, n) for( int i = 1; i <= n; i++ )


const int N = 10005;
long long v[N], dp[N][N];
int n;


int main()
{
  long long sum = 0;
  int i = 1, val = 3;


  cin >> n;
  f(i, n){
      cin >> v[i];
      sum += v[i];
  }

  f(i, n)
    f(j, n)
      if(i == j)
        dp[i][j] = v[i];
      else if(j == i + 1 )
        dp[i][j] = max(v[i], v[j]);

  while(i <= n - 2)  {
      int j = val;
      int x = 1;
      while(j <= n){
          dp[x][j] = max( v[x] + min( dp[x + 2][j], dp[x + 1][j - 1]), v[j] + min( dp[x + 1][j - 1], dp[x][j - 2]));
          j++;
          x++;
      }
      val ++;
      i ++;
  }


  cout << dp[1][n] - (sum - dp[1][n]);
  return 0;
}


Measured memory_bytes: 234496
#include <stdio.h>

int N;
char S[300][301];

int main(void) {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%s", S[i]);
    // printf("%s\n", S[i]);
  }

  int ans = 0;
  for (int k = 0; k < N; ++k) {
    int ok = 1;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        ok &= S[(i+k)%N][j] == S[(j+k)%N][i];
      }
      if (!ok)
        break;
    }
    if (ok)
      ++ans;
  }
  ans *= N;
  printf("%d\n", ans);
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int H, W, A, B;

int main() {
    cin >> H >> W >> A >> B;

    vvi s(H, vi(W, 0));
    vi checkA1(H, 0), checkB1(W, 0);
    vi checkA0(H, 0), checkB0(W, 0);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (checkA1[i] < W-A && checkB1[j] < H-B) {
                checkA1[i]++;
                checkB1[j]++;
                s[i][j] = 1;
            } else if (checkA0[i] < W-A && checkB0[j] < H-B) {
                checkA0[i]++;
                checkB0[j]++;
                s[i][j] = 0;
            } else {
                cout << "No"<< endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  ll n,d; cin>>n>>d;
  ll ans{};
  for(int i=0; i<n; i++){
    ll x,y; cin>>x>>y;
    if(x*x+y*y<=d*d)ans++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int M, D;
    cin >> M >> D;
    int ans = 0;
    for(int i = 1; i <= M; i++){
        for(int j = 1; j <= D; j++){
            int d1 = j % 10;
            int d10 = j / 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
   int n; cin >> n;
   string w; cin >> w;
   map<string,int> check;
   check[w]++;
   rep(i,n-1){
       string s; cin >> s;
       if(w[w.length()-1]!=s[0] || check[s]!=0){
           cout << "No" << endl;
           return 0;
       }
       w=s;
       check[s]++;
   }
   cout << "Yes" << endl;
return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int64_t gcd(int64_t a, int64_t b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

int64_t num_prime_factor(int64_t x){
    map<int64_t, int> prime_factor;
    prime_factor[1]++;
    bool flag = true;
    
    while(flag){
        int64_t up_bnd = int64_t(sqrt(x));
        bool flag2 = false;
        for (int a = 2; a <= up_bnd; a++) {
            if (x % a == 0) {
                flag2 = true;
                while (x % a == 0) {
                    x /= a;
                    prime_factor[a]++;
                }
                break;
            }
        }
        if (!flag2) {
            prime_factor[x]++;
            flag = false;
        }
    }
    return prime_factor.size();
}

int main(int argc, const char * argv[]) {

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

    int64_t a, b; cin >> a >> b;
    cout << num_prime_factor(gcd(a, b)) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        for (int i=0;i<10;i++){
            System.out.println(r*x-d);
            x=r*x-d;
        }
    }
}


Measured memory_bytes: 35712
#include <iostream>
#include <algorithm>
using namespace std;
int a[100];
int bubbleSort(int N){
	int cnt = 0;
	bool flag = true;
	while (flag){
		flag = false;
		for (int i = N - 1; i >= 1; --i){
			if (a[i] < a[i - 1]) swap(a[i], a[i - 1]), flag=true, ++cnt;
		}
	}
	return cnt;
}
int main(){
	int n; cin >> n; 
	for (int i = 0; i < n; ++i) cin >> a[i];
	int cnt=bubbleSort(n);
	for (int i = 0; i < n; ++i){
		if (i != 0) cout << ' ';
		cout << a[i];
	}
	cout << '\n' << cnt << '\n';
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
        d[i] += x;
    }
    }
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    T sum(int l, int r) {
        return sum(r) - sum(l-1);
    }
};

int main() {
    // Binary Indexed Tree
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    // 一個前の同じ玉の色の箇所へ矢印を書く、ない時は-1
    vector<int> lastSameCol(N+1, -1);
    vector<vector<int>> arrow(N);
    rep(i, N) {
        int prev = lastSameCol[A[i]];
        if (prev != -1) arrow[prev].push_back(i);
        lastSameCol[A[i]] = i;
    }
    vector<vector<P>> queries(N);
    rep(qi, Q) {
        int l, r;
        cin >> l >> r;
        --l; --r;
        queries[l].emplace_back(r, qi);        
    }
    vector<int> ans(Q);
    BIT<int> bit(N);
    for (int i = N-1; i >= 0; i--) {
        for (int x : arrow[i]) {
            bit.add(x, 1);
        }
        for (auto p : queries[i]) {
            int right = p.first, qi = p.second;
            ans[qi] = right - i + 1 - bit.sum(i, right);
        }
    }
    rep(i, Q) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 59924
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;

bool solve(int N, vector<int> a){
  
  sort(ALL(a));

  int d = a.back();
  int r = (d+1)/2;

  if(a[0] < r) return false;

  if(d % 2 == 1){
    if(count(ALL(a),r) != 2) return false;
    FORE(i,r+1,d){
      if(count(ALL(a),i) < 2) return false;
    }
  }else{
    if(count(ALL(a),r) != 1) return false;
    FORE(i,r+1,d){
      if(count(ALL(a),i) < 2) return false;
    }
  }
  return true;
}



int main(){
  int N;
  while(cin >> N){
    vector<int> a(N); cin >> a;

    bool ans = solve(N,a);
    
    cout << (ans ? "Possible" : "Impossible") << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
    
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e19;

ll h[100001];
ll N, A, B, C;

bool check(ll k){
    ll cnt = 0;
    REP(i, N){
        ll tmp = h[i] - B * k;
        if(tmp > 0){
            cnt += ceil((double)tmp/(double)C);
        }
    }
//    cout << k << "," <<cnt << endl;
    return cnt<=k;
}

int main() {  
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> A >> B;
    C = A - B;
    ll hmax=0;
    REP(i, N){
        cin >> h[i];
        hmax = max(h[i], hmax);
    }
    
    ll l, r, m;
    l = 0;
    r = 2*ceil(hmax/B)+1;
    ll mink = LINF;
    while(1){
        m = (l + r)/2;
        if(l == m){
            break;
        }
        bool bal = check(m);
        if(bal){
//            cout << l << "," << r << "," << m << ":" << bal << endl;
            mink = min(mink, m);
            r = m;
        }else{
            l = m;
        }
        
    }
    cout << mink << endl;
    return 0;    
}


Measured memory_bytes: 1024
def d_lunlun_number():
    from collections import deque
    K = int(input())

    queue = deque(range(1, 10))
    ans = -1
    for _ in range(K):
        ans = queue.popleft()
        lsd = ans % 10  # least significant digit
        if lsd != 0:
            queue.append(10 * ans + (lsd - 1))
        queue.append(10 * ans + lsd)
        if ans % 10 != 9:
            queue.append(10 * ans + (lsd + 1))
    return ans

print(d_lunlun_number())

Measured memory_bytes: 12404
n=int(input())
s=[""]*n
for i in range(n):
  s[i]=input()

ans=0
lis={}
for word in s:
  arr=[]
  for let in word:
    arr.append(let)
  arr.sort()
  new=''
  for let in arr:
     new += let
  if new in lis:
    lis[new] += 1
    ans += lis[new]
  else: 
    lis[new] = 0
print(ans)

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

#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;


void solve(){
	int n, m= 0, s=0;
	cin>>n;
	rep(i,0,n){
		int tem;
		cin>>tem;
		m = max(m, tem);
		s+=tem;
	}
	if(m>=(s-m))
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
 //    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define MOD 1000000007

int main() {
	char s;
	cin >> s;
	if (s == 'A') {
		cout << 'T';
	}
	else if (s == 'T') {
		cout << 'A';
	}
	else if (s == 'C') {
		cout << 'G';
	}
	else {
		cout << 'C';
	}

	return 0;
}


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

#define pb push_back
#define INF INT_MAX

void solution1(int n, vector<int>& heights);
void solution2(int n, vector<int>& heights);
void solution3(int n, vector<int>& heights);

int main(void){

	// taking input
	int n ;
	cin >> n;
	vector<int> heights(n);
	for(int i = 0;i < n;i++)
		cin >> heights[i];

	// sending inputs to functions
	// 
	// solution1(n, heights);
	//
	solution2(n, heights);
}


// iterative
void solution1(int n, vector<int>& heights){

	std::vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(heights[1]-heights[0]);
	for(int i =2;i < n;i++){
		dp[i] = min(dp[i-1] + abs(heights[i]-heights[i-1]), dp[i-2] + abs(heights[i]-heights[i-2]));
	}
	cout << dp[n-1] << endl;
	return;
}

int helper(int n, std::vector<int>& heights, int x, std::vector<int>& dp){
	if(dp[x] != -1)
		return dp[x];
	if(x == 0){
		dp[x] = 0;
		return dp[x];
	}
	if(x == 1){
		dp[x] = abs(heights[1] - heights[0]);
		return dp[x];
	}
	dp[x] = min(helper(n, heights, x-1, dp)+abs(heights[x]-heights[x-1]), helper(n, heights, x-2, dp)+abs(heights[x]-heights[x-2]));
	return dp[x];
}

// recursive
void solution2(int n, vector<int>& heights){
	std::vector<int> dp(n, -1);
	int ans = helper(n, heights, n-1, dp);
	cout << ans << endl;
	return;
}



void solution3(int n, vector<int>& heights){

}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >>n >>k;
	VI a(n);
	rep(i, n){cin >>a[i]; a[i]--;}
	int now = 0;
	for(; k; k>>=1){
		VI nxt(n);
		if(k & 1) now = a[now];
		rep(i, n) nxt[i] = a[a[i]];
		swap(a, nxt);
	}
	cout << now +1 <<"\n";
	return 0;
	
}


Measured memory_bytes: 4796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC140B();
        }

        static void AC140B()
        {
            //https://atcoder.jp/contests/abc140/tasks
            
            var n = int.Parse(Console.ReadLine()); //料理の種類
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray(); //料理を食べた順番
            var b = Console.ReadLine().Split().Select(int.Parse).Sum(); //n番目の料理を食べたときに得られる満足度 の合計
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray(); //追加満足度

            int additionalPoint = 0;

            //aの配列で連番になっているものを探す
            for (int i = 0; i < n -1 ; i++ )
            {
                //cから連番のインデックスに該当する満足度を探す
                if(a[i] + 1 == a[i +1])
                {
                    additionalPoint += c[a[i] - 1];
                }
            }
            Console.WriteLine(b + additionalPoint);
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<long> A(n);
    priority_queue<long> q;
    rep(i, 0, n)
    {
        cin >> A[i];
        q.push(A[i]);
    }
    rep(i, 0, m)
    {
        long a = q.top();
        q.pop();
        q.push(a / 2);
    }
    long ans = 0;
    rep(i, 0, n)
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
import math
N,H = list(map(int,input().split()))
data=[]
for i in range(N):
    a,b = list(map(int,input().split()))
    data.append([a,b])

s1 = sorted(data,key = lambda x:-x[1])
s2 = sorted(data,key = lambda x:-x[0])
cnt = 0


for i in range(N):
    if H > 0:
        if s1[i][1] > s2[0][0]:
            H -= s1[i][1]
            cnt += 1
        else:
            break
    else:
        print(cnt)
        exit()
    


if H > 0:
    print(cnt + math.ceil(H/s2[0][0]))
else:
    print(cnt)
        
        

Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
const int maxn = 1e5 + 90;
map <int, int> m;
bool mark[maxn];
int val[maxn];
int ans;
int cor = 0;
int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int n;
    cin >> n >> n;
    for(int i = 0; i < n; i++){
        int a;
        string s;
        cin >> a >> s;
        if(s == "AC" and mark[a] == false)
            ans += val[a], mark[a] = true, cor++;
        val[a]++;
    }
    cout << cor << ' ' <<ans;


}



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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int res = 1e9;

  for (int i = 0; i + m <= n; i++) {
    int tmp = 0;
    for (int j = 0; j < m; j++) {
      if (s[i + j] != t[j]) tmp++;
    }
    res = min(res, tmp);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3624
fun main(args: Array<String>) {
    var X = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var max = X.max()!!
    var tmp = (max*3 - X.sum())
    if(tmp%2 == 0) println(tmp/2)
    else println(((max+1)*3 - X.sum())/2)
}

Measured memory_bytes: 35980
// Aizu Vol-10 1069: Squid Multiplication
// 2017.8.18 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 32000
unsigned long long odd[MAX+5], even[MAX+5];
int ol, el;

unsigned long long gcd(unsigned long long a, unsigned long long b)
{
	unsigned long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

unsigned long long ays_sqrt(unsigned long long a)
{
	unsigned long long x = 0;
	unsigned long long d = 0x80000000ULL;
	if (a >= 0x7fffffffULL * 0x7fffffffULL) return 0x7fffffffULL;
	do {
		if (a >= x * x) x += d; else x -= d;
		d >>= 1;
	} while (d);
	if (a > x * x) x++;
	if (a < x * x) x--;
	return x;
}


int cmp(unsigned long long *a, unsigned long long *b) {
	if (*a < *b) return -1;
	if (*a == *b) return 0;
	return 1;
}

int main()
{
	int n, k, i;
	unsigned long long g, e1, e2, o1;

	while (scanf("%d", &n) && n) {
		k = n*(n + 1) / 2;
		for (ol = el = 0, i = 0; i < k; i++) {
			scanf("%llu", &g);
			if (g & 1) odd[ol++] = g;
			else       even[el++] = g;
		}
		qsort(odd, ol, sizeof(unsigned long long), cmp);
		qsort(even, el, sizeof(unsigned long long), cmp);
		e1 = even[0], e2 = even[1], o1 = odd[0];
		g = gcd(e1, o1), e1 /= g, o1 /= g;
		g = gcd(e2, o1), e2 /= g, o1 /= g;
		g = ays_sqrt(e1 * e2);
		printf("%llu\n%llu", g, even[0]/g);
		for (i = 1; i < n; i++) printf(" %llu", even[i]/g);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1180
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int H = scan.nextInt();
		int M = scan.nextInt();
		scan.close();
		System.out.printf("%4.10f", Math.sqrt(A*A + B*B - 2 *A*B*Math.cos((H*30 - M*5.5) * Math.PI / 180)));
	}
}



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



int main(){
    int x,t;
    cin >> x >> t;
    if(x-t>0) cout << x-t << endl;
    else cout << 0 << endl;
   return 0;
}

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

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

template<int mod> struct Combination {
    vector<ModInt<mod>> fact, ifact;
    Combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * i);
        ifact[n] = fact[n].inverse();
        for (int i = n; i > 0; i--) ifact[i - 1] = ifact[i] * i;
    }
    ModInt<mod> operator() (int n, int r) {
        if (r < 0 or r > n) return 0;
        return fact[n] * ifact[n-r] * ifact[r];
    }
    constexpr ModInt<mod> &operator[] (int i) const {
        return fact[i];
    }
};

constexpr int MOD = 1000000007;
constexpr int MAX = 1000100;

int main() {
	Combination<MOD> binom(MAX);
	int n, k;
	cin >> n >> k;
	
	cout << binom(k, n) << '\n';
	
	return 0;
}


Measured memory_bytes: 10580
#![allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

fn main() {
   input! {
      n:usize,
      xy: [(i64, i64); n]
   }

   let mut low = 0f64;
   let mut high = 1000f64;
   let mut pm = vec![];
   for i in 0..n {
      for j in i + 1..n {
         let (x1, y1) = xy[i];
         let (x2, y2) = xy[j];
         pm.push(((x1 + x2) as f64 / 2.0, (y1 + y2) as f64 / 2.0));
      }
   }

   for &(x1, y1) in pm.iter() {
      let mut mx = 0f64;
      for (x2, y2) in xy.iter().map(|&(x, y)| (x as f64, y as f64)) {
         let r = ((x1 - x2).powi(2) + (y1 - y2).powi(2)).sqrt();
         if mx < r {
            mx = r;
         }
      }
      if mx < high {
         high = mx;
      }
   }

   'outer: for _ in 0..100 {
      let r = (high + low) / 2.0;
      let mut points = pm.clone();
      for i in 0..n - 1 {
         for j in i + 1..n {
            if let Some((p1, p2)) = intersection(r, xy[i], xy[j]) {
               points.push(p1);
               points.push(p2);
            } else {
               low = r;
               continue 'outer;
            }
         }
      }
      let mut flag = false;
      let mut rm = 0f64;
      'outer1: for (x1, y1) in points {
         for (x2, y2) in xy.iter().map(|&(x, y)| (x as f64, y as f64)) {
            let rn = ((x1 - x2).powi(2) + (y1 - y2).powi(2)).sqrt();
            if rn > r {
               continue 'outer1;
            }
            if rn > rm {
               rm = rn;
            }
         }
         flag = true;
         break;
      }
      if flag {
         high = rm;
      } else {
         low = r;
      }
   }
   println!("{0:.10}", high);
}

fn intersection(
   r: f64,
   (x1, y1): (i64, i64),
   (x2, y2): (i64, i64),
) -> Option<((f64, f64), (f64, f64))> {
   let mx = (x1 + x2) as f64 / 2.0;
   let my = (y1 + y2) as f64 / 2.0;
   let dx = (x1 - x2) as f64;
   let dy = (y1 - y2) as f64;
   let dr = (dx * dx + dy * dy).sqrt();
   if dr <= 2.0 * r {
      let h = (r * r - dr * dr / 4.0).sqrt();
      let a = (-dx / dy).atan();
      return Some((
         (mx + h * a.cos(), my + h * a.sin()),
         (mx - h * a.cos(), my - h * a.sin()),
      ));
   }
   None
}


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

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

    int ans=0;
    rep(i,n){
        int num=0;
        while(a[i]%2 == 0){
            a[i] >>= 1;
            num++;
        }
        ans += num;
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k){
        cout<<n*x<<endl;
    }
    else{
        cout<<k*x+(n-k)*y<<endl;
    }
    
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 300010;
int n , l , a[N];
int main(){
	scanf("%d%d",&n,&l);
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	int idx = -1;
	for(int i = 0 ;i < n - 1;i++){
		if(a[i] + a[i + 1] >= l){
			idx = i;
			break;
		}
	}
	if(idx == -1){
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	for(int i = 0;i<idx;i++)
		printf("%d\n",i + 1);
	for(int i =n - 2;i > idx;i--)
		printf("%d\n",i + 1);
	printf("%d\n",idx + 1);
    return 0;
} 

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace C___Cell_Inversion
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver());
        }
        static long solver()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            long MOD = 1000000007;

            if (S[0] == 'W' || S[S.Length - 1] == 'W') return 0;
            var isRight = new bool[S.Length];
            for (int i = 0; i < S.Length; i++) isRight[i] = (i % 2 == 1) == (S[i] == 'W');
            if (isRight.Count(b => b) != S.Length / 2) return 0;

            long setCount = 1;
            int rightCount = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (rightCount < 0) return 0;
                if (isRight[i])
                {
                    rightCount++;
                }
                else
                {
                    setCount = setCount * rightCount % MOD;
                    rightCount--;
                }
            }
            for (int i = 2; i <= N; i++) setCount = setCount * i % MOD;
            return setCount;
        }
    }
}


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

const int N=2e5+10;

int n,k,c;
int L[N],R[N];
char str[N];

int main()
{
	cin>>n>>k>>c;
	cin>>(str+1);
	
	int cnt=0;
	for(int i=1,j=0;i<=n;i++) {
		if(str[i]!='x') {
			L[++j]=i;
			i+=c;
			cnt=max(cnt,j);
		}
	}
	if(cnt>k) return 0;
	for(int i=n,j=cnt;i>=1;i--) {
		if(str[i]!='x') {
			R[j--]=i;
			i-=c;
		}
	}
	
	for(int i=1;i<=cnt;i++) {
		//cout<<L[i]<<' '<<R[i]<<'\n';
		if(L[i]==R[i]) cout<<L[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int n,mi=10000000,ma=-10000000;
    long long sum=0;
  cin >> n;
  int i,b;
  for(i=0;i<n;i++){
    cin >> b;
    mi=min(mi,b);
    ma=max(ma,b);
    sum+=b;
  }
  cout << mi <<  " " << ma << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1164
n, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)

#ans = ""

k.upto(n-1) do |a|
	#ans += arr[a] > arr[a-k] ? "Yes\n" : "No\n"
	puts arr[a] > arr[a-k] ? "Yes": "No"
end

#puts ans






Measured memory_bytes: 36044
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

excess = []
shortage = []

ans = 0

for i in range(n):
    if a[i] >= b[i]:
        excess.append(a[i] - b[i])
    else:
        shortage.append(b[i] - a[i])

ans = len(shortage)

if sum(excess) < sum(shortage):
    print(-1)
elif len(shortage) == 0:
    print(0)
else:
    excess.sort(reverse=True)
    excess_num = 0
    shortage_num = sum(shortage)
    for i in range(n):
        excess_num += excess[i]
        ans += 1
        if excess_num >= shortage_num:
            print(ans)
            exit()

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

typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const ll N=210;
int main()
{
    fast();
    ll n,a;
    cin>>n>>a;

    n = n%500;
    if(n<=a)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char ch;
        int n , a, b ;

        scanf("%d%d%d" , &n , &a , &b);

	if(1 > n || n > 20 || 1 > a || a > 50 || 1 > b || b > 50 ){

	}

	int r = a*n ;


	
	if (r > b) {
printf("%d\n",b);
}else {
printf("%d\n",r);
}

	
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+9;
int a[N], cnt[N];
int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        cnt[ a[i] + 1 ] ++;
        cnt[ a[i] - 1 ] ++;
        cnt[ a[i] ]++;
    }
    int res = 0;
    for (int i = 0; i <= 1e5; i++) res = max(res, cnt[i]);
    return 0 * printf("%d\n", res);
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
 
	static Main instance = new Main();
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int[] a = new int[n];
        long[] count = new long[n];
      
        for(int i = 0; i < n ; i++){
          a[i] = sc.nextInt()-1;
          count[a[i]]++;
        }
        
        long ans = 0;
        for(int i = 0 ; i < n ; i++){
          ans += (count[i]*(count[i]-1))/2;
        }
        
        for(int k = 0; k < n ; k++){
          int K = a[k];
          ans -= (count[K]-1);
          System.out.println(ans);
          ans += (count[K]-1);
        }
      
	}
}

Measured memory_bytes: 64100
#include <stdio.h>
#include <math.h>

int judge(int);

int main()
{
  int i, n, num, count=0, result;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num);
    result=judge(num);
    if(result==1) count++;
    
  }
  printf("%d\n",count);
  
  return 0;
}
int judge(int a)
{
  int i, sqrt_a;

  if(a==2) return 1;
  if(a%2==0) return 0;

  sqrt_a=sqrt(a);
  
  for(i=2;i<=sqrt_a;i++){
    if(a%i==0) return 0;
  }
  return 1;
}


Measured memory_bytes: 2084
function Main(input) {
  input = input.split("\n");
  n = Number(input[0].split(" "));
  a = input[1].split(" ").map(Number);
  b = input[2].split(" ").map(Number);
  c = input[3].split(" ").map(Number);
  var ans=0;
  for(var i=0; i<n; i++){
    ans+=b[a[i]-1];
    if(a[i] == a[i-1]+1){
      ans+=c[a[i]-2];
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n, m = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [int(input()) for i in range(m)]
c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

for i in range(n):
    print(c[i])
    

Measured memory_bytes: 7992
#include<iostream>
#include<sstream>
#include<cstdio>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
	vector<int> args;
	for(int x=0;x<10;x++){
		int j;scanf("%d",&j);args.push_back(j);
	}
	sort(args.begin(),args.end());
	for(int x=0;x<3;x++){
		printf("%d\n",args[args.size()-1-x]);
	}
	return 0;
}	

Measured memory_bytes: 1208
package main
 
import "fmt"
 
func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)
 
	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String N0 = scan.next();
		String S = scan.next();
		int N = Integer.parseInt(N0);
		int x = 0;

		char[] moji = new char[N];// 判定前配列
		int[] value = new int[N];// 判定後配列

		for (int i = 0; i <= N -1  ; i++) {
			
			moji[i] = S.charAt(i);
			if (moji[i] == 'I') {
				x++;
				value[i] = x;
			} else if (moji[i] == 'D') {
				x--;
				value[i] = x;
			}

		}
		//System.out.println(Arrays.toString(value));
		
		int max = value[0];
		for (int a = 1; a < value.length; a++) {
			int v = value[a];
			if (v > max) {
				max = v;
			}
	
		}
		
		if(max< 0){
			System.out.println(0);		
		} else {
			System.out.println(max);		
		}




		
	}
}


Measured memory_bytes: 23124
#coding:utf-8
a=input()
b=input()
dumy=""
count=True
for i in range(len(a)):
  if(a==b):
    print("Yes")
    count=False
    break
  a=list(a)
  dumy=a.pop()
  a="".join(a)
  a=dumy+a
if(count==True):
  print("No")

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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,x;cin>>n;
    map<int,int> m;
    for(int i=0;i<n;++i){
        cin >> x;
        ++m[x];
        if(m[x]==3) m[x] = 1;
    }
    int ans = 0, cnt = 0;
    for(auto itr = m.begin(); itr != m.end(); ++itr){
        if(itr->second==2) ++ans;
        ++cnt;
    }
  
    cout << cnt - (ans%2) << '\n';
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,minx=9999999;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int k=0;k<=n;k++)
	{
		int x=0,y=0;
		for(int i=1;i<=n;i++)
		{
			if(i<k)
			{
				x+=a[i];
			}
			else
			{
				y+=a[i];
			}
		}
		if(abs(x-y)<minx)
		{
			minx=abs(x-y);
		}
	}
	cout<<minx<<endl;
	return 0;
}

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

int main(void)
{
	int n = 0,m[10];
	for (int i = 0; i <= 9; i++)
	{
		m[i] = 0;
	}
	for (int i = 0; i <= 3; i++)
	{
		scanf("%d", &n);
		m[n] += 1;
	}

	if (m[1] == 1 && m[4] == 1 && m[7] == 1 && m[9] == 1)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 128
import queue
K = int(input())
q = queue.Queue()
count = 0
for i in range(1,10):
  q.put(str(i))
while count < K:
  tmp = q.get()
  count += 1
  if count == K:
    print(tmp)
    break
  if tmp[-1] == '0':
    for add in ['0', '1']:
      q.put(tmp + add)
  elif tmp[-1] == '9':
    for add in ['8', '9']:
      q.put(tmp + add)
  else:
    for add in [str(int(tmp[-1]) - 1),tmp[-1], str(int(tmp[-1]) + 1)]:
      q.put(tmp + add)

    

Measured memory_bytes: 17520
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,K;string S;
	cin>>N>>K>>S;
	
	// 解法
	ll ans = 0;
	ll count = 0;
	ll r = 0;
	REP(l,N){
		if (l!=0 & S[l-1]=='0' & S[l]=='1') count--;
		while (r<N){
			if (count==K & S[r-1]=='1' & S[r]=='0')break;
			if (r==l & S[r]=='0'){
				count++;
			}
			else if (S[r-1]=='1' & S[r]=='0'){
				count++;
			}
			
			// printf("l:%lld r:%lld, s:", l,r);
			// cout<<S.substr(l,r-l+1);
			// printf(" count:%lld\n", count);
			if (r-l+1>ans) ans = r-l+1;
			r++;
		}
	}
	
	//出力
	cout << ans << endl;
}


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

struct Card
{
	int value;
	char mark;
};

//????????????????????????????????¨
void BubbleSort(Card A[], int n)
{
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j > i; j--) {
			if (A[j].value < A[j - 1].value) {
				Card c = A[j];
				A[j] = A[j - 1];
				A[j - 1] = c;
				flag = 1;
			}
		}
	}
}

void SelectionSort(Card A[], int n)
{
	int i, j, minj;
	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (A[minj].value > A[j].value) minj = j;
		}
		if (minj != i) {
			Card c = A[i];
			A[i] = A[minj];
			A[minj] = c;
		}		
	}
}

void show(Card A[], int n)
{
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << A[i].mark << A[i].value;
	}
	cout << endl;
}

int main()
{
	int n;
	Card c1[100], c2[100];
	bool isStable = 1;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c1[i].mark >> c1[i].value;
		c2[i] = c1[i];
	}
	BubbleSort(c1, n);
	SelectionSort(c2, n);

	show(c1, n);
	cout << "Stable" << endl;
	show(c2, n);
	for (int i = 0; i < n; i++) {
		if (c1[i].mark != c2[i].mark) {
			cout << "Not stable";
			isStable = 0;
			break;
		}
	}
	if (isStable) cout << "Stable";
	cout << endl;
	return 0;
}

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

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back


using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };



void solve() {

    int n;
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
}


int main() {

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

        
        solve();


    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main(){
	int x, y, z;
	int s, ans;
	scanf("%d %d %d", &x, &y, &z);
	s = 0;
	for (int i = 100; i >= 1; i--){
		if (x%i == 0 && y%i == 0)s++;
		if (s == z){
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
#print(a)
#print(b)
ans=0
for i in range(n):
    t=min(a[i],b[i])
    ans+=t
    a[i]-=t
    b[i]-=t
    t=min(a[i+1],b[i])
    ans+=t
    a[i+1]-=t
    b[i]-=t
print(ans)



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

int main(){
  int i,j,cnt=0;
  int n,m;
  cin>>n>>m;
  int a=1900*m+100*(n-m);
  int p=1;
  for(i=0;i<m;i++){
    p*=2;
  }
  cout<<a*p<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int numOfDigits(long N, long K) {

    int cnt = 0;

    while (N != 0) {
        N /= K;
        cnt += 1;
    }

    return cnt;
}

int main() {
    long N, K;
    cin >> N >> K;

    cout << numOfDigits(N, K) << endl;

    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,t;
    cin >> n >> t;
    int d,p;
    int dp=INT_MAX;
    for(int i=0;i<n;i++)
    {
        cin >> d >> p;
        if(p<=t)
            dp=min(dp,d);
    }
    if(dp==INT_MAX)
        cout << "TLE";
    else
        cout << dp;
	return 0;
}


Measured memory_bytes: 256
def modinv(a, m): #mod. m でのaの逆元 a^{-1}を計算する
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    
    u %= m
    if u < 0:
        u += m
    return u

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

MOD = 10 ** 9 + 7

#O(N)
first = []
for i in range(0, H - A):
    if i == 0:
        tmp = 1
        first.append(tmp)
        continue
    tmp = (tmp * (B + i - 1) * modinv(i, MOD)) % MOD
    first.append(tmp)

# print (first)

#O(N)
second = []
for i in range(0, H):
    if i == 0:
        tmp = 1
        second.append(tmp)
        continue
    tmp = (tmp * ((W - B) + i - 1) * modinv(i, MOD)) % MOD
    second.append(tmp)

# print (second)

#O(N)
ans = 0
for i in range(H - A):
    ans = (ans + first[i] * second[H - 1 -i]) % MOD

print (ans)
#total O(3 * N) --> O(N)

Measured memory_bytes: 10664
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),k=sc.nextInt(),r=sc.nextInt(),s=sc.nextInt(),p=sc.nextInt();
    long max=0;
    String str=sc.next();
    StringBuilder res= new StringBuilder(str);
    for(int i=0;i<str.length();i++) {
    	if(i>=k) {
    		if(res.substring(i, i+1).equals(res.substring(i-k, i+1-k)))res.replace(i, i+1, "x");
    	}
    }
    for(int i=0;i<res.length();i++) {
    	if(res.substring(i, i+1).equals("r"))max+=p;
    	else if(res.substring(i, i+1).equals("s"))max+=r;
    	else if(res.substring(i, i+1).equals("p"))max+=s;
    }
    System.out.println(max);
    //System.out.println(res);
  }
}


Measured memory_bytes: 42508
import sys
import numpy as np
input = sys.stdin.readline
n = int(input())
G = np.array([list(map(int, input().split())) for _ in range(n)], dtype=float)
use = np.ones((n,n),dtype=bool)
impossible = np.zeros((n,n),dtype=bool)
for w in range(n):
    D = sum(np.meshgrid(G[w], G[w]))
    D[w] = np.inf
    D[:,w] = np.inf
    use &= ~(G == D)
    impossible |= G > D
if impossible.any():
    print(-1)
else:
    print(int(np.sum(G[use]) / 2))

Measured memory_bytes: 17852
n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    sum=0
    p=10000
    l=i
    for k in range(5):
        sum+=int(l/p)
        l%=p
        p/=10
    if sum>=a and sum<=b:
        ans+=i

print(ans)

"""
20 2 5

84

10 1 2

13

100 4 16

4554


"""

Measured memory_bytes: 3060
package main

import "fmt"

func main() {

	var h, w int
	
	for {

		fmt.Scan(&h, &w)
		if h==0 && w==0 {
			break
		}

		for row:=0; row<h; row++ {
			for col:=0; col<w; col++ {
				if (row+col)%2 == 0{
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}
const int MAX_N = 2000002;
int f[MAX_N];
set<int> st;
map<int, bool> mp;
int mx;
int dd;
void sieve(vector<int> a) {
  f[0] = -1;
  for (int i : a) {
    if (mp[i]) {
      dd++;
      st.erase(i);
      continue;
    }
    if (f[i]) continue;
    st.insert(i);
    mp[i] = true;
    f[i] = i;
    for (ll j = i; j <= mx; j += i)
      if (!f[j]) f[j] = i;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }
  sort(a.begin(), a.end());
  mx = a[n - 1];
  sieve(a);
  int ans = st.size();
  // if (dd > 0) ans -= dd + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 24336