akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)

using namespace std;

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    ll N, K, L, R;
    string s;
    cin>>s;
    rep(i,s.length()){
        cout<<"x";
    }
   cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, ta[1010], mu = 1;
void yaku(int n) {
	int i = 2;
	while (n >= 2) {
		while (n%i == 0) {
			n /= i;
			ta[i]++;
		}
		i++;
	}
}

signed main() {
	cin >> n;
	for (int i = 2; i <= n; i++) {
		yaku(i);
	}
	sort(ta, ta + 1010);
	for (int i = 1009; i >= 0; i--) {
		if (ta[i] == 0)break;
		else {
			mu *= (ta[i] + 1);
			mu %= INF;
		}
	}
	cout << mu << endl;
	ggr
}

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

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> C(H);
  rep(i, H) cin >> C[i];

  int ans=0;
  vector<int> BL_H(H);
  vector<int> BL_W(W);

  rep(i, (1<<H)){
    rep(j,(1<<W)){
      bitset<6> b(i);
      bitset<6> c(j);

      int sum = 0;
      int cnt = 0;
      rep(k,H){
        rep(l,W){
          if(C[k][l] == '#') sum++;
          if(b.test(k) || c.test(l)){
            if(C[k][l] == '#') cnt++;
          }
        }
      }
      if(sum - cnt == K) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N, A, B;
    vector<int> P;
    cin >> N;
    cin >> A >> B;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        P.push_back(p);
    }
    vector<int> v1, v2 ,v3;
    for (int i = 0; i < N; ++i) {
        int p = P[i];
        if(p <= A){
            v1.push_back(p);
        }
        if(A+1 <= p && p <= B){
            v2.push_back(p);
        }
        if(B+1<= p){
            v3.push_back(p);
        }
    }

    int result = (v1.size() < v2.size())? v1.size() : v2.size();
    result = (result < v3.size())? result : v3.size();

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#define pb push_back
#define INF 999999

using namespace std;

int main(){
    //Fast I/O 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, W; //n = quantidade de itens disponiveis  // W = capacidade da knapsack
    cin >> n >> W;
    vector<long int> val(n + 1);
    vector<long int> wt(n + 1);
    val[0] = -1, wt[0] = - 1;
    for(int i = 1; i <= n; i++){
        cin >> wt[i] >> val[i];
    }
    long int knapsack[n + 1][W + 1];
    //pre-processing...
    for(int i = 0; i <= n; i++){
        knapsack[i][0] = 0;
    }
    for(int i = 0; i <= W; i++){
        knapsack[0][i] = 0;
    }
    //show time!
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= W; j++){
            if(wt[i] > j){
                knapsack[i][j] = knapsack[i - 1][j];
            }else{
                knapsack[i][j] = max(knapsack[i - 1][j], val[i] + knapsack[i - 1][j - wt[i]]);
            }
        }
    }
    cout << knapsack[n][W] << endl;
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

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

}

int arr[100001];
int f[100001];
int ma[100001];
int ans[100001];

int Find(int x) {

	if (x == f[x])
		return x;

	return f[x] = Find(f[x]); 

}

int32_t  main() {

	IOS;

	int N, M, K;

	cin >> N >> M >> K;

	for (int i = 1; i <= N; i++) {

		f[i] = i;

	}

	for (int i = 0; i < M; i++) {

		int x, y;
		cin >> x >> y;
		arr[x]++;
		arr[y]++;

		f[Find(x)] = Find(y);

	}
	 
	for (int i = 1; i <= N; i++) {

		ma[Find(i)]++;

	}

	for (int i = 1; i <= N; i++) {
	   ans[i] =  (ma[f[i]] - arr[i] -1) ;
	}

	for (int i = 0; i< K; i++) {

		int a, b;

		cin >> a >> b;

		if (f[a] == f[b]) {

			ans[a]--;

			ans[b]--;
		}
	}
	 
	for (int i = 1; i <= N; i++) {

		cout << ans[i] << " " ;

	}


}


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> vec (3);
    for(int i = 0;i < 3;i++){
        cin >> vec[i];
    }
    SORT(vec);
    cout << vec[2]-vec[0] << endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
    	Scanner scn = new Scanner(System.in);
    	int inputDate;
    	int x =1;
    	while(true) {
    		inputDate = scn.nextInt();
    		if (inputDate == 0) {
    			break;
    		}
    		System.out.println("Case " +  + x++ + ": " + inputDate);
    	}
   	}
 }


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	bool a = false;
	int k = n / 2;
	int count = 0;
	for (int i = 0; i < k; i++) { 
		if (n % 2 == 0 && (s[i] == s[i + k]))
			count++;
	}
	if (count == k)a = true;
	if (n == 1)a = false;
	if (a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a;
	while(1)
	{
		scanf("%d",&n);
		if(n>=1 && n<=100) break;
	}
	if(n%2==0)
	{
		a=n/2;
	}
	else
	{
		a=(n/2)+1;
	}
	printf("%.10f",a*1.0/n);
	return 0;
 } 

Measured memory_bytes: 128
import numpy as np
N=int(input())
mod=10**9+7
A=np.array(list(map(int, input().split())))
ans=0
for i in range(60):
  ones=np.count_nonzero(A>>i&1)
  zeros=N-ones
  ans+=ones*zeros*2**(i)%mod
  ans%=mod
  
print(ans)

Measured memory_bytes: 48808
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int n;

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n;
    int a[n][n-1], b[n][n];
    for(int i=0;i<n;++i) {
        for(int j=0;j<n-1;++j) {
            cin >> a[i][j];
            --a[i][j];
            b[i][a[i][j]] = j;
        }
    }

    queue<Pii> que;
    for(int i=0;i<n;++i) que.emplace(i, a[i][0]);
    vector<int> idx(n, 0);
    vector<vector<int>> d(n, vector<int>(n-1, 0));
    while(!que.empty()) {
        Pii p = que.front(); que.pop();
        // cerr << "(" << p.first+1 << ", " << p.second+1 << ")" << endl;
        if(d[p.second][b[p.second][p.first]] == -1) {
            int d1 = (b[p.first][p.second] == 0)?0:d[p.first][b[p.first][p.second]-1];
            int d2 = (b[p.second][p.first] == 0)?0:d[p.second][b[p.second][p.first]-1];
            d[p.first][b[p.first][p.second]] = max(d1, d2) + 1;
            d[p.second][b[p.second][p.first]] = max(d1, d2) + 1;

            if(b[p.first][p.second] != n-2) {
                que.emplace(p.first, a[p.first][b[p.first][p.second]+1]);
            }
            if(b[p.second][p.first] != n-2) {
                que.emplace(p.second, a[p.second][b[p.second][p.first]+1]);
            }

        } else {
            d[p.first][b[p.first][p.second]] = -1;
        }

        // for(int i=0;i<n;++i) {
        //     for(int j=0;j<n-1;++j) {
        //         cerr << d[i][j] << " ";
        //     }
        //     cerr << endl;
        // }
        // cerr << endl;
        
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
        ans = max(ans, d[i][n-2]);
        for(int j=0;j<n-1;++j) {
            if(d[i][j] < 1) {
                ans = -1;
                break;
            }
        }
        if(ans == -1) break;
    }

    cout << ans << endl;

}


Measured memory_bytes: 12032
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
#include<queue>
#include<random>
#include<map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
using namespace std;

int n,mm;


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

    cin >> n >> mm;
    vector<int> k(n);
    for(int i=0;i<n;i++) cin >> k[i];
    map<ll , ll> m;
    vector<int> sum(n+1);
    sum[0] = 0;
    for(int i=0;i<n;i++){
        sum[i+1] = (sum[i] + k[i])%mm;
    }

    ll ans=0;

    for(int i=0;i<=n;i++){
        ans += m[sum[i]];
        m[sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	if (b!=100) cout << b*pow(100, a) << endl;
	else cout << (ll)((b + 1)*pow(100, a)) << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# f_inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N = inputInt()
	A = inputList()

	A.sort()

	for i,val in enumerate(A):
		if i == 0:
			continue
		if val == A[i-1]:
			print("NO")
			sys.exit()

	print("YES")

if __name__ == "__main__":
	main()


Measured memory_bytes: 79304
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    long long int n=0;
    long long int ch_num = 0;
    char ch[11] = {0};
    rep(i, 11) ch[i] = -1;
    cin >> n;
    int counter = 0;
    while (n >= ch_num)
    {
        int foo[3] = {0};
        ch[0]++;
        rep(i, 10)
        {
            if (ch[i] > 2)
            {
                ch[i] = 0;
                ch[i + 1]++;
            }
        }
        ch_num = 0;
        rep(i, 11)
        {
            if (ch[i] == 0)
            {
                ch_num += 3 * pow(10, i);
                foo[0] += 1;
            }
            if (ch[i] == 1)
            {
                ch_num += 5 * pow(10, i);
                foo[1] += 1;
            }
            if (ch[i] == 2)
            {
                ch_num += 7 * pow(10, i);
                foo[2] += 1;
            }
        }
        if (foo[0] > 0 && foo[1] > 0 && foo[2] > 0 &&n>=ch_num) //3,5,7があるか
            counter++;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N = iin()
XL = [iln() for _ in range(N)]

XL = sorted(XL, key=lambda x: x[0]+x[1])

prev = -10**9
ans = 0
for i in range(0, N):
    if prev <= XL[i][0] - XL[i][1]:
        ans += 1
        prev = XL[i][0] + XL[i][1]
print(ans)




Measured memory_bytes: 35188
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int  s,esc,c;
    cin>>s;
	vector<int> a(1000000);
	a[0] = s;
	esc = 0;
	for (int i = 1;;i++){
		if (a[i-1] % 2 == 0)a[i] = a[i-1] / 2;
		else a[i] = 3*a[i-1] + 1;
		for (int j = 0; j < i; j++){
			if (a[i] == a[j]) esc=1;
				}
		if (esc == 1){
			c = i;
			break;
		}
	}
	cout << c+1 << endl;
    
}


Measured memory_bytes: 4096
n = int(input())
alist = list(map(int, input().split()))

mina = pow(10, 9) + 7
mc = 0
ans = 0
for a in alist:
  if abs(a) < mina:
    mina = abs(a)
  if a < 0:
    mc += 1
    ans += -a
  else:
    ans += a

if mc % 2 == 0:
  print(ans)
else:
  print(ans - 2 * mina)


Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define size(a) (ll)(a).size()

typedef long long ll;
typedef long double ld;

using namespace std;
int n;
string s;


int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");


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

    cin >> n;

    vector<int> A(n);
    vector<int> B(n);

    set<pair<int, int>> MX_find;

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

    for (int i = 0; i < n; i++)
    {
        cin >> B[i];
        MX_find.insert({B[i], i});
    }

    ll ans = 0;

    while(!MX_find.empty())
    {
        auto q = *MX_find.rbegin();
        MX_find.erase(q);
        int numb = q.x;
        int pos = q.y;

        //cout << numb << ' ' << pos << endl;

        int prev = (pos - 1 + n) % n;
        int next = (pos + 1) % n;

        int sum = B[prev] + B[next];

        int final_form = numb % sum;

        if (final_form != A[pos] % sum)
        {
            if (A[pos] > final_form)
            {
                ans = -1;
                break;
            }

            ans += numb / sum;
            B[pos] = final_form;

            if (numb == final_form)
            {
                ans = -1;
                break;
            }

            MX_find.insert({B[pos], pos});
        }
        else
        {
            ans += (numb - A[pos]) / sum;
            B[pos] = A[pos];
        }
    }

    cout << ans << "\n";

}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

void solve(){
    int n,ans = 0;
    cin >> n;
    vector<int>v(n+5);
    FOR(i,1,n+1)cin >> v[i];
    FOR(i,1,n+1){
        FOR(j,i+1,n+1){
            FOR(k,j+1,n+1){
                vector<int>tmp;
                tmp.pb(v[i]);
                tmp.pb(v[j]);
                tmp.pb(v[k]);
                sort(tmp.begin(),tmp.end());
                if(tmp[0] != tmp[1] && tmp[1] != tmp[2] && tmp[0]+tmp[1] > tmp[2]){
                    ++ans;
                    //cout << i << " " << j << " " << k << "\n";
                }
            }
        }
    }
    cout << ans << "\n";
}
 
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define llint long long int
#define ldouble long double

//setprecision()<<

using namespace std;

int main() {
string big="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small="abcdefghijklmnopqrstuvwxyz";
int N,K;
string S;
cin>>N>>K>>S;
for(int i=0;i<26;i++){
    if(S.at(K-1)==big.at(i)){
        S.at(K-1)=small.at(i);
        break;
    }
}
cout<<S<<endl;
return 0;
}

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

double dp[3000][3000];
double solve(double a[],int i,int cnt,int n)
{
	if(i==n+1)
	{
		if(cnt>n-cnt)
		return(1.0);
	    else
	    {
	    	return(0.0);
	    }
	}
	if(dp[i][cnt]!=-1.0)
	{
		return(dp[i][cnt]);
	}
	double op1=solve(a,i+1,cnt+1,n)*(a[i]);
	double op2=solve(a,i+1,cnt,n)*(1-a[i]);
	return(dp[i][cnt]=op1+op2);
}
int main()
{
	int n,i,j;
	cin>>n;
	double a[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<3000;i++)
	{
		for(j=0;j<3000;j++)
		{
			dp[i][j]=(-1.0);
		}
	}
    cout<<fixed<<setprecision(9)<<solve(a,1,0,n);
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

#define lli long long int
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int main (void)
{
	lli l, r;
	scanf("%lld %lld",&l,&r);
	if (l%2019 == 0 || r%2019 == 0)
	{
		printf("0\n");
		return(0);
	}
	if (r-l > 2018)
	{
		printf("0\n");
		return(0);
	}
	lli min_i, min_j;
	min_i = 2020;
	min_j = 2020;
	lli index = l;
	lli j = l;
	lli out = 2019;
	lli tmp = 0;
	while (index <= r)
	{
		j = l;
		while (j <= r)
		{
			if (index == j)
			{
				j++;
				continue;
			}
			tmp = ((index%2019)*(j%2019))%2019;
			if (tmp < out )
			{
				out = tmp;
			}
			j++;
		}
		index++;
	}
	
	printf("%lld\n",out%2019);
	return(0);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main () {
    int h,w,a,b;cin>>h>>w>>a>>b;
    int x[h][w],k=0,count=0,u=0;
       for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            x[i][j]=0;
        }
    }
    for (int i=0;i<b;i++) {
        //count++;
        //if (count>b) {k=u+1;count=1;}
        for (int j=0;j<a&&j<w;j++) {
            x[i][j]=1;
        }
    }
      for (int i=b;i<h;i++) {
        for (int j=a;j<w;j++) {
            x[i][j]=1;
        }
    }
   /*  for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            cout<<x[i][j];
        }
    }*/
    
    int r1=0,r2=0,f=0;
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (x[i][j]==1) f++;
        }
        if (f==a||f==h-a) {r1=1;break;}
        f=0;
    }
    if (w==1) r2=1;
    f=0;
     for (int i=0;i<w;i++) {
        for (int j=0;j<h;j++) {
            if (x[j][i]==1) f++;
        }
        if (f==b||f==w-b) {r2=1;break;}
        f=0;
    }
    if (h==1) r1=1;
  if (r1==0||r2==0) cout<<"-1"<<endl;
  else {
       for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            cout<<x[i][j];
        }
        cout<<endl;
    }
  }
}



Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int min = 100;

		for(int i = 1;i<=(N/2);i++) {
			int sum;
			sum = getDigitSum(N-i)+getDigitSum(i);
			if(min>sum) {
				min=sum;
			}
		}

		System.out.println(min);

	}

	private static int getDigitSum(int x) {
		int s =0;
		for(int i = 0;x != 0;i++) {
			s += x%10;
			x /=10;
		}
		return s;
	}

}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  REP(i, n) {
    int h;
    cin >> h;
    ans += (k <= h);
  }
  cout << ans << endl;
  return 0;
}

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

int n;
int a[100000];
int cnt[100001];

int power(int a, int n) {
	int ret = 1;
	for (int i = 0; i < n; i++) {
		ret *= a;
		ret %= 1000000007;
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	
	for (i = 0; i < n; i++) cnt[a[i]]++;
	
	if (n % 2) {
		if (cnt[0] != 1) { cout << 0 << endl; return 0; }
		for (i = 2; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		cout << power(2, n / 2) << endl;
	}
	
	else {
		for (i = 1; i < n; i += 2) {
			if (cnt[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
		cout << power(2, n / 2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1024
# ABC 058: B – ∵∴∵
o, e = [input() for _ in range(2)]

password = ''

if len(o) == len(e):
    for i in range(len(o)):
        password += o[i] + e[i]
elif len(o) > len(e):
    password += o[0]

    for i in range(len(e)):
        password += e[i] + o[i + 1]

print(password)

Measured memory_bytes: 3060
N = int(input())
A = [[] for _ in range(N)]
B = [[] for _ in range(N)]
for i in range(N):
    A[i], B[i] = map(int, input().split())

A.sort()
B.sort()
if N%2 == 1:
    m_min = A[N//2]
    m_max = B[N//2]
    diff = m_max - m_min
    print(diff +1)
else:
    m_min = (A[N//2-1] +A[N//2])/2
    m_max = (B[N//2-1] +B[N//2])/2
    diff = m_max - m_min
    print(int(diff//0.5)+1)

Measured memory_bytes: 102176
N,M=map(int,input().split())
F = [set() for _ in range(N)]
for _ in range(M):
  a,b = map(lambda x: int(x)-1, input().split())
  F[a].add(b)
  F[b].add(a)

from collections import deque
 
def bfs():
  ans = 1
  done = set()
  for i in range(N):
    if i in done: continue
    queue = deque([i])
    num = 0
    while queue:
      p = queue.popleft()
      for p2 in F[p]:
        if p2 in done: continue
        done.add(p2)
        queue.append(p2)
        num += 1
    ans = max(ans,num)
  return ans
print(bfs())

Measured memory_bytes: 83608
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;

	int n;
	cin >> n;
	set <int> s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s.in(x);
	}
	if (sz(s) == n) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 9600
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long a[100000];

int get_lsb(int N){
    for(int i = 0; i < 32; i++){
        if(((N >> i) & 1) == 1){
            return i;
        }
    }
    return 32;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    int xor_total = 0;
    set <int> lsbs;
    for(int i = 0; i < N; i++){
        xor_total ^= a[i];
        lsbs.insert(get_lsb(a[i]));
    }
    
    bool flipped = false;
    int flip_no = 0;
    for(int i = 31; i >= 0; i--){
        //cout << i << endl;
        if(!flipped){
            if(((xor_total >> i) & 1) == 1){
                if(lsbs.find(i) == lsbs.end()){
                    cout << - 1 << endl;
                    return 0;
                }
                flipped = !flipped;
                flip_no ++;
            }
        } else {
            if(((xor_total >> i) & 1) == 0){
                if(lsbs.find(i) == lsbs.end()){
                    cout << -1 << endl;
                    return 0;
                }
                flipped = !flipped;
                flip_no ++;
            }
        }
    }
    
    cout << flip_no << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define no_of_test(x)        int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	no_of_test(x)
	{
       string a,b,s;
	   cin>>a>>b;
	   int a1,b1;
	   cin>>a1>>b1;
	   cin>>s;
	   if(s==a)
	   a1--;
	   else
	   {
		   b1--;
	   }
	   cout<<a1<<" "<<b1<<'\n';
	   
	}
	return 0;
}

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

error = False
capacity = [0]
cap = 1
for i, a in enumerate(A):
    cap = cap - a
    if cap < 0:
        error = True
        break
    capacity.append(cap)
    cap *= 2

if error:
    print(-1)
else:
    total = 0
    carry = 0
    for d in range(N, -1, -1):
        cap = capacity[d]
        a = A[d]
        check = carry + a
        if check <= cap:
            total += check
            carry += a
        else:
            total += check
            carry = cap

    print(total)


Measured memory_bytes: 668652
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if (a < b){
  for (int i =0; i < b; i++){
    cout << a;
    }
  }
  else {
  for (int j = 0; j < a; j++) {
    cout << b;
    }
  }
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

void solve(){
  string s, t; cin >> s >> t;
  vector<int> v(26, -1);
  string ans = "Yes\n";
  for(int i = 0; i < s.length(); i++){
    if(v[(int)s[i] - 97] == -1){
      v[(int)s[i] - 97] = (int)t[i] - 97;
      if(v[(int)t[i] - 97] == -1) v[(int)t[i] - 97] = (int)s[i] - 97;
      else if(v[(int)t[i] - 97] != v[(int)s[i] - 97]){
        ans = "No\n";
        break;
      }
    }
    else if(v[(int)s[i] - 97] != (int)t[i] - 97){
      ans = "No\n";
      break;
    }
    for(int i = 0; i < 26; i++){
      cout << (char)(i + 97) << "->" << (char)(v[i] + 97) << " ";
    }
    cout << endl;
  }
  cout << ans;
  return;
}

void solve2(){
  string s, t; cin >> s >> t;
  string ans = "Yes\n";
  vector<int> vs(26, -1), vt(26, -1);
  for(int i = 0; i < s.length(); i++){
    if(vs[(int)s[i] - 97] == -1){
      vs[(int)s[i] - 97] = (int)t[i] - 97;
    }
    else if(vs[(int)s[i] - 97] != (int)t[i] - 97){
      ans = "No\n";
      break;
    }
  }
  for(int i = 0; i < t.length(); i++){
    if(vt[(int)t[i] - 97] == -1){
      vt[(int)t[i] - 97] = (int)s[i] - 97;
    }
    else if(vt[(int)t[i] - 97] != (int)s[i] - 97){
      ans = "No\n";
      break;
    }
  }
  cout << ans;
}

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


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



int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{

	    ll n;
		cin>>n;
		ll arr[n+5];
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
		}
			    ll sum=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				sum+=(arr[i]*arr[j]);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[10000],i=1,k=0,t;
	while(k==0){
		scanf("%d",&a[i]);
		if(a[i]==0){
			k=1;
		}else {
			i++;
		}
	}
	for(t=1;t<=i-1;t++){
		printf("Case %d: %d\n",t,a[t]);
	}
	return 0;
}

Measured memory_bytes: 1752
#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>;

void Main()
{
  int x[5]; rep(i,5) {
    cin >> x[i];
    if (x[i] == 0) {cout << i+1 << endl; return;}
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    string k; cin>>k;
    int d; cin>>d;

    int len = k.size();
    vvi dp(d, vi(2));
    // dp[sum][smaller_already] reprsents the number of ways to choose digits so far
    // such that (sum of digits)%d is 'sum' and smaller_already means whether
    // we have already choosen a digit that is smaller than some digit in K

    dp[0][0] = 1;
    for(int idx=0; idx<len; ++idx){
        vvi ndp(d, vi(2));
        for(int sum=0; sum<d; ++sum){
            for(bool sm_already : {false, true}){
                for(int digit = 0; digit<10; ++digit){
                    if(digit > k[idx] -'0' && !sm_already){
                        break;
                    }
                    
                    // either it was prev smaller or since now the digit chosen is < than k[idx]
                    // so sm_already and we can choose bigger digits in next idx
                    add_self(ndp[(sum+digit)%d][sm_already || digit < k[idx] - '0' ], 
                             dp[sum][sm_already]);
                }
            }
        }
        dp = ndp;
    }

    int ans = (dp[0][false] + dp[0][true])%mod;
    --ans; // since we are counting 0 as well
    if(ans<0){
        ans+=mod;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

long long n, d;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> d;
	d *= d;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		long long x, y;
		cin >> x >> y;
		long long dist = x * x + y * y;
		cnt += (dist <= d);
	}
	cout << cnt << '\n';
	return 0;
}

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

int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  if (A >= K) {
    ans += K;
    cout << ans << endl;
    return 0;
  } else {
    ans += A;
    K = K - A;
    if (B >= K) {
      cout << ans << endl;
      return 0;
    } else {
      K = K - B;
      ans -= K;
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		String n = scan.next();

		if (n.indexOf("9") != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int p=31;
const int m=1e9+7;
typedef long long ll;
typedef int in;
#define ff first
#define ss second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");} 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// #define int ll
in main (){
	
	#ifndef ONLINE_JUDGE					
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	unordered_map<int,pair<int,int>>ct;

	for(int i=0;i<n;++i){
		cin>>a[i];
		ct[a[i]].ff+=1;
	}

	for(int i=0;i<n;++i){
		cin>>b[i];
		ct[b[i]].ss+=1;
	}
	bool hai=true;
	for(int i=0;i<n;++i){
		if(ct[a[i]].ff+ct[a[i]].ss>n)
			{
				hai=false;
				break;
			}
	}

	if(!hai){
		cout<<"No";
		return 0;
	}
	cout<<"Yes\n";
	vector<int>r(n);
	r=b;
	reverse(r.begin(),r.end());
	int kha=-1,val=-1;
	for(int i=0;i<n;++i){
		if(r[i]==a[i]){
			kha=i;
			val=r[kha];
			break;
		}
	}	
	int l = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == val && r[i] == val) {
            l = i;
            break;
        }
    }
	if(kha!=-1)
	for(int i=0;i<n && kha<n;++i){	
		if(a[i]!=val && r[i]!=val && kha<=l){
		swap(r[i],r[kha]);
		++kha;
	}
		 if(kha<n && r[kha]!=val)break;
	}		
	for(int i=0;i<n;++i){
		cout<<r[i]<<' ';
	}

    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"; //check time    
}
    
/*
12
1 1 2 3 3 4 4 5 6 7 8 9
1 3 3 3 3 3 5 6 6 6 6 6
*/

Measured memory_bytes: 13632
import std.stdio,std.conv,std.datetime,std.algorithm,std.string,std.array;void main(){int[] a;auto w=["Sun","Mon","Tues","Wednes","Thurs","Fri","Satur"];while(a=readln.split.map!(to!int).array,a[0])writeln(w[Date(2004,a[0],a[1]).dayOfWeek]~"day");}

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

vector<ll> yaku;

int main(){
  ll n,m;
  cin >> n >> m;
  
  ll i=1;
  
  while(i*i <= m){
    if(m % i == 0){
      yaku.push_back(i);
      yaku.push_back(m/i);
    }
    i++;
  }
  
  sort(yaku.begin(), yaku.end(), greater<>());
  
  i=0;
  while(yaku[i] * n > m){
    i++;
  }
  
  cout << yaku[i] << endl;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

vector<ll> calc_divisor(ll n) {
    vector<ll> res;
    for (ll i = 1LL; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            ll j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> divs = calc_divisor(N);
    for (auto d : divs) {
        ll m = d - 1;
        if (m == 0) continue;
        if (N / m == N % m) ans += m;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
def p_a():
    N = int(input())
    H = list(map(int, input().split()))

    one = []
    two = []
    for i in range(N):
        if i < N - 1:
            one.append(abs(H[i + 1] - H[i]))
        if i < N - 2:
            two.append(abs(H[i + 2] - H[i]))

    ans = []
    ans.append(0)
    ans.append(one[0])

    for i in range(0, N - 2):
        ans.append(min(one[i + 1] + ans[i + 1], two[i] + ans[i]))

    print(ans[N-1])


if __name__ == '__main__':
    p_a()


Measured memory_bytes: 59752
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
object Main extends App {
  val scanner = new Scanner(System.in)
  var n = scanner.nextInt

  val tn = n * 2

  var m = ((-1 + math.sqrt(1 + 8 * n)) / 2).toInt
  while(m * (m + 1) < tn) {
    m += 1
  }

  while(n > 0) {
    if(n >= m) {
      println(m)
      n -= m
    }
    m-=1
  }
}

Measured memory_bytes: 23056
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int[] scalepans = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
        
        while (scanner.hasNext()) {
            int leftWeight = scanner.nextInt();
            int rightWeight = 0;
            int cnt = 0;
            boolean[] isUsed = new boolean [10];

            for (int i = scalepans.length-1; i >= 0; i--) {
                if (leftWeight == rightWeight) {
                    break;
                }
                if ((leftWeight - rightWeight) >= scalepans[i]) {
                    isUsed[i] = true;
                    rightWeight += scalepans[i];
                    cnt++;
                }
            }
            
            for (int i = 0; i < isUsed.length; i++) {
                if (isUsed[i]) {
                    if (cnt == 1) {
                        System.out.println(scalepans[i]);
                        break;
                    } else {
                        System.out.print(scalepans[i] + " ");
                    }
                    cnt--;
                }
            }
        }
    }
}

Measured memory_bytes: 17208
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[ \t\n,]");

	public static void main(String[] args){
		double x = 0;
		double y = 0;
		int ang = 90;
		for(;;){
			int d = scan.nextInt();
			int a = scan.nextInt();
			if(d == 0 && a == 0) break;
			x += (double) d * Math.cos(Math.toRadians((double) ang));
			y += (double) d * Math.sin(Math.toRadians((double) ang));
			ang -= a;
		}

		System.out.printf("%d\n", (int) x);
		System.out.printf("%d\n", (int) y);
	}
}

Measured memory_bytes: 26304
N, M=map(int,input().split())
H=list(map(int,input().split()))
ans=[1]*N
for i in range(M):
  A, B=map(int,input().split())
  x=H[A-1]
  y=H[B-1]
  if x>y:
    ans[B-1]=0
  elif x==y:
    ans[B-1]=0
    ans[A-1]=0
  elif y>x:
    ans[A-1]=0   
print(sum(ans))

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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		int maxNum=-1;
		int idx;
		for(int i = 0; i < n; i++){
			int p,d1,d2;
			cin>>p>>d1>>d2;
			int sum=d1+d2;
			if(maxNum<sum){
				maxNum=sum;
				idx=p;
			}
		}
		cout<<idx<<" "<<maxNum<<endl;
	}

	return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int ii = 0; ii < n - 1; ii++) {
		cout << a[ii] << " ";
	}
	cout << a[n - 1] << endl;
	int v;
	for (int i = 1; i < n; i++) {
		v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;

		for (int ii = 0; ii < n - 1; ii++) {
			cout << a[ii] << " ";
		}
		cout << a[n - 1] << endl;
	}

}


Measured memory_bytes: 3092
#include<cstdio>

using namespace std;

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

int main(){
    int n;
    scanf("%d", &n);
    int a[n+1];
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
    }
    int cost = 0;
    for(int i = 1; i <= n; i++){
        cost += abs(a[i-1] - a[i]);
    }
    cost += abs(a[0] - a[n]);
    
    for(int i = 1; i < n; i++){
        int ans = cost;
        ans -= abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]);
        ans += abs(a[i-1] - a[i+1]);
        printf("%d\n", ans);
    }
    int ans = cost;
    ans -= abs(a[n-1] - a[n]) + abs(a[0] - a[n]);
    ans += abs(a[n-1] - a[0]);
    printf("%d\n", ans);
    
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


struct UnionFind
{
    vector<int> par;
    vector<int> s;
    
    UnionFind(int N) : par(N), s(N){
        rep(i, N) par[i] = i;
        rep(i, N) s[i] = 1;
    }
    
    int root(int x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[rx] += s[ry];
        s[ry] = s[rx];
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        int rx = root(x);
        return s[rx];
    }
};

int main(){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> edges(M);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--;b--;
        edges[i] = {a, b};
    }
    
    int ans = 0;
    rep(i, M){
        UnionFind tree(N);
        rep(j, M){
            if(i != j)tree.unite(edges[j].first, edges[j].second);
        }
        if(tree.size(0) != N)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
W,H,x,y,r = [int(i) for i in input().split()]

if x-r < 0 or x+r > W:
    print("No")

elif y-r < 0 or y+r > H:
    print("No")

elif x < r:
    print("No")

elif y < r:
    print("No")

else:
    print("Yes")

Measured memory_bytes: 7720