akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    char temp;
    int ans = 0;
    for(int i=0;i<4;i++){
        cin >> temp;
        if(temp=='+')ans++;
        else ans--;
    }
    cout << ans << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
/*FUNC*/
//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

ll nPr(ll n,ll r) {
    ll ans=1;
    r=n-r;
    while(n!=r) {
        ans*=n;
        --n;
    }
    return ans;
}

ll nE(ll n) {
    return nPr(n,n);
}

ll nCr(ll n,ll r) {
    if(r==0)return -1;
    else{
        if(0!=n-r&&n-r<r)r=n-r;
        return nPr(n,r)/nE(r);
    }
}

Measured memory_bytes: 256
class UnionFind(object):
    "https://www.kumilog.net/entry/union-find"
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

N, M, K = map(int, input().split(" "))


uf = UnionFind(N)
fr = {}
for _ in range(M):
    a, b = map(int, input().split(" "))
    a -= 1
    b -= 1
    uf.union(a, b)
    if fr.get(a) is not None:
        fr[a] += 1
    else:
        fr[a] = 1

    if fr.get(b) is not None:
        fr[b] += 1
    else:
        fr[b] = 1

bl = {}
for _ in range(K):
    c, d = map(int, input().split(" "))
    c -= 1
    d -= 1
    if not uf.is_same(c, d):
        continue

    if bl.get(c) is not None:
        bl[c] += 1
    else:
        bl[c] = 1

    if bl.get(d) is not None:
        bl[d] += 1
    else:
        bl[d] = 1


for i in range(N):
    s = uf.get_size(i) - 1
    s -= bl.get(i, 0)
    s -= fr.get(i, 0)
    print(s)

Measured memory_bytes: 124064
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int H,N,A[1111],B[1111],dp[1111][11111]={};

int main() {
	cin>>H>>N;
	for(int i=1;i<=N;i++)cin>>A[i]>>B[i];
	for(int i=0;i<=H;i++)dp[0][i]=1e9;
	dp[0][0]=0;
	for(int i=1;i<=N;i++)for(int j=1;j<=H;j++){
		dp[i][j]=min(dp[i-1][j],dp[i][j-1]+B[i]);
		dp[i][j]=min({dp[i][j],dp[i-1][max(j-A[i],0)]+B[i],dp[i][max(j-A[i],0)]+B[i]});
	}
	cout<<dp[N][H]<<endl;
	return 0;
}



Measured memory_bytes: 45312
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
    string s;
    getline(cin, s);
    for (int i = 0; i < s.size(); i++)
    {
        if ('a' <= s[i] && s[i] <= 'z')
            cout << (char)(s[i] - ('a' - 'A'));
        else if ('A' <= s[i] && s[i] <= 'Z')
            cout << (char)(s[i] + ('a' - 'A'));
        else
            cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 3244
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		sc.close();

		int x = Math.max(h, w);
		System.out.println((n + x - 1) / x);
	}
}


Measured memory_bytes: 21460
n = int(input())
h = list(map(int, input().split()))
 
import numpy as np
 
d = [0] * n #ex. [0, 0, 0, 0, 0, 0]
 
d[1] = np.abs(h[1] - h[0])
 
for i in range(n-2):
    d[i+2] = min(d[i] + np.abs(h[i+2] - h[i]), d[i+1] + np.abs(h[i+1] - h[i+2]))
    
print(d[n-1])
    
 

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


int main()
{
	int sec, B, time;
	cin >> sec >> B >> time;

	int count=0;

	if (time >= sec) {

		for (int i = sec; i < time + 0.5; i += sec) {

			count += B;
			
		}
	}
	else B = 0;

	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long
#define pb push_back 
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<ll>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl;
#define cno cout << "No" << endl;
#define mod 1000000007
#define mod2 998244353
#define INT_MAX1 900000000
//////////////////////////////////////////////////////////////////////////////////////////////

int dp[1001][1001];
bool v[1001][1001];
int n,m;
string arr[1001];

int s1(int i, int j)
{
    if(i>=n or j>=m or arr[i][j]=='#')
        return 0;
    if(i==n-1 and j==m-1)
        return 1;
    if(v[i][j])
        return dp[i][j];
    v[i][j] = 1;
    return dp[i][j] = (s1(i,j+1)+s1(i+1,j))%mod;
}

void solve()
{
    cin >> n >> m;
    inp(arr,n);
    cout << s1(0,0) << endl;
}

 
int32_t main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 10240
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
 
typedef int long long ll;
using namespace std;

int n = 0 ;


int main(){
    cin >> n;
    ll ans = 0;
    vector<int> a(n,0) ;
    vector<int> b(n,0) ;
    vector<int> c(n,0) ;
    
    rep(i,n) cin >> a[i] ;
    rep(i,n) cin >> b[i] ;
    rep(i,n) cin >> c[i] ;

    sort(ALL(a)) ;
    sort(ALL(b)) ;
    sort(ALL(c)) ;

    rep(i,n) {
        ans += (c.end() - upper_bound(ALL(c),b[i]))*(lower_bound(ALL(a),b[i]) - a.begin());
        // cout << b[i] << " " << (c.end() - up) << " " << (down - a.begin()) << endl;
    }

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

Measured memory_bytes: 4588
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const double EPS = 1e-7;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<double> x(n), y(n), z(n), r(n);
    vector<int> l(n);
    rep(i, 0, n){
        cin >> x[i] >> y[i] >> z[i] >> r[i] >> l[i];
    }
    rep(i, 0, q){
        double sx, sy, sz, dx, dy, dz;
        cin >> sx >> sy >> sz >> dx >> dy >> dz;
        int tm = 100000;
        vector<bool> f(n);
        rep(j, 0, tm + 1){
            double nx = sx + (dx - sx) * (double)j / (double)tm;
            double ny = sy + (dy - sy) * (double)j / (double)tm;
            double nz = sz + (dz - sz) * (double)j / (double)tm;
            rep(k, 0, n){
                if(f[k]) continue;
                double dist = pow(nx - x[k], 2) + pow(ny - y[k], 2) + pow(nz - z[k], 2);
                if(r[k] * r[k] - dist > -EPS){
                    f[k] = true;
                }
            }
        }
        int ans = 0;
        rep(j, 0, n) if(f[j]) ans += l[j];
        cout << ans << endl;
    }
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
int ans[100005];
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int k=min(j-i,abs(x-i)+abs(y-j)+1);
           // cout<<k<<'\n';
            ans[k]++;
        }
    }
    for(int i=1;i<=n-1;i++)
    cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define REP(i,n)  for(int i=0;i<(n);i++)

int main() {
    int k,t,maxa=0;
    cin>>k >>t;
    VI a(t);
    for(int i=0;i<t;i++){
        cin>>a[i];
        if(a[i]>maxa)maxa=a[i];
    }
    cout<<max(maxa-1-(k-maxa),0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N, L;
    cin >> N >> L;
    string S[N];
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(&S[0], &S[N]);
    for(string &s:S) {
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;cin.hasNext();){
			int a=cin.nextInt();
			int b=cin.nextInt();
			Map<Integer,Integer>map=new HashMap<Integer,Integer>();
			int cnt=-1;
			while(true){
				cnt++;
//				System.out.println(a+" "+b);
				int div=a/b;
				int mod=a%b;

				if(cnt!=0)
				System.out.print(div);
				if(mod==0){
					System.out.println();
					break;
				}				
				if(map.containsKey(mod)){
					System.out.println();
					for(int i=0;i<map.get(mod);i++){
						System.out.print(" ");
					}
					for(int i=0;i<cnt-map.get(mod);i++){
						System.out.print("^");
					}
					System.out.println();
//					System.out.println(map.get(mod)+" "+cnt);
					break;
				}
				
				map.put(mod,cnt);
				a = mod*10;
			}
		}
	}

}

Measured memory_bytes: 23740
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll a[5]={};
ll r=0;
rep(i,3){
cin >> r;
a[r]++;
cin >> r;
a[r]++;}
sort(a,a+5);
if(a[1]==1&&a[2]==1&&a[3]==2&&a[4]==2){
cout << "YES" << endl;}
else{
cout << "NO" << endl;}}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long ans = -1e18;
  ans = max(ans, a * c);
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
S = input()
n = len(S)-1
ans = 0
for i in range(2**n):
    add = 1
    expr = list(S)
    for j in range(n):
        if ((i >> j) & 1):
            expr.insert(j+add, "+")
            add += 1
    ans += eval("".join(expr))
print(ans)


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    agc026a()
}

fun agc026a() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toInt() }

    val count = mutableListOf(1)
    var before = aList.first()
    for (i in 1..aList.lastIndex) {
        if (aList[i] == before) count[count.lastIndex]++ else {
            count.add(1)
            before = aList[i]
        }
    }

    val answer = count.map { it / 2 }.sum()

    println(answer)
}


Measured memory_bytes: 36416
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 1000001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair 
#define ll long long
#define ull unsigned ll 
#define pb push_back
#define db double
int read()
{
	int x=0,f=1;char ch=gc;
	while(!isdigit(ch)){ch=gc;if(ch=='-')f=-1;}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int main()
{  
   int a=rd,b=rd,c=rd;
   print(a+b+c+max(max(a,b),c)*9);puts(" ");
	return 0;
}

Measured memory_bytes: 256
inputABT = input().split()     #数値を入力

#a,b,tの値をそれぞれに代入
a = float(inputABT[0])
b = inputABT[1]
t = float(inputABT[2])


end =  t + 0.5    #終了時刻を算出
second = 1    #秒数のカウント
biscuit = 0    #ビスケットの枚数

while second * int(a) < end:    #secondが終了時刻になるまで繰り返す
    second += 1
    biscuit += int(b)


print(biscuit)


Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a * 500 + b * 100 + c * 50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 3064
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
    ll n;
    string s;
    std::cin >> n>>s;
    
    ll rc = 0;
    
    string c = "L";
    for (int i = 1; i < n*2; i++) {
        if(s[i]!=s[i-1]){
            if(c[i-1]=='R'){
                c += 'R';
                rc++;
            }else{
                c += 'L';    
            }
        }else{
            if(c[i-1]=='R'){
                c += 'L';
            }else{
                c += 'R';
                rc++;
            }
        }
    }
    if(s[0]=='W'){
        std::cout << 0 << std::endl;
        return 0;
    }

    if(rc!=n){
        std::cout << 0 << std::endl;
        return 0;
    }
    if(c[2*n-1]=='L'){
        std::cout << 0 << std::endl;
        return 0;
    }
    rc = 0;
    ll ans = 1;

    for (int i = 2*n-1; i >=0; i--) {
        if(c[i]=='R'){
            rc++;
        }else{
            if(rc==0){
                std::cout << 0 << std::endl;
                return 0;
            }
            ans *= rc;
            rc--;
            ans %= MOD;
        }
    }

    for (int i = 0; i < n; i++) {
        ans *= i+1;
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}

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

int main()
{
	int s,w;
	cin >> s >> w;
	if(s <= w)
		cout << "unsafe";
		else cout << "safe";
	return 0;
}

Measured memory_bytes: 3596
from itertools import*
n = int(input())
s = input()
b, w = [list(accumulate([0] + list(map(int, s.translate(str.maketrans("#.","10"[::p]))))[::p]))[::p] for p in [1,-1]]
m = float("inf")
for i in range(-~n):
    m = min(m, b[i] + w[i])
print(m)

Measured memory_bytes: 21532
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int b[n-1];
  unsigned long long int sum=0;
  for(int i=0;i<n-1;i++)
          cin >> b[i];
  for(int i=0;i<n-2;i++)
  {
          sum+=min(b[i],b[i+1]);  
  }
  if(n-2>0)
      sum+=b[n-2];
      
  sum+=b[0];
  if(n==2)
          sum=2*b[0];
  cout << sum << endl;
  return 0;
}

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

using namespace std;
#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

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

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int n; cin >> n;
    vector<P> up, down;
    int total = 0;
    REP(i, n) {
        string s; cin >> s;
        int mi = 0, sum = 0;
        REP(j, SZ(s)) {
            sum += s[j] == '(' ? 1 : -1;
            chmin(mi, sum);
        }
        if (sum > 0) {
            up.emplace_back(mi, abs(sum));
        } else {
            down.emplace_back(mi - sum, abs(sum));
        }
        total += sum;
    }
    if (total != 0) {
        cout << "No" << endl;
        return 0;
    }
    sort(up.rbegin(), up.rend());
    sort(down.rbegin(), down.rend());

    bool valid = true;
    int sum;
    sum = 0;
    for (auto& tp : up) {
        if (tp.first + sum < 0) {
            valid = false;
        }
        sum += tp.second;
    }

    sum = 0;
    for (auto& tp : down) {
        if (tp.first + sum < 0) {
            valid = false;
        }
        sum += tp.second;
    }

    cout << (valid ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 11228
N,K,Q = map(int, input().split())
A = [int(i) for i in input().split()]
S = sorted(A)+[0]
A+=[0]
ans =[]
for i in range(N):
    if S[i]==S[i+1]:
        continue
    mi = S[i]
    L =[]
    kou=[]
    for y in range(N+1):
        if A[y]>=mi:
            kou.append(A[y])
        elif len(kou)<K:
            kou =[]
        else:
            L+=sorted(kou)[:len(kou)-K+1]
            kou =[]
    if len(L)<Q:
        continue
    L.sort()
    ans.append((L[Q-1]-mi))
print(min(ans))

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

/* */

int main(){
    // 入力スタンダード
    int n,m;
    cin >> n >> m;

    // 入力スタンダード（複数指定）
    vector<int> a;
    int sum = 0;
    for(int i=0; i<n; i++) {
        int ai;
        cin >> ai;
        a.push_back(ai);
        sum += ai;
    }
    // ***************************************
    sort(a.begin(), a.end(), greater<int>());

    int c = 0;
    for(int i=0; i<n; i++){
        if(a.at(i)*4*m >= sum){
            c++;
            if(c>=m){
                cout << "Yes" << endl;
                return 0;
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long x,y,count=0;
	
		count=0;
		scanf("%lld%lld",&x,&y);
	if(fabs(x)==fabs(y))
	{
		if(x*y<0)
		count++;
		//printf("%d\n",count);
	}
	if(fabs(x)<fabs(y))
	{
		count+=fabs(y)-fabs(x);
		if(x<0)
		{
			count++;
			if(y<0)
			count++;
		}
		else
		{
			if(y<0)
			count++;
		}
	}
	if(fabs(x)>fabs(y))
	{
		count+=fabs(x)-fabs(y);
		if(x>0)
		{
			count++;
			if(y>0)
			count++;
		}
		else
		{
			if(y>0)
			count++;
		}
	}
	printf("%lld\n",count);
	
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int H[N];

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        if (H[i] >= K)
        {
            cnt++;
        }
    }

    cout << cnt << endl;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0;i < s.size();i++){
        s[i] = (s[i] + n - 'A')%26 + 'A';
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char c[101][101];
int d[101][101];
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			cin>>c[i][o];
			if(c[i][o]=='#')
			{
				d[i][o]=-100;
				d[i+1][o]+=1;
				d[i+1][o+1]+=1;
				d[i+1][o-1]+=1;
				d[i][o+1]+=1;
				d[i][o-1]+=1;
				d[i-1][o]+=1;
				d[i-1][o+1]+=1;
				d[i-1][o-1]+=1;
			}
		}
	}
	for(int i=1;i<=a;i++)
	{
		for(int o=1;o<=b;o++)
		{
			if(d[i][o]<0)
				cout<<"#";
			else
				cout<<d[i][o];
		}
		cout<<"\n";
	}
}

Measured memory_bytes: 384
#include <stdio.h>

typedef struct point{
  int x;
  int y;
}Point;

int check(Point* p1, Point* p2, Point* p3);

int main(void){
  int x,y;
  Point p1,p2,p3,pstart,pnext;
  int n;
  int retval=1;

  scanf("%d",&n);
  scanf("%d %d",&x,&y);
  p1.x=x;
  p1.y=y;
  pstart.x=x;
  pstart.y=y;
  scanf("%d %d",&x,&y);
  p2.x=x;
  p2.y=y;
  pnext.x=x;
  pnext.y=y;
  for(int i=2;i<n;i++){
    scanf("%d %d",&x,&y);
    p3.x=x;
    p3.y=y;
    if(check(&p1,&p2,&p3)==1){
      retval=0;
    }
    p1=p2;
    p2=p3;
  }

  if(check(&p1,&p2,&pstart)==1){
    retval=0;
  }
  if(check(&p2,&pstart,&pnext)==1){
    retval=0;
  }
  printf("%d\n",retval);
  return 0;
}

int check(Point* p1, Point* p2, Point* p3){
  int v1x,v1y,v2x,v2y;
  int z;
  v1x=p3->x-p2->x;
  v1y=p3->y-p2->y;
  v2x=p1->x-p2->x;
  v2y=p1->y-p2->y;
  z=v1x*v2y-v1y*v2x;
  //printf("%d %d %d %d %d %d %d\n",p1->x,p1->y,p2->x,p2->y,p3->x,p3->y,z);
  if(z>=0){
    return 0;
  }
  else{
    return 1;
  }
}



Measured memory_bytes: 2132
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, b; cin >> n >> a >> b;
	cout << max(n, max(a, b)) * 10 + a + b + n - max(n, max(a, b)) << endl;
	cin >> n;
}

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

long long dp[100001];

long long fun(vector<vector<int> >&g, int i)
{
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    vector<int>:: iterator it;
    it=g[i].begin();
    long long maxi=INT_MIN;
    while(it!=g[i].end())
    {
        maxi=max(maxi, fun(g, *it));
        it++;
    }
    dp[i]=1+maxi;
    return dp[i];
}
int main()
{
    int n, m, x, y;
    cin>>n>>m;
    memset(dp, -1, sizeof(dp));
    vector<vector<int> >g(n+1);
    for(int i=0;i<m;i++)
    {
        cin>>x>>y;
        g[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
    {
        if(g[i].size()==0)
        {
            dp[i]=0;
        }

    }
    long long ans=INT_MIN;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans, fun(g, i));
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 8576
#include <iostream>
using namespace std; 
typedef long long ll;
 int main(void)
 { ll H,W; 
  cin >> H >> W;
 if(H == 1 || W == 1)
 {  cout << 1 << endl;  }
  else 
  {  cout << (H * W + 1) / 2 << endl;  }
 return 0; }



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;

int main() {
  int a,b,c,k; cin>>a>>b>>c>>k;
  for(int x = 0; x <= k; x++) {
    // A„ÇíxÂõû2ÂÄç
    for(int y = 0; y <= k-x; y++) {
      // B„ÇíyÂõû2ÂÄç
      int z = k - x - y;

      // „ÇÑ„Çã
      int na = a * pow(2, x);
      int nb = b * pow(2, y);
      int nc = c * pow(2, z);
      if (nb > na && nc > nb) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No";
}


Measured memory_bytes: 3968
from itertools import accumulate

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

A.sort()
S=list(accumulate(A))
S.sort(reverse=True)
A.sort(reverse=True)

ans=1

for i in range(1,N):
  cnt=S[i]
  if S[i]*2 >= A[i-1]:
    ans+=1
  else:
    break

print(ans)

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

int main(void)
{
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0;i < n;i++) cin >> x[i];

    int ans = 0;
    for (int i = 0;i < n;i++)
    {
        ans += 2 * min(x[i], k - x[i]);
    }

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


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<string> str_v(N);
  for(int i=0;i<N;++i){
    cin>>str_v[i];
  }
  
  ll ans=0;
  map<string,int> mp;
  for(int i=0;i<N;++i){
    sort(str_v[i].begin(),str_v[i].end());
    ans+=mp[str_v[i]];
    ++mp[str_v[i]];
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 18176
//
#include<iostream>
using namespace std;
#define maxnn 5000
#define mod 1000000007
#define ll long long 
#define lowbit(i) i&(-i)
ll m,d;
ll c[maxnn];
ll n,k;
ll a[maxnn];
void add(ll x)
{
	for(ll i=x;i<=4010;i+=lowbit(i))
	{
		c[i]++;
	}
}
ll get(ll x)
{
	ll ans=0;
	for(int i=x;i;i-=lowbit(i))
	{
		ans+=c[i];
	}
	return ans;
}
ll ksm(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans%mod;
}
int main()
{
	cin>>n>>k;
	ll tot=0;
	ll tot1=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]; a[i]++;
		tot=tot+get(2001)-get(a[i]);
		tot1+=get(a[i]-1);
		add(a[i]);
	}
	ll tot2=0;
	ll tmp=0;
	ll ans=tot%mod;
	ll aaa=((k*(k-1)%mod)*(ksm(2,mod-2)%mod))%mod;
	ll aans=(((k*(k+1)%mod)%mod)*(ksm(2,mod-2)%mod))%mod;
	ll o=((((ans%mod)*(aans%mod))%mod+(aaa*tot1))%mod); 
	cout<<o%mod;
}


Measured memory_bytes: 256
def g(N):
 d=[]
 for i in range(1,int(N**0.5)+1):
  if N%i==0:
   d.append(i)
   d.append(N//i)
 return sorted(d)
d=g(int(input()))
n,m=d[len(d)//2-1:len(d)//2+1]
print(n+m-2)

Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e6 + 9;

ll z[N], a[N], b[N];
vector<ll> va, vb;

vector<ll> vv;

void Z() {
	for(ll it: vb)
		vv.push_back(it);
	vv.push_back(-1); // invalid number like $
	for(ll it: va)
		vv.push_back(it);
	for (ll i = 1, l = 0, r = 0; i < (int)vv.size(); ++i) {
		if(i <= r)
			z[i] = min(r - i + 1, z[i - l]);
		while(i + z[i] < (int)vv.size() && vv[i + z[i]] == vv[z[i]])
			++z[i];
		if(i + z[i] - 1 > r) {
			r = i + z[i] - 1;
			l = i;
		}
	}
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 1; i < n + n; ++i) {
		if(i >= n)
			a[i] = a[i - n];
		va.push_back(a[i] ^ a[i - 1]);
	}
	va.push_back(a[0] ^ a[n - 1]);
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		if(i)
			vb.push_back(b[i] ^ b[i - 1]);
	}
	vb.push_back(b[0] ^ b[n - 1]);
	Z();
	for (int i = n + 1; i <= n + n; ++i) {
		if(z[i] == n)
			cout << i - n - 1 << ' ' << (a[i - n - 1] ^ b[0]) << '\n';
	}
	return 0;
}


Measured memory_bytes: 32232
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};

  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

  bool strCreatable = 1;
  for (int i = 0; i < S.size();) {
    bool substrCreatable = 0;
    for (int j = 0; j < 4; j++) {
      string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        substrCreatable = 1;
        i += d.size();
      }
    }
    if (!substrCreatable) {
      strCreatable = 0;
      break;
    }
  }

  cout << (strCreatable ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
 
#define N 100005
#define NIL -1
 
struct Node{ int p, l, r;};
struct Node T[N];

void inorder(int u){
  if(u != NIL){
    inorder(T[u].l);
    printf(" %d",u);   
    inorder(T[u].r); 
  }
}
void preorder(int u){
  if(u != NIL){
    printf(" %d",u);  
    preorder(T[u].l);
    preorder(T[u].r);
  }
}
void postorder(int u){
  if(u != NIL){
    postorder(T[u].l);
    postorder(T[u].r);
    printf(" %d",u);
  }
}
  
int main(int argc,char *argv[]){
  int i, v,n;    
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
      T[i].p = T[i].l = T[i].r = NIL;
    }
    for ( i = 0; i < n; i++ ){
      scanf("%d",&v);
      scanf("%d %d",&T[v].l,&T[v].r);   
      T[T[v].l].p = v;
      T[T[v].r].p = v;
    }
      
      
    printf("Preorder\n");
    for(i=0; i<n; i++){
      if(T[i].p == NIL)
      preorder(i);
    }
    printf("\nInorder\n");
    for(i=0; i<n; i++){
      if(T[i].p == NIL)
      inorder(i);
    }
    printf("\nPostorder\n");
    for(i=0; i<n; i++){ 
      if(T[i].p == NIL)
      postorder(i);
    }
    printf("\n");
     
    return 0;  
}

Measured memory_bytes: 616
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}
Int MOD = 1000000000+7;

int main() {
    Int H,N;
    cin >> H >> N;
    vector<pii> magics;
    mapii max_b;

    rep(i,N){
        Int a,b;
        cin >> a >> b;
        magics.emplace_back(make_pair(a,b));
    }

    sort(magics.begin(),magics.end());

    vi HP = vi(H+1,10000000000LL);

    HP[1] = magics[0].second;

    REP(i,1,H+1){
        rep(j,N){
            int cand;
            if(i<=magics[j].first){
                HP[i] = min(HP[i], magics[j].second);
            }else{
                cand = i-magics[j].first;
                HP[i] = min(HP[i], HP[cand]+magics[j].second);
            }


        }
    }

    cout << HP[H] << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stack>
using namespace std;
#define N 100010
#define LL long long
int a[N];
stack<int> p,q;
int main()
{
    int i,j,k,n,x,y;
    int x1,x2,y1,y2;
    LL s;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    p.push(a[0]);
    q.push(a[n-1]);
    s=a[n-1]-a[0];
    x=1;
    y=n-2;
    while(x<=y)
    {
        x1=abs(a[x]-p.top());
        x2=abs(a[x]-q.top());
        y1=abs(a[y]-p.top());
        y2=abs(a[y]-q.top());
        if(x1>=x2&&x1>=y1&&x1>=y2)
        {
            s=s+x1;
            p.push(a[x]);
            x++;
        }
        else
        if(x2>=x1&&x2>=y1&&x2>=y2)
        {
            s=s+x2;
            q.push(a[x]);
            x++;
        }
        else
        if(y1>=x1&&y1>=x2&&y1>=y2)
        {
            s=s+y1;
            p.push(a[y]);
            y--;
        }
        else
        if(y2>=x1&&y2>=x2&&y2>=y1)
        {
            s=s+y2;
            q.push(a[y]);
            y--;
        }
    }
    printf("%lld\n",s);
    return 0;
}


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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 110;
int n, K, m;
bool f[N][N];

bool ok(){
    memset(f, 0, sizeof(f));
    for(int x=1; x<n; x++){
        int y = n - x;
        int c = x*(x-1)/2 + y*(y-1)/2;
        if(c >= K){
            m = 0;
            for(int i=1; i<=x; i++){
                for(int j=x+1; j<=n; j++){
                    f[i][j] = 1;
                    m++;
                }
            }
            for(int i=1; i<=x && c>K; i++){
                for(int j=i+1; j<=x && c>K; j++){
                    f[i][j] = 1;
                    m++;
                    c--;
                }
            }
            for(int i=1; i<=y && c>K; i++){
                for(int j=i+1; j<=y && c>K; j++){
                    f[i+x][j+x] = 1;
                    c--;
                    m++;
                }
            }
            return 1;
        }
    }
    return 0;
}

int main(){
    while(~scanf("%d %d", &n, &K)){
        if(ok()){
            printf("%d\n", m);
            for(int i=1; i<=n; i++){
                for(int j=i+1; j<=n; j++){
                    if(f[i][j]){
                        printf("%d %d\n", i, j);
                    }
                }
            }
        } else {
            puts("-1");
        }
    }
    return 0;
}


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

bool table[1000][1000][1000]{false};

int main(){

    int n,p[3],count=0;

    cin >> n;

    for(int i=0;i<n;i++){
      cin >> p[0] >> p[1] >> p[2];
      sort(p,p+3);
      if(!table[p[0]][p[1]][p[2]]){
        table[p[0]][p[1]][p[2]] = true;
      }
      else{
        count++;
      }
    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 6984
#include <iostream>
using namespace std;
int n,count;
int a[300000];

void check(){
	int d=8;
	a[0]=6;
	count=1;
	int i;
	while(d<300000){
		for(i=0;i<count;i++){
			if(d%a[i]==0)break;
		}
		if(i==count){
			a[count]=d;
			count++;
		}
		if(d%7==6){
			d+=2;
		}else{
			d+=5;
		}
	}
	//i=0;
	//while(i<count){
	//	cout <<a[i]<<endl;
	//	i++;
	//}
}

int main(){
	check();
	//cout <<"ok"<<endl;
	while(1){
		cin >>n;
		if(n==1)break;
		cout<<n<<":" ;
		int i=0;
		while(a[i]<=n&&i<count){
			if(n%a[i]==0)cout<<" " <<a[i];
			i++;
		}
		cout <<endl;
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int n, i;
vector<int> h(N);
int dp[N];

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                cin>>n;
                for(i = 1; i<=n; i++) {
                        cin>>h[i]; dp[i] = 0;
                }
                dp[1] = 0; dp[2] = abs(h[2] - h[1]);
                for(i = 3; i<=n; i++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
                cout<<dp[n]; 
        }
        return 0;
}

Measured memory_bytes: 3936
import sys
readline = sys.stdin.readline
import math

def main():
    N = int(readline())
    D, X = map(int, readline().rstrip().split())
    for _ in range(N):
        a = int(readline())
        X += math.floor((D-1) / a + 1)

    print(X)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
const int inf=0x3f3f3f3f;
int n,k;
char s[10000];
int a[1000];
int main()
{
    //freopen("/Users/zilongzhang/Desktop//l.txt","r",stdin);
    while(scanf("%d",&n)!=-1)
    {
        double sum=0;
        for(int i=1;i<=n;i++) {
            scanf("%d", &a[i]);
            sum+=1.0/a[i];
        }
        printf("%.5lf\n",1.0/sum);
    }
    return 0;
}

Measured memory_bytes: 256
#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);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  int n;
  string s;
  while(cin >> n >> s){
    bool ans = false;

    if(n % 2 == 0){
      if(s.substr(0,n/2) == s.substr(n/2,n/2)) ans = true;
      
    }

    cout << (ans ? "Yes" : "No") << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

double pq;
int a,n;
int ans = 0;

void dfs(int t, double sum, int pi, int prev){
    if(t > n || sum > pq + EPS) return;
    if(abs(sum - pq) < EPS){
        ans++;
        return;
    }
    for(int i = prev; i * pi <= a; i++){
        dfs(t+1, sum + 1.0/i, pi * i, i);
    }
}

int main(void) {
    int i,j;
    int p,q;
    while(cin >> p >> q >> a >> n, p){
        pq = (double)p/q;
        ans = 0;
        loop(i,1,a+1){
            dfs(1,1.0/i,i,i);
        }
        cout << ans << endl;
    }
}



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

inf = float('inf')

def solve(N: int, x: "List[int]", y: "List[int]", d: "List[str]"):
    D_xmin = [inf for dd in [-1, 0, 1]]
    D_xmax = [-inf for dd in [-1, 0, 1]]
    D_ymin = [inf for dd in [-1, 0, 1]]
    D_ymax = [-inf for dd in [-1, 0, 1]]
    trans_x = {'U': 1, 'D': 1, 'L': 0, 'R': 2}
    trans_y = {'U': 2, 'D': 0, 'L': 1, 'R': 1}
    
    for xx, yy, dd in zip(x, y, d):
        D_xmin[trans_x[dd]] = min(D_xmin[trans_x[dd]], xx)
        D_xmax[trans_x[dd]] = max(D_xmax[trans_x[dd]], xx)
        D_ymin[trans_y[dd]] = min(D_ymin[trans_y[dd]], yy)
        D_ymax[trans_y[dd]] = max(D_ymax[trans_y[dd]], yy)
    
    ts = [0]
    for D in [D_xmin, D_xmax, D_ymin, D_ymax]:
        ts.append(D[0] - D[1])
        ts.append(D[1] - D[2])
        ts.append((D[0] - D[2]) / 2)

    res = inf
    for t in ts:
        if t < 0:
            continue
        xmin = min(D_xmin[0] - t, D_xmin[1], D_xmin[2] + t)
        xmax = max(D_xmax[0] - t, D_xmax[1], D_xmax[2] + t)
        ymin = min(D_ymin[0] - t, D_ymin[1], D_ymin[2] + t)
        ymax = max(D_ymax[0] - t, D_ymax[1], D_ymax[2] + t)
        res = min(res, (xmax - xmin) * (ymax - ymin))

    print(res)
    return


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

if __name__ == '__main__':
    main()


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,t;
  cin >> a>>b>>t;
  int x=0;
  int n;
  for(int i = 0; x <= t+0.5; i++){
    x += a;
    n = i;
  }
  cout << b*n <<endl;

  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    A, B, C = inm()
    K = ini()
    while B <= A:
        B *= 2
        K -= 1
    while C <= B:
        C *= 2
        K -= 1
    if K < 0:
        return False
    return True


print("Yes" if solve() else "No")



Measured memory_bytes: 9200