akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#define lowbit(x) ((x) & -(x))
#define EB emplace_back
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define maxn 1005
using namespace std;

struct DSU {
    vector<int> s, p;
    DSU(int sz) : s(sz + 1, 1), p(sz + 1, -1) {}
    int find(int x) {
        return (p[x] == -1) ? x : (p[x] = find(p[x]));
    }
    bool join(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(s[x] < s[y]) swap(x, y);
        s[x] += s[y]; p[y] = x;
        return true;
    }
    int cnt() {
        int ret = 0;
        for(int i = 1; i < SZ(p); i++) {
            if(p[i] == -1) ret++;
        }
        return ret;
    }
};

int mx[4] = {0, 0, -1, 1};
int my[4] = {-1, 1, 0, 0};
char mp[maxn][maxn];
int id[maxn][maxn];
int n, m;

bool cool(int i, int j) {
    if(i < 0 || i >= n) return false;
    if(j < 0 || j >= m) return false;
    return mp[i][j] == '#';
}

int solve() {
    int R = 0, C = 0;
    for(int i = 0; i < n; i++) {
        int cnt = 0;
        if(mp[i][0] == '#') cnt++;
        if(mp[i][m - 1] == '#') cnt++;
        for(int j = 1; j < m; j++) {
            if(mp[i][j - 1] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) R++;
    }
    for(int j = 0; j < m; j++) {
        int cnt = 0;
        if(mp[0][j] == '#') cnt++;
        if(mp[n - 1][j] == '#') cnt++;
        for(int i = 1; i < n; i++) {
            if(mp[i - 1][j] != mp[i][j]) cnt++;
        }
        if(cnt > 2) return -1;
        if(cnt) C++;
    }
    if((R + C) > 0 && (R != n || C != m)) return -1;
    DSU loli(n * m);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(mp[i][j] == '.') cnt++;
            else {
                for(int k = 0; k < 4; k++) {
                    int ii = i + mx[k];
                    int jj = j + my[k];
                    if(cool(ii, jj)) {
                        loli.join(id[i][j], id[ii][jj]);
                    }
                }
            }
        }
    }
    return loli.cnt() - cnt;
}


int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    /*cin >> n >> m; int tot = 0;
    for(int i = 0; i < n; i++) {
        cin >> mp[i];
        for(int j = 0; j < m; j++)
            id[i][j] = ++tot;
    }
    cout << solve() << '\n';*/
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << '\n';
    return 0;
}










Measured memory_bytes: 256
program B;
var
  n, m: Longint;
  t, p, x: array[1..111] of Longint;
  sum, i, j: Longint;

begin
  ReadLn(n);
  for i := 1 to n do Read(t[i]);
  ReadLn(m);
  for i := 1 to m do ReadLn(p[i], x[i]);
  for i := 1 to m do
    begin
      sum := 0;
      for j := 1 to n do
        if j = p[i] then Inc(sum, x[i])
        else Inc(sum, t[j]);
      WriteLn(sum);
    end;
end.

Measured memory_bytes: 128
import sys
l = [1,0,0]
m = ['A','B','C']
for line in sys.stdin.readlines():
  line = line.replace('\n','')
  x,y = line.split(',')
  l[m.index(x)],l[m.index(y)] = l[m.index(y)],l[m.index(x)]
print(m[l.index(1)])

Measured memory_bytes: 7444
#include<cstdio>
using namespace std;
int a,b,c;
int main()
{
    scanf("%d%d%d\n",&a,&b,&c);
    for(int i=1;i<1000;i++)
    {
        if(a*i%b==c){printf("YES\n");return 0;}
    }
    printf("NO\n"); 
    return 0;
}

Measured memory_bytes: 128
if __name__ == "__main__":
	A = int(input())
	B = int(input())
	l = []
	l.append(A)
	l.append(B)
	if 1 in l:
		if 2 in l:
			print("3")
		elif 3 in l:
			print("2")
	else:
		print("1")

Measured memory_bytes: 2940
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compl(const void *a, const void *b){return (*(long*)a<*(long*)b)-(*(long*)a>*(long*)b);}

int main(void){
	int n, i, j;
	int x[50], y[50];
	scanf("%d", &n);
	if(n==1){
		puts("1");
		return EXIT_SUCCESS;
	}
	for(i=0; i<n; i++){
		scanf("%d%d", x+i, y+i);
	}
	int s[2500][2], S=0;
	for(i=0; i<n; i++){
		for(j=0; j<i; j++){
			int dx=x[i]-x[j];
			int dy=y[i]-y[j];
			if(dy<0){dx=-dx; dy=-dy;}
			if(dy==0 && dx<0){dx=-dx;}
			s[S][0]=dx;
			s[S][1]=dy;
			S++;
		}
	}
	qsort(s, S, sizeof(int)*2, compl);
	int max=0, now=1;
	for(i=1; i<S; i++){
		if(s[i][0]==s[i-1][0] && s[i][1]==s[i-1][1]){
			now++;
		}else{
			if(now>max) max=now;
			now=1;
		}
	}
	if(now>max) max=now;
	printf("%d\n", n-max);
}


Measured memory_bytes: 252
// Written By NewbieChd
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 5003, yyb = 2019;

int main() {
    int L = read(), R = read(), i, j;
    if (R - L + 1 >= yyb) {
        printf("0\n");
        return 0;
    }
    int ans = 1e9;
    L %= yyb, R %= yyb;
    if (L < R) {
        for (i = L; i < R; ++i)
            for (j = i + 1; j <= R; ++j)
                ans = min(ans, i * j % yyb);
        printf("%d\n", ans);
    }
    else
        printf("0\n");
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll n = s.size();
    map<char,ll> mp;
    for(int i = 0; i < n; i++){
        mp[s[i]]++;
    }
    ans = n*(n-1)/2;
    for(auto p:mp){
        ans -= p.second*(p.second-1)/2;
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
using namespace std;

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

typedef long long ll;

const int INF=1e9+7;

int main(){
	int n,k;
	cin>>n>>k;
	int ans=1;
	while(n--){
		ans=min(ans*2,ans+k);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<algorithm>
using namespace std;
int main()
{


        int n,c=0;
        string s;
        cin>>n;
        cin>>s;
        int i=0;
        while(i<s.length()-2)
        {
            if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
            {
                c++;
                i=i+3;
            }
            else
            {
                i++;
            }
        }
        cout<<c<<endl;

    return 0;
}


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

char a[22][22];
int w, h;
int yy[4] = {-1, 0, 0, 1}, xx[4] = {0, 1, -1, 0};
int solve(int y, int x){
	if(a[y][x] == '#')return 0;
	a[y][x] = '#';
	int ans = 0;
	for(int i = 0;i < 4;i++){
		ans += solve(y+yy[i], x+xx[i]);
	}
	return ans+1;
}

int main(){
	int y, x;
	while(cin >> w >> h, w){
		fill((char*)a, (char*)(a+22), '#');
		for(int i = 1;i <= h;i++)
		for(int j = 1;j <= w;j++){
			cin >> a[i][j];
			if(a[i][j] == '@'){y = i;x = j;}
		}
		cout << solve(y, x) << endl;
	}
	return 0;
}

Measured memory_bytes: 2948
N = int(raw_input())
num = [x.strip() for x in raw_input().split()]

cnt = 0
flg = 0
while flg == 0:
    for i in range(N):
        if int(num[i]) % 2 == 0:
            num[i] = int(num[i]) // 2
        else:
            flg = 1

    if flg == 0:
        cnt += 1
print cnt

Measured memory_bytes: 2820
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };
char s[52][52];
bool b[52][52];

signed main(){

	int H, W;
	cin >> H >> W;
	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++){
			cin >> s[i][j];
			if (s[i][j] == '#') b[i][j] = true;
			else b[i][j] = false;
		}

	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++){
			if (s[i][j] == '#'){
				if (s[i + 1][j] == '#'){
					b[i][j] = b[i + 1][j] = false;
				}
				if (s[i][j + 1] == '#'){
					b[i][j] = b[i][j+1] = false;
				}
			}
		}

	bool success = true;
	for (int i = 1; i <= H; i++)
		for (int j = 1; j <= W; j++)
			if (b[i][j] == true) success = false;


	if (success) Yes;
	else No;

	return 0;
}


Measured memory_bytes: 256
N ,M = map(int,input().split())
L = sorted(list(map(int,input().split())))

dis = [(L[i+1] - L[i],i) for i in range(M-1)]
dis1 = [L[i+1]-L[i] for i in range(M-1)]
dis = sorted(dis,key=lambda x:(x[0],-x[1]))[::-1]
l = [0]
for i in range(N-1):
    try:l.append(dis[i][1]+1)
    except:pass
#print(l,dis1)
l = sorted(l)
ans = 0
cnt = 0
for i in range(len(l)-1):
    cnt +=1
  #  print(dis1[l[i]:l[i+1]-1],l[i],l[i+1])
    ans += sum(dis1[l[i]:l[i+1]-1])
 #   print(ans)
ans += sum(dis1[l[cnt]:])
print(ans)



Measured memory_bytes: 29844
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
 
#define ALL(x) x.begin(), x.end()
using namespace std;
 
typedef vector<vector<int> > G;
const int inf = 1e9;
 
int n, m;
G graph;
vector<int> ans;
 
int visited[100100];
 
void dfs(int u){
    // cout << u << endl;
    ans.push_back(u);
    visited[u] = 1;
 
    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if( !( visited[v] ) ){
            return dfs(v);
        }
    }
    // return;
}
 
int main(void){
    cin >> n >> m;
    graph = G(n+100);
    for(int i=0; i<m; i++){
 
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
 
    }
    
    dfs(1);
    reverse(ans.begin(), ans.end());
    ans.pop_back();
    dfs(1);
 
    cout << ans.size() << endl;
 
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
 
    cout << endl;
    return 0;
}

Measured memory_bytes: 10104
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#undef DEBUG

#ifdef DEBUG
struct testdata{
    int N;
    int A[3*100000];
    int a[3*100000];
} td[] = {
    {16, {3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 4, 2, 2, 2, 2, 2}, {16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
    {7, {1,1,1,1, 1, 2, 2},{7,2,0,0,0,0,0}},
    {3, {2, 1, 2}, {3, 1, 0}},
    {5, {1, 2, 3, 4, 5}, {5, 2, 1, 1, 1}},
    {4, {1, 3, 3, 3}, {4, 1, 0, 0}},
};
#endif

int
cmp(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

void
solver(int n, int *a, int *aaa)
{
    int i, j, r;
    int A[3*100000];
    int v = 0;
    int ans;

    bzero(A, sizeof(A));

    for (i=0; i<n; i++) {
        if (A[a[i]-1]==0)
            v++;
        A[a[i]-1]++;
    }
    qsort(A, n, sizeof(int), cmp);
    printf("%d\n", n);
    ans = n;
    j = 0;
    r = n;
    for (i=2; i<n+1; i++){
//        printf("i: %d, j: %d, r: %d\n", i, j, r);
        if (r<(i-j)) {
            if (aaa!=NULL) {
                printf("0 (%d)\n", aaa[i-1]);
            }
            else {
                printf("0\n");
            }
            continue;
        }
        for (; j<n; j++) {
            //printf("       j: %d, r: %d v: %d\n", j, r, v);
            if (v==i-j) {
                ans = A[j+v-1]<n/i?A[j+v-1]:n/i;
                break;
            }
            if (v<i-j) {
                ans = 0;
                break;
            }
            if (n/i<A[j] || r/(i-j)<A[j]) {
                v--;
                r -= A[j];
            }
            else {
                ans = r/(i-j);
                break;
            }
        }        
        if (aaa!=NULL) {
            printf("%d (%d)\n", ans, aaa[i-1]);
        }
        else {
            printf("%d\n", ans);
        }
    }
}

int
main(int argc, char *argv[])
{
    int i;
    int j;
    int N;
    int A[3*100000];

#ifdef DEBUG
    for (i=0; i<5; i++) {
        printf("Test case %d\n", i+1);
        solver(td[i].N, td[i].A, td[i].a);
    }
#else
    scanf("%d", &N);
    for (i=0; i<N; i++)
        scanf("%d", A+i);
    solver(N, A, NULL);
#endif

    return 0;
}

Measured memory_bytes: 3452
#include<stdio.h>
int T,S[4*200010],N[200010];
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
//????????¢??°?????????MIN???
int hyoka(int a,int b){return (a<0||b<0)?(a<0?b:a):N[a]<N[b]?a:b;}
//?????°??¨?????????n?????°???d??§?????????????§????
void sset(int n){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<T;i++)S[T+i]=i<n?i:-1;
  for(i=T-1;i;i--)S[i]=hyoka(S[i*2],S[i*2+1]);
}
//?????°??¨???update??¢??°
//i???????????°??????n????????´???????§????
void sud(int i,int n){for(N[i+=T]=n;i/=2;)S[i]=hyoka(S[i*2],S[i*2+1]);}
//?????°??¨???find??¢??°
//[a,b)????????????????????????sout(a,b,1,0,T);
int sout(int a,int b,int i,int l,int r){//printf("%d %d %d %d %d\n",a,b,i,l,r);
  if(r<=a||b<=l)return -1;
  if(a<=l&&r<=b)return S[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}
int ta[100010],to[100010],nt[100010],r=0,fi[100010],ID[200010];
void ldfs(int s,int d){
  int i;
  N[fi[s]=r]=d;
  ID[r++]=s;
  for(i=ta[s];i+1;i=nt[i]){
    if(fi[to[i]]+1)continue;
    ldfs(to[i],d+1);
    N[r]=d;
    ID[r++]=s;
  }
}
void slca(int p){
  ldfs(p,r=0);
  sset(r);
}
int alca(int a,int b){return sout(MIN(fi[a],fi[b]),MAX(fi[a],fi[b])+1,1,0,T);}
int main(){
  int n,m,i,j,e=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)ta[i]=fi[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&m);
    while(m--){
      scanf("%d",&j);
      nt[e]=ta[i];
      to[e]=j;
      ta[i]=e++;
    }
  }
  slca(0);
  scanf("%d",&n);
  while(n--){
    scanf("%d %d",&i,&j);
    printf("%d\n",ID[alca(i,j)]);
  }
  return 0;
}

Measured memory_bytes: 11532
s = int(input())
a = int(s**(1/2))
if s == a**2:
  b =0 
  print(" ".join(map(str, [0,0,a,1,b,a])))
elif a*(a+1) - s >= 0: 
  b = a*(a+1) - s
  print(" ".join(map(str, [0,0,a+1,1,b,a])))
else:
  b = (a+1)**2 - s
  print(" ".join(map(str, [0,0,a+1,1,b,a+1])))

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll n1,ll n2)
{
ll r;
   while(n2!=0)
   {
       r=n1%n2;
       n1=n2;
       n2=r;
   }
  return n1;

}

int main()
{
    ll t,i,j,k=0,q,p,x,y,n,a,b,c,d;
    cin>>a>>b>>c>>d;
    k=max(a*c,max(a*d,max(b*c,b*d)));
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3632
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ADayOfTakahashi {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    int res = a;
	    if(b < a) res--;
	    out << res << endl;
	}
};


int main() {
	ADayOfTakahashi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
///age yekam bekeshi beham is no problem ._.
#include<bits/stdc++.h>
#define size(a) (int)a.size()
#define ld long double
#define int long long
#define F first
#define S second
#define pb push_back
using namespace std;
void null(){return ;}
const int maxn=1e5+7,INF=3e18+9237,mod=1e9+7;

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a,b;cin>>a>>b;
	if(a<=0&&b>=0)return cout<<"Zero",0;
	if(a>0)return cout<<"Positive",0;
	if(b<0){
		if(abs(a-b)%2==0)cout<<"Negative";
		else cout<<"Positive";
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int H, W;
    cin >> H >> W;
    vector<string> vec(H);
    REP(i, H) cin >> vec[i];
    
    // calculation
    REP(i, H) {
        cout << vec[i] << "\n";
        cout << vec[i] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main()
{
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  int sum=a+b+c;
  
  if(sum==17)
  {
    if(a==5&&b==5)
    {
      printf("YES\n");
    }
    else if(a==5&&c==5)
    {
      printf("YES\n");
    }
    else if(b==5&&c==5)
    {
      printf("YES\n");
    }
    else
    {
      printf("NO\n");
    }
  }
   else
  {
    printf("NO\n");
  }
  
  return 0;
}


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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


template<class T>
vector<int> ZAlgorithm(const T& src) {
  vector<int> A(src.size());
  A[0] = src.size();
  int i = 1, j = 0;
  while (i < src.size()) {
    while (i + j < src.size() && src[j] == src[i + j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue; }
    int k = 1;
    while (i + k < src.size() && k + A[k] < j) A[i + k] = A[k], ++k;
    i += k; j -= k;
  }
  return move(A);
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;

  int result = 0;
  while (S.size()) {
    auto zs = ZAlgorithm(S);
    F0R(i, zs.size()) {
      chmax(result, min(zs[i], i));
    }
    S.erase(S.begin());
  }
  cout << result;
}
#endif


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

//flag?????¨????????????????????????
int bubbleSort(int A[], int N) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i ++) {
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--) {
			if ( A[j] < A[j -1]) {
			//??£???????´????????????????
			swap(A[j],A[j - 1]);
			flag = 1;
			sw++;
			}
		}
	}
	return sw;
}

int main() {
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	sw = bubbleSort(A, N);

	for (int i = 0; i < N; i ++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;

	return 0;
}

Measured memory_bytes: 3104
#include <iostream>

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

    auto former_half = (M + 1) / 2;
    auto latter_half = M - former_half;
    for (auto first = former_half, second = first + 1; first > 0; first--, second++) {
        std::cout << first << ' ' << second << std::endl;
    }

    for (auto first = former_half * 2 + latter_half, second = first + 2; first > former_half * 2; first--, second++) {
        std::cout << first << ' ' << second << std::endl;
    }

    return 0;
}


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

int main()
{
    ll n,d,i,j,cnt=0,s=0,a[100][100],x,k;

    cin>>n;
    cin>>d;

    for(i=1; i<=n; i++)
    {
        for(j=1; j<=d; j++)
        {
            cin>>a[i][j];
        }
    }

    for(i=1; i<=n-1; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            for(k=1; k<=d; k++)
            {
                s+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
            }
            x=sqrt(s);
            if(s==(x*x))
            {
                cnt++;
            }
            s=0;
        }
    }

    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] argv) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		int a = scan.nextInt();
		int b = scan.nextInt();
		String u = scan.next();

		if (u.equals(s)) a--;
		if (u.equals(t)) b--;

		System.out.println(a + " " + b);

		scan.close();
	}
}

Measured memory_bytes: 22100
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	a(x,3,x)
	for t in r(30):b(p:=i+t+30);a(q:=p+1,3,q);[*map(b,r(q,v:=i+60))];a(v,x,i+t,1);b(p);a(q,i+t,q)
p(3934)
a(0,1,3)
a(2,3,3,1)
d(0,9)
d(1,50)
for t in r(60):a(2,2,2);[t-31<s<30!=(a(8+t-s,50+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9284
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
from re import split
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy
import re

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


h, w = LI()
L = SR(h)
dp = [[INF] * w for _ in range(h)]
dp[0][0] = 1 if L[0][0] == '#' else 0
for y in range(h):
    for x in range(w):
        if y:
            if L[y][x] == '.' or L[y - 1][x] == '#':
                dp[y][x] = dp[y - 1][x]
            else:
                dp[y][x] = dp[y - 1][x] + 1
        if x:
            if L[y][x] == '.' or L[y][x - 1] == '#':
                dp[y][x] = min(dp[y][x], dp[y][x - 1])
            else:
                dp[y][x] = min(dp[y][x], dp[y][x - 1] + 1)


print(dp[h - 1][w - 1])

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

int main(){
	ll x;
	cin >> x;
	if(x<100){
		cout << 0;
	}
	else {
		ll temp=x/100;
		x-=(temp*100);
		for (int i = 0; i < temp; ++i)
		{
			if(x>=5){
				x-=5;
			}
			else if(x>=4){
				x-=4;
			}
			else if(x>=3){
				x-=3;
			}
			else if(x>=2){
				x-=2;
			}
			else if(x>=1){
				x-=1;
			}
			else{
				continue;
			}
		}
		if(x==0){
			cout << 1;
		}
		else {
			cout << 0;
		}

	}
}

Measured memory_bytes: 256
def genDivisor(v):
    i=2
    ds=[]
    while i*i<=v:
        if v%i==0:
            ds.append(i)
            ds.append(v//i)
        i+=1
    return ds

x,y=map(int,input().split(" "))

dx=genDivisor(x)
if x>1:
    dx.append(x)
dy=genDivisor(y)
if y>1:
    dy.append(y)

xny=sorted(list(set(dx).intersection(set(dy))))

N=len(xny)
count=1
for i in range(N):
    needToDel=False
    for j in range(i):
        if xny[i]%xny[j]==0:
            needToDel=True
            break
    if needToDel==False:
        count+=1
print(count)





Measured memory_bytes: 5224
#include <bits/stdc++.h>
#define db double
using namespace std;
const int N = 1e5 + 100;
const db eps = 1e-8;
const db inf = 1e20;
const db pi = acos (-1);
inline int sgn (db p) {
    if (fabs (p) < eps) return 0;
    if (p < 0) return -1;
    return 1;
}
struct point {
    db x, y;
    point () {}
    point (db _x, db _y) {x = _x, y = _y;}
    void input () {scanf ("%lf %lf", &x, &y);}
    bool operator == (point b) const {return sgn (x - b.x) == 0 && sgn (y - b.y) == 0;}
    bool operator < (point b) const {return y < b.y || (sgn (y - b.y) == 0 && x < b.x);}
    point operator - (const point &b) const {return point (x - b.x, y - b.y);}
    db operator * (const point &b) const {return x * b.x + y * b.y;}
    db operator ^ (const point &b) const {return x * b.y - y * b.x;}
    point operator + (const point &b) const {return point (x + b.x, y + b.y);}
    point operator * (const db &b) const {return point (x * b, y * b);}
    point operator / (const db &b) const {return point (x / b, y / b);}
    db distance (point p) {return hypot (x - p.x, y - p.y);}
    db len () {return hypot (x, y);}
    db len2 () {return x * x + y * y;}
    db cross (point a, point b) {return (a - *this) ^ (b - *this);}
    db dot (point a, point b) {return (a - *this) * (b - *this);}
    bool on_seg (point a, point b) {return sgn (cross (a, b)) == 0 && dot (a, b) <= 0;}///点是否在线段ab上
    point turn (db k) {return point (x * cos(k) - y * sin(k), x * sin(k) + y * cos(k));}
    point rotate(point p, db angle) {///绕着 p 点逆时针旋转 angle
        point v = (*this) - p;
        db c = cos(angle), s = sin(angle);
        return point(p.x + v.x*c - v.y*s, p.y + v.x*s + v.y*c);
    }
} p;
///两线段是否相交
bool seg (point a, point b, point c, point d) {
    if (a.on_seg (c, d) || b.on_seg (c, d) || c.on_seg (a, b) || d.on_seg (a, b)) return true;
    if (a.cross (b, d) * a.cross (b, c) < 0 && c.cross (d, b) * c.cross (d, a) < 0) return true;
    return false;
}
/// 点的投影是否在线段ab上
bool check (point p, point a, point b) {
    point x = b - a;
    db k = x.len ();
    db u = a.dot (p, b) / k;
    x = (x / k) * u + a;
    if (x.on_seg (a, b)) return true;
    return false;
}
struct polygon {
    int n;
    point ps[N];
    void input () {
        cin >> n;
        for (int i = 0; i < n; i++) ps[i].input ();
    }
    void getconvex (polygon &convex) {
        sort (ps, ps + n);
        int &top = convex.n;
        top = 0;
        convex.ps[top++] = ps[0];
        for (int i = 1; i < n; i++) {
            while (top >= 2 && convex.ps[top - 2].cross (convex.ps[top - 1], ps[i]) < 0) top--;
            convex.ps[top++] = ps[i];
        }
        int t = 0;
        for (int i = n - 2; i >= 0; i--) {
            while (t && convex.ps[top - 2].cross (convex.ps[top - 1], ps[i]) < 0) top--, t--;
            if (!i) break;
            convex.ps[top++] = ps[i], t++;
        }
    }
} s, e;
int main () {
    s.input ();
    s.getconvex (e);
    cout << e.n << endl;
    for (int i = 0; i < e.n; i++) printf ("%.0f %.0f\n", e.ps[i].x, e.ps[i].y);
    return 0;
}



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

using namespace std;
typedef long long ll;
#define DBG(v) cerr << #v << " = " << (v) << endl;

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

    int a[3];
    for(int &x:a)
        cin >> x;
    sort(a, a + 3);
    cout << a[0] + a[1];
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG
#include "cpp-pyprint/pyprint.h"
#endif

void Main() {
    int N, M;
    cin >> N >> M;
    Graph query(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        query[a-1].push_back(b-1);
    }
    vector<unordered_map<int, int>> graph(N, unordered_map<int, int>());
    for (int i = 1; i < N; ++i) {
        graph[i][0] = 0;
        graph[0][i] = 0;
    }
    for (int j = 0; j < N; ++j) {
        int a = j;
        for (int i = 0; i < query[j].size(); ++i) {
            int b = query[j][i];
            //print(query[i]);
            if (a != 0 && b != 0) {
                graph[a][0] += 1;
                graph[0][a] += 1;
                graph[0][b] += 1;
                graph[b][0] += 1;
            } else if(a == 0) {
                graph[0][b] += 1;
                graph[b][0] += 1;
            }else{
                graph[0][a] += 1;
                graph[a][0] += 1;
            }
        }
    }
//    for (int k = 0; k < N; ++k) {
//        for (int i = 0; i < graph[k].size(); ++i) {
//            cout << k << ": "<< i <<" => " << graph[k][i] << endl;
//        }
//    }
    bool flg = true;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < graph[i].size(); ++j) {
            int tmp = graph[i][j];
            if (tmp % 2 == 0) {
                continue;
            }else{
                flg = false;
            }
        }
    }
    if(flg) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2048;
using func = bitset<MAXN>;
using vf = vector<func>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vf beat(N + 1);
    for (int j = 2; j <= N; j++) {
        string str;
        cin >> str;
        for (int i = 1; i < j; i++) {
            beat[j][i] = str[i - 1] == '1';
            beat[i][j] = str[i - 1] == '0';
        }
    }
    //WATCHC(beat);

    vf meet_ij(N + 1), meet_ji(N + 1);
    vf lwin_ij(N + 1), lwin_ji(N + 1);
    vf rwin_ij(N + 1), rwin_ji(N + 1);

    for (int i = 1; i <= N; i++) {
        lwin_ij[i][i] = lwin_ji[i][i] = true;
        rwin_ij[i][i] = rwin_ji[i][i-1] = true;
    }

    for (int len = 2; len <= N; len++) {
        for (int i = 1; i + len - 1 <= N; i++) {
            int j = i + len - 1;

            meet_ij[i][j] = (lwin_ij[i] & rwin_ji[j]).count();
            meet_ji[j][i] = meet_ij[i][j];

            lwin_ij[i][j] = (beat[i] & meet_ij[i] & lwin_ji[j]).count();
            lwin_ji[j][i] = lwin_ij[i][j];

            rwin_ij[i][j] = (beat[j] & meet_ji[j] & rwin_ij[i]).count();
            rwin_ji[j][i-1] = rwin_ij[i][j];

            /*cout << "Processed interval [" << i << ", " << j << "]\n";
            WATCH(meet_ij[i][j]);
            WATCH(lwin_ij[i][j]);
            WATCH(rwin_ij[i][j]);*/
        }
    }

    int ans = 0;
    for (int ch = 1; ch <= N; ch++) {
        if (rwin_ji[ch][0] && lwin_ij[ch][N])
            ans++;
    }
    cout << ans << endl;

    return 0;
}



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

#define ll long long

int main(){
	ll a, b, c, k; cin >> a >>  b >> c >> k;
	ll result = 0;
	if (a <= k){
		result += a * 1;
		k -= a;
	}else{
		result += k * 1;
		k = 0;
	}
	if (b <= k){
		result += b * 0;
		k -= b;
	}else{
		result += k * 0;
		k = 0;
	}
	if (c <= k){
		result += c * -1;
		k -= c;
	}else{
		result += k * (-1);
		k = 0;
	}
	cout << result << "\n";

}

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

int main(void){
	int n,k;
	cin >> n >> k;

	vector<int> x(n),y(n);
	vector<int> xary,yary;

	for(int i = 0; i < n; ++i){
		cin >> x[i] >> y[i];
		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}
	
	sort(begin(xary),end(xary));
	sort(begin(yary),end(yary));
	
	ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

	for(int xi = 0; xi < n; ++xi){
		for(int xj = xi + 1; xj < n;++xj){
			for(int yi = 0; yi < n; ++yi){
				for(int yj = yi + 1; yj < n;++yj){
	
					int num = 0;
					ll lx = xary[xi],rx = xary[xj];
					ll by = yary[yi],uy = yary[yj];

					for(int i = 0; i < n;++i){
						if(lx <= x[i] and x[i] <= rx and by <= y[i] and y[i] <= uy){
							num++;
						}
					}

					if(num >= k) ans = min(ans,1LL * (rx - lx) * (uy - by));
				}
			}
		}
	}

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


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 n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            boolean bo = isTriangle(a, b, c) || isTriangle(b, c, a) || isTriangle(c, a, b);
            if (bo) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
    
    public static boolean isTriangle(int a, int b, int c) {
        return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)) == c;
    }
}

Measured memory_bytes: 33196
s = input()
cnt0 = 0
cnt1 = 0
tile = ['0','1']
ans0 = ''
ans1 = ''
for i in range(len(s)):
    ans0 += tile[i%2]
    ans1 += tile[(i+1)%2]

for i,j,k in zip(s,ans0,ans1):
    if i != j:
        cnt0 += 1
    if i != k:
        cnt1 += 1
print(min(cnt0,cnt1))

Measured memory_bytes: 3316
import sys, array, re, functools
input = lambda: sys.stdin.readline()
@functools.lru_cache(maxsize = 10000)

def Main():
  x = int(input())
  lb = -1
  ub = 123456789
  
  while ub - lb > 1:
    mid  = (ub + lb)//2
    s = mid*(mid + 1)//2
    
    if s >= x:
      ub = mid
      # ans = mid
    else:
      lb = mid
  
  print(ub)
if __name__ == '__main__':
  Main()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define pb push_back

int main(){
    fast;
    ll n,k;
    cin>>n>>k;
    double d=log10(n)/log10(k);
    cout<<floor(d)+1<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ
{
  public class Program
  {
    private static int FigLength(int num)
    {
      int length = 1;
      int ten = 10;
      while (num / ten != 0)
      {
        ten *= 10;
        length++;
      }
      return length;
    }

    public static void Main()
    {
      int n = int.Parse(Console.ReadLine());

      int[] ary = new int[n];

      for (int i = 0; i < n; i++)
      {
        ary[i] = int.Parse(Console.ReadLine());
      }

      Array.Sort(ary);

      int sliceN = (n == 3) ? 3 : 4;
      int[] lenAry = new int[sliceN];
      for (int i = 0; i < sliceN; i++)
      {
        lenAry[i] = FigLength(ary[i]);
      }

      int[] results = new int[6 * (sliceN - 2)];
      int count = 0;

      for (int i = 0; i < sliceN; i++)
      {
        for (int j = 0; j < sliceN; j++)
        {
          if (j == i) continue;
          results[count++] = ary[i] * (int)Math.Pow(10, lenAry[j]) + ary[j];
        }
      }

      Array.Sort(results);

      Console.WriteLine(results[2]);
    }
  }
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

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

ll a,b,c;
cin>>a>>b>>c;
if((c-a-b>0)&&(c-a-b)*(c-b-a)>4*a*b)
cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,m,ans,a[100005],b[200005];
ll check(ll x){
	ll res=0;
	for(int i=0;i<n;i++){
		ll k=lower_bound(a,a+n,x-a[i])-a;
		res+=n-k;
	}
	return res;
}
int main(){
	n=read(),m=read();
	for(int i=0;i<n;i++)
		a[i]=read();
	sort(a,a+n),b[0]=a[0];
	for(int i=0;i<n;i++)
		b[i+1]=a[i]+b[i];
	ll l=0,r=200001;
	while(l<r-1){
		ll mid=(l+r)>>1;
		if(check(mid)>=m)l=mid;
		else r=mid;
	}
	ll res=0;
	for(int i=0;i<n;i++){
		ll k=lower_bound(a,a+n,l+1-a[i])-a;
		res+=n-k,ans+=b[n]-b[k]+a[i]*(n-k);
	}
	ans+=(m-res)*l;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    string s;
    cin>>n;
    cin>>s;
    int ans=false;
    if(n%2==0) {
        rep(i,n/2) {
            if(s[i]!=s[n/2+i]) break;
            if(i==n/2-1)    ans=true;
        }
    }

    if(ans==false)  cout<<"No"<<endl;
    else    cout<<"Yes"<<endl;
    
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, d, x;
  cin >> n >> d >> x;

  rep(i, n) {
    ll a;
    cin >> a;
    x += (d-1) / a + 1;
  }

  cout << x << endl;

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])
        cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   int n; cin>>n;
   if(n>=400 && n<=599){
      cout<<8;
   }
   else if(n>=600 && n<= 799){
      cout<<7;
   }else if(n>=800 && n<= 999){
      cout<<6;
    }else if(n>=1000 && n<= 1199){
      cout<<5;
   }else if(n>= 1200 && n<= 1399){
      cout<<4;
   }else if(n>= 1400 && n<= 1599){
      cout<<3;
   }else if(n>= 1600 && n<= 1799){
      cout<<2;
   }else if(n>= 1800 && n<= 1999){
      cout<<1;
   }

  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

long N;
int ans = 0;

void dfs(long num,int a,int b,int c){
  if(num > N) return;
  if(a && b && c) ans++;
  dfs(num*10+3,1,b,c);
  dfs(num*10+5,a,1,c);
  dfs(num*10+7,a,b,1);
}

int main(void){
  scanf("%ld",&N);

  dfs(0,0,0,0);

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int MOD = 100000007;
const int MAXN = 1000000;
const int inf = 0x3f3f3f3f;
int main()
{
	//freopen("data.txt","r",stdin);
	int a, b, t;
	scanf("%d%d%d", &a, &b, &t);
	int ans = t / a * b;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]


ans = 1
a.sort()

for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        print("0")
        exit(0)
    if ans > 10 ** 18:
        print("-1")
        exit(0)

print(ans)

Measured memory_bytes: 84708
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

typedef pair<int,int> PII;
const int M=20;
vector<PII> g[M];
int n;

bool check(int st)
{
	for(int i=0;i<n;i++)
	{
		if(!(st&(1<<i))) continue;
		for(PII p:g[i])
			if(((st>>p.first)&1) != p.second) return false;
	}
	return true;
}
int count(int st)
{
	int ans=0;
	while(st)
		ans+=st&1,st>>=1;
	return ans;
}

int main()
{
	scanf("%d",&n);
	int m,x,y;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&m);
		while(m--)
		{
			scanf("%d%d",&x,&y);
			x--;
			g[i].emplace_back(x,y);
		}
	}
	int mask=1<<n;
	int ans=0;
	for(int i=1;i<mask;i++)
	{
		if(check(i)) ans=max(ans,count(i));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,arr[100005],mod=1e9+7;

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
int main()
{
    calcFacAndInv(1000000);
    cin>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    sort (arr+1,arr+n+1);
    ll total=0;
    for(int i=1; i<=n; i++)
    {
        ll maxi=0,mini=0;
        if(i>1 && i-1>=k-1)
            maxi=ncr(i-1,k-1);
        if(i<n && n-i>=k-1)
            mini=ncr(n-i,k-1);



        ll sub=(maxi-mini);
        total=(total%mod+(arr[i]%mod*sub)%mod+mod)%mod;
    }
    cout << total%mod << endl;
    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, M;
    cin >> N >> M;
    vector<pll> alb(N);
    REP(i, N) cin >> alb[i].first >> alb[i].second;
    sort(alb.begin(), alb.end());

    ll res = 0;
    priority_queue<ll> pq;
    ll itr = 0;
    REP(i, M){
    	while(itr < N && alb[itr].first <= i+1) pq.push(alb[itr].second), itr++;
    	if(pq.empty()) continue;
    	ll tmp = pq.top();pq.pop();
    	//dump(tmp)
    	res += tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2936
a, b = list(map(int, input().split()))
p = 1

if 0 < a and 0 < b:
    print('Positive')
elif a <= 0 and 0 <= b or 0 <= a and b <= 0:
    print('Zero')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')

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

int main(){
	while(1){
		int h[101];
		int n=0;
		int d=0;
		cin>>n;
		if(n==0){
			break;
		}
		for(int i=0;i<n+1;i++){
			cin>>h[i];
		}
		for(int i=0;i<n+1;i++){
			int F=1;
			int tmp[100];
			for(int j=0;j<i;j++){
				tmp[j]=h[j];
			}
			for(int j=i+1;j<n+1;j++){
				tmp[j-1]=h[j];
			}
			d=tmp[1]-tmp[0];
			for(int a=1;a<n-1;a++){
				if(tmp[a+1]-tmp[a]!=d){
					F=0;
					break;
				}
			}
			if(F==1){
				cout<<h[i]<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
using pint = pair<int, int>;


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    int a[N];
    for (auto &x: a) {
        cin >> x;
    }
    int mx = a[0];
    long long ans = 0;
    for (int i = 1; i < N; i ++) {
        if (mx > a[i]) {
            ans += mx - a[i];
        } else if (mx < a[i]) {
            mx = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4320
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    ans = 0
    for k in c.keys():
        cur = c[k-1] + c[k] + c[k+1]
        ans = max(cur, ans)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56492
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define say(args) cout << (args) << endl
#define rep(i, a) for (int i = 0; i < a; i++)

using namespace std;

string reverse_str(string str) {
  int l = str.size();
  for (int i = 0; i < l / 2; i++) {
    int swap_idx  = l - i - 1;
    char tmp      = str[i];
    str[i]        = str[swap_idx];
    str[swap_idx] = tmp;
  }
  return str;
}

int count_organize(string &str) {
  int n = str.size();
  map<string, int> counter;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (i + j == n) {
        string one = str.substr(0, i);
        string two = str.substr(i, j);
        // cout << "i : " << i << ", j : " << j << endl;
        // cout << "str : " << str << ", one : " << one << ", two : " << two << endl;
        // cout << reverse_str( string("ab") ) << endl;
        counter[one + two] = 1;
        counter[one + reverse_str(two)] = 1;
        counter[reverse_str(one) + two] = 1;
        counter[reverse_str(one) + reverse_str(two)] = 1;
        counter[two + one] = 1;
        counter[two + reverse_str(one)] = 1;
        counter[reverse_str(two) + one] = 1;
        counter[reverse_str(two) + reverse_str(one)] = 1;
      }
    }
  }
  int count = 0;
  for (auto itr : counter) {
    count += 1;
  }
  return count;
}

int main() {
  int n;
  cin >> n;
  vector<string> strings(n);
  rep(i, n) {
    cin >> strings[i];
  }

  for (auto str : strings) {
    say( count_organize(str) );
  }
}

Measured memory_bytes: 3272