akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(string, n);
	for (char c : n) switch(c){
	case '1': cout << 9; break;
	case '9': cout << 1;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	double n,sum=0;
	cin >> n;
	vector<ll>v(n);
	rep(i, n)cin >> v[i];
	sort(v.begin(), v.end());
	for (ll i = 0; i < n; i++) {
		if (i == 0 || i == 1)sum += v[i] * pow(0.5, n - 1);
		else sum += v[i] * pow(0.5,n-1-(i-1));
	}
	cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
///
// File:  alds1_1_d.cpp
// Author: ymiyamoto
//
// Created on Wed Oct  4 00:51:49 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint64_t n;
  cin >> n;

  int64_t max_value = INT64_MIN;
  int64_t min_value;
  cin >> min_value;
  for (uint64_t i = 1; i < n; i++) {
    int64_t value;
    cin >> value;
    max_value = max(value - min_value, max_value);
    min_value = min(value, min_value);
  }

  cout << max_value << endl;

  return 0;
}

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


using namespace std;
const long long inf=LONG_MIN;

int main(){
	vector <int> v1 , v2;
	vector <long long> V;
	long long maxi=0;
	int N , W , w , v;
	cin>>N>>W;
	V.push_back(0);
	for (int i=1;i<W+1;i++)
		V.push_back(inf);
	
	for (int i=0;i<N;i++){
		cin>>w>>v;
		v1.push_back(w);
		v2.push_back(v);
	}
	
	for (int i=0;i<N;i++)
		for (int j=W;j>=0;j--)
			if (j+v1[i]<=W)
				V[j+v1[i]]=max(V[j+v1[i]], V[j]+v2[i]);
	
	for (int i=W;i>=0;i--)
		if (V[i]>maxi)
			maxi=V[i];
			
	cout<<maxi;
	
	return 0;
}

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

string s;
int one,zero;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i]=='1') one++;
			else zero++;
	} 

	cout << min(one,zero)*2 << endl;
	return 0;
}

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

string s,ss,t;
void input()
{
    cin >> ss >> t;
}

void solve()
{
    int Ns = ss.size(), Nt = t.size();
    for (int i = 0; i < Ns-Nt; ++i) {
        if(ss[i] == t[0]){
            for (int j = 0; j < Nt; ++j){
                if(ss[i+j] != '?' && ss[i+j] != t[j]) break;
            }
        }
    }
    for (int i = Ns-1; i >= Nt-1; --i){
        if(ss[i] == '?' || ss[i] == t[Nt-1]){
            s = ss;
            bool flag = true;
            for (int j = 0; j < Nt; ++j){
                if(ss[i-j] != '?' && ss[i-j] != t[Nt-1-j]) {
                    flag = false;
                    break;
                }
                ss[i-j] = t[Nt-1-j];
            }
            if(flag){
                for (int i = 0; i < Ns; ++i) {
                    if(ss[i] == '?') cout << 'a';
                    else cout << ss[i];
                }
                cout << endl;
                return;
            }
            ss = s;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <cmath>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using ll = long long;
using pii = pair<int, int>;

int main(){
  string a, b, c, result = "";
  cin >> a >> b >> c;
  result += a[0];
  result += b[0];
  result += c[0];
  transform(result.begin(), result.end(), result.begin(), ::toupper);
  puts(result)
}


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

int main()
{
	long long h;
	cin >> h;
	long long a = 1;
	while (1){
		if (h < a){
			cout << a-1 << endl;
			return 0;
		}
		a *= 2;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
long long int knapsack(long long int arr[][2],int n,int w)
{
  long long int dp[n][w+1];
  for(int i=0;i<n;i++)
  {
      for(int j=0;j<=w;j++)
      {
          dp[i][j]=0;
      }
  }
  for(int i=1;i<=w;i++)
  {
      if(arr[0][0]<=i)
      {
           dp[0][i] = arr[0][1];
      }
  }
  for(int i=1;i<n;i++)
  {
      for(int j=1;j<=w;j++)
      {
          if(j-arr[i][0]>=0)
          dp[i][j] = max(dp[i-1][j],arr[i][1]+dp[i-1][j-arr[i][0]]);
          else
          dp[i][j]= dp[i-1][j];
      }
  }
  return dp[n-1][w];
}
int main()
{
  int n,w;
  cin>>n>>w;
  long long int arr[n][2];
  for(int j=0;j<n;j++)
  {
    for(int i=0;i<2;i++)
    {
        cin>>arr[j][i];
    }
  }
  cout<<knapsack(arr,n,w)<<endl;
  return 0;
}


Measured memory_bytes: 78336
from collections import Counter
n, m = map(int, input().split())
x = list(map(int, input().split()))
c = [0] * m
for y in x:
    c[y % m] += 1
ans = c[0] // 2
c[0] = 0
for i in range((m - 1) // 2):
    t = min(c[i + 1], c[m - i - 1])
    ans += t
    c[i + 1] -= t
    c[m - i - 1] -= t
if m % 2 == 0:
    ans += c[m // 2] // 2
    c[m // 2] %= 2
c2 = Counter(x)
for k, v in c2.items():
    ans += min(c[k % m], v) // 2
    c[k % m] -= min(c[k % m], v) // 2 * 2
print(ans)


Measured memory_bytes: 20448
#include<stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int x,y;
    for(;;){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0){
            break;
        }
        if(x>y){
            swap(x,y);
        }
        printf("%d %d\n",x,y);
    }
}


Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin >> n;
    map<int,int>mp1,mp2;
    for(int i=0;i<n/2;++i)
    {
        int t;
        cin >> t;
        mp1[t]++;
        cin >> t;
        mp2[t]++;
    }
    pair<int,int>mx11,mx12,mx21,mx22;
    for( auto it : mp1 )
    {
        if( mx11.second <= it.second )
        {
            mx12 = mx11;
            mx11 = it;
        }
        else
        if( mx12.second <= it.second )
            mx12 = it;
    }
    for( auto it : mp2 )
    {
        if( mx21.second <= it.second )
        {
            mx22 = mx21;
            mx21 = it;
        }
        else
        if( mx22.second <= it.second )
            mx22 = it;
    }
    int mn = 1e9;
    if( mx11.first != mx21.first )
        mn = min( mn , n - mx11.second - mx21.second );
    if( mx11.first != mx22.first )
        mn = min( mn , n - mx11.second - mx22.second );
    if( mx12.first != mx21.first )
        mn = min( mn , n - mx12.second - mx21.second );
    /*if( mx12.first != mx22.first )
        mn = min( mn , n - mx12.second - mx22.second );*/
    cout << mn;


 
}

Measured memory_bytes: 4992
fn main() {
    #[allow(unused_imports)]
    use std::io::{Read, Write, BufWriter};
    let mut a = Vec::new();
    std::io::stdin().read_to_end(&mut a).unwrap();
    let a = String::from_utf8(a).unwrap();
    let mut a = a.split_whitespace();
    #[allow(unused_mut,unused_variables)]
    let mut b = BufWriter::new(std::io::stdout());
    macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) }
    #[allow(unused_macros)]
    macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) }
    #[allow(unused_imports)]
    use std::cmp::{min, max};

    let n: usize = yomu!();
    let d: usize = yomu!();
    let mut xs: Vec<Vec<i32>> = vec![vec![0; d]; n];
    for i in 0..n {
        for j in 0..d {
            xs[i][j] = yomu!();
        }
    }
    let mut ans = 0;
    for i in 0..n {
        for j in 0..i {
            let mut s = 0;
            for k in 0..d {
                s += (xs[i][k] - xs[j][k]) * (xs[i][k] - xs[j][k]);
            }
            let t = (s as f64).sqrt() as i32;
            if t * t == s {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
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;
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  IOS;
  constexpr char endl = '\n';

  string N;
  cin >> N;
  string res = (count(all(N), '7')) ? "Yes" : "No";

  cout << res << endl;
}

Measured memory_bytes: 3580
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c)
ans = 0

for i in range(n):
    a_M = bisect.bisect_left(a, b[i])
    c_m = bisect.bisect_right(c, b[i])
    ans += a_M * (n - c_m)
print(ans)

Measured memory_bytes: 107108
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
 
bool DP(vector<int>& a, int A){    //部分和問題
 
    vector<vector<bool> > dp(a.size() + 5, vector<bool> (A + 5, false));
    
    //dp初期条件
    dp[0][0] = true;
    
    //dp
    for(int i = 0; i < a.size(); i++){
        for(int j = 0; j <= A; j++){
            dp[i + 1][j] = dp[i][j] || dp[i + 1][j];
            if(j >= a[i]) dp[i + 1][j] = dp[i][j - a[i]] || dp[i + 1][j];
        }
    }
    if(dp[a.size()][A]) return true;
    else return false;
}
 
int main(void){
 
    string s; cin >> s;
    int x, y; cin >> x >> y;
    vector<int> a;
    vector<int> b;
    int j = 0;
    int counter = 0;
    int sum_a = x, sum_b = y;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'T'){
            if(j == 0) {
                sum_a -= counter;
                counter = 0;
                j++;
            }else if(j % 2 == 0){
                if(counter > 0) a.push_back(counter);
                counter = 0;
                j++;
            }else if(j % 2 == 1){
                if(counter > 0) b.push_back(counter);
                counter = 0;
                j++;
            }
        }else{
            counter++;
        }
    }
    
 
    if(j % 2 == 0){
        if(j == 0) sum_a -= counter;
        else if(counter > 0) a.push_back(counter);
    }else{
        if(counter > 0) b.push_back(counter);
    }
 
    for(size_t i = 0; i < a.size(); i++) sum_a += a[i];
    for(size_t i = 0; i < b.size(); i++) sum_b += b[i];
    a.push_back(abs(x));
    b.push_back(abs(y));

    fprintf(stderr, "sum_a = %d, sum_b = %d\n", sum_a, sum_b);
    if(sum_a % 2 == 1 || sum_b % 2 == 1 || sum_a < 0 || sum_b < 0){  //sumが偶数であるのは必要条件であるため
        cout << "No" << endl;
        return 0; 
    }
 
    sum_a = sum_a / 2;
    sum_b = sum_b / 2;
    
    bool flag1, flag2;
    
    flag1 = DP(a, sum_a);  //数列a, A = sum_a の部分和問題
    flag2 = DP(b, sum_b);
 
    if(flag1 && flag2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

vector<int> G[10000];
bool used[10000];
int ans[100][100];
void solve() {
	int n; cin >> n;
	int e = 2 * n*n - 2 * n;
	rep(i, e) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int root = 0;
	rep(i, e) {
		if (G[i].size() == 2) {
			root = i; break;
		}
	}
	ans[0][0] = root;
	used[root] = true;
	rep(i, n - 1) {
		rep(j, G[root].size()) {
			int to = G[root][j];
			if (used[to])continue;
			if (i < n - 2 && G[to].size() == 3) {
				root = to;
				break;
			}
			if (i == n - 2 && G[to].size() == 2) {
				root = to; break;
			}
		}
		used[root] = true;
		ans[0][i + 1] = root;
	}
	rep(i, n - 1) {
		rep(j, n) {
			int id = ans[i][j];
			rep(k, G[id].size()) {
				int to = G[id][k];
				if (!used[to]) {
					ans[i + 1][j] = to; used[to] = true;
				}
			}
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (j > 0)cout << " ";
			cout << ans[i][j] + 1;
		}
		cout << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3756
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 5005;
const int inf = 1e18;
int n, a[N], f[N], p[N], A, B, s[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); A = read(); B = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	for(int i = 1; i <= n; i ++) f[i] = inf;
	for(int i = 1; i <= n; i ++)
	{
		int x = a[i];
		for(int j = 0; j <= n; j ++)
		{
			if(j) p[j] = min(f[j], p[j - 1]);
			else p[j] = f[j];
		}
		for(int j = 0; j <= x; j ++) f[j] += A;
		for(int j = x + 1; j <= n; j ++) f[j] += B;
		f[x] = min(f[x], p[x]);
	}
	int ans = inf;
	for(int i = 0; i <= n; i ++) ans = min(ans, f[i]);
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;

using namespace std;

struct xyz {
    int a;
    int b;
};

struct abc {
    int p;
    int x;
};

int main() {
    int n, q;
    cin >> n >> q;
    
    vector<xyz> v(n - 1);
    vector<vector<int>> save = vector<vector<int>>(n, vector<int>(0));
    for(int i = 0; i < n - 1; i++) {
        cin >> v[i].a >> v[i].b;
        save[v[i].a - 1].push_back(v[i].b);
        save[v[i].b - 1].push_back(v[i].a);
    }
    
    vector<abc> que(q);
    for(int i = 0; i < q; i++) {
        cin >> que[i].p >> que[i].x;
    }
    
    vector<ll> ans(n, 0);
    for(int i = 0; i < q; i++) {
        ans[que[i].p - 1] += que[i].x;
    }
    
    bool flag[1000000] = {false};
    queue<int> next;
    next.push(0);
    while(!next.empty()) {
        int tmp = next.front();
        next.pop();
        for(int i = 0; i < save[tmp].size(); i++) {
            if(!flag[save[tmp][i] - 1]) {
                ans[save[tmp][i] - 1] += ans[tmp];
                next.push(save[tmp][i] - 1);
            }
        }
        flag[tmp] = true;
    }
    
    for(int i = 0; i < n; i++) {
        if(i == n - 1) {
            cout << ans[i] << endl;
        }
        else {
            cout << ans[i] << " ";
        }
    }
    
    /*
    for(int i = 0; i < n; i++) {
        if(i == n - 1) {
            cout << ans[i] << endl;
            break;
        }
        
        cout << ans[i] << " ";
        
        for(int j = 0; j < save[i].size(); j++) {
            ans[save[i][j] - 1] += ans[i];
        }
    }
     */
    
    return 0;
}



Measured memory_bytes: 20468
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}


std::string str="All Good Till Here";

/////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    fastio
	ll tt,i,j,a,b,h,m,x;
	//cin>>tt;
  tt=1;
	while(tt--)
	{
    cin>>a>>b>>h>>m;
    ld mi=1.0*(2*PI*m)/60, ho=1.0*2*PI*((60*h)+m)/720;;
    ld diff=abs(mi-ho);
    ld ans=sqrt((a*a)+(b*b)-2*a*b*cos(diff));
    cout<<fixed<<setprecision(12)<<ans<<"\n";
	}
    return 0;
}


Measured memory_bytes: 4100
N = input()

num = len(N)
V = 753
min_dif = 1000

for i in range(num-2) : 
    sum = int(N[i])*100 +int(N[i+1])*10 +int(N[i+2])
    dif = abs(V -sum)
    min_dif = min(min_dif, dif)
    
print(min_dif)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int n, x;

int main(){
    vector<int> a;
    deque<int> d;
    
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x;
        a.push_back(x);
    }

    for(int i = 0; i < n; i++){
        if((i % 2) != 0){
            d.push_back(a[i]);
        } else{
            d.push_front(a[i]);
        }
    }

    if(n % 2 == 0){
        reverse(d.begin(), d.end());
    }

    for(int i = 0; i < n; i++){
        cout << d[i] << " ";
    }




}



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

int main(){
    int n;
    cin >> n;
    int ans;
    for(int i = 1; i <= n; i++){
        if(i*i <= n){
            ans = i*i;
        }else{
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char A[55][55];
  char B[55][55];
  int N,M;
  scanf("%d %d",&N,&M);
  int i,j,x,y;
  for(i=0;i<N;i++){
    scanf("%s",A[i]);
  }
  for(i=0;i<M;i++){
    scanf("%s",B[i]);
  }
  i=0;
  j=0;
  while(1){
    if(i+M-1>=N) break;
    int cnt=0;
    for(y=0;y<M;y++){
      for(x=0;x<M;x++){
        if(A[y+i][x+j]==B[y][x])cnt++;
      }
    }
    if(cnt==M*M){
      printf("Yes\n");
      return 0;
    }
    j++;
    if(j+M-1>=N){
      i++;
      j=0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
def div2_count(n):
  if n % 2 != 0: return 0
  else: return 1 + div2_count(n / 2)
 
N = int(input())
ans = 1
count = 0
 
for i in range(N, 1, -1):
  tmp = div2_count(i) 
  if tmp > count: 
    ans = i
    count = tmp
    
print(ans)

Measured memory_bytes: 9100
import java.util.Scanner;
import java.util.Arrays;


public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] nArray = new int[n];

	for ( int i=0; i<n; i++ ) {
	    nArray[i] = sc.nextInt();
	}

	Arrays.sort(nArray);

	int t;
	for ( int i=0; i<n/2; i++ ) {
	    t = nArray[i];
	    nArray[i] = nArray[n-i-1];
	    nArray[n-i-1] = t;
	}

	int alice=0, bob=0;
	for ( int i=0; i<n; i++ ) {
	    if ( i%2 == 0 ) {
		alice += nArray[i];
	    } else {
		bob += nArray[i];
	    }
	}

	System.out.println(alice - bob);
    }
    
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int H, N;
    cin >> H >> N;

    rep(i, N) {
        int A;
        cin >> A;
        H -= A;
    }
    
    cout << ((H <= 0) ? "Yes" : "No") << endl;
}

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

typedef long long int ll;

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll,ll>> ab(n);
    for(ll i = 0;i < n;i++){
        cin >> ab[i].second >> ab[i].first;
    }

    sort(ab.begin(),ab.end());
    
    ll t = 0;
    for(ll i = 0;i < n;i++){
        t += ab[i].second;
        if(t > ab[i].first){
            cout << "No";

            return 0;
        }
    }

    cout << "Yes";

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
vector<int> adj[200005],vis(200005,0);
int k;
void dfs(int s){
	vis[s]=1;
	k++;
	for(auto p:adj[s]){
		if(!vis[p])
		dfs(p);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			k=0;
			dfs(i);
			ans=max(ans,k);
		}
	}
	cout<<ans;
}


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

signed main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  
  for( int i = 0; i < N; i++ ){
    if( S.substr(i) == T.substr(0, N-i) ){
      string ans = S.substr(0, i)  + T;
      cout << ans.size() << endl;
      return 0;
    }
  }
  cout << S.size() + T.size() << endl;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(int argc, char const *argv[])
{
  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  int fr[100010] = {}, bl[100010] = {};
  int a, b;
  for (int i = 0; i < m; i++)
  {
    cin >> a >> b; a--; b--;
    uf.unite(a,b);
    fr[a]++; fr[b]++;
  }
for (int i = 0; i < k; i++)
{
    cin >> a >> b; a--; b--;
    if (uf.same(a,b)) {
      bl[a]++; bl[b]++;
    }
    
}

  for (int i = 0; i < n; i++) {
    cout << uf.size(i)-1-fr[i]-bl[i] << " ";
  }
  cout << endl;
  
  return 0;
}


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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

map<int, int> depth_ans;
map<int, int> ans;
map<int, int> visited;
queue<int> que;
void saiki(vector<vector<int>> &room, int nowRoom, int depth) {
	visited[nowRoom] = 1;
	//cout << nowRoom << endl;
	for (int i = 0; i < room[nowRoom].size(); ++i) {
		int nextRoom = room[nowRoom][i];
		if (visited[nextRoom] == 0) {
			que.push(nextRoom);
			visited[nextRoom] = 1;
		}
		if (depth < depth_ans[nextRoom] || depth_ans[nextRoom] == 0) {
			ans[nextRoom] = nowRoom;
			depth_ans[nextRoom] = depth;
			//cout << nextRoom << "  " << nowRoom << endl;
		}
	}
	while (que.size() != 0) {
		int i = que.front();
		//cout << "room" << i << endl;
		que.pop();
		saiki(room, i, depth_ans[i]);
	}
}

int main() {
	int n, m;
	cin >> n >> m;

	vector<vector<int>> room(n + 1);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		room[a].push_back(b);
		room[b].push_back(a);
	}


	int nowRoom = 1;
	visited[1] = 1;
	saiki(room, nowRoom, 1);
	bool check = true;
	for (int i = 2; i < n + 1; ++i) {
		if (ans[i] == 0)check = false;
	}
	if (check) {
		cout << "Yes" << endl;
		for (int i = 2; i < n + 1; ++i) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 36160
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

saken s;
ll n;

void change() {

    ll x = n;

    while(x) {

        s.pb(char(x % 10 + 48));

        x /= 10;

    }

}

int main(){

cin >> n;

change();

if(n <= 9) {cout << n;return 0;}

ll col = 0;
ll ans = 0;

for(int i = 0; i < s.sz() - 1; ++i) {

    if(s[i] != '9') {
        s[i] = '9';
        col = 1;
    }

    ans += (s[i] - 48);
}

ans += (s[s.sz() - 1] - 48);

cout << ans - col;

return 0;
}



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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

ll gcdll(ll a, ll b){
    if(!b) return a;
    return gcdll(b, a%b);
}

void seive(int n){
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;

    for(int i=2; i*i<=n; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=n; j+=i){
                is_prime[j] = false;
            }
        }
    }
}

vector<int> constructZFunc(string s){
    int n = s.size();
    vector<int> z(n);
    int l, r;
    l = r = 0;
    z[0] = 0;
    rep(i, 1, n-1){
        z[i] = 0;
        if(i<=r){
            z[i] = min(r-i+1, z[i-l]);  /// initialization, req. for linear time approach.
        }
        while(i+z[i] < n && s[z[i]] == s[i+z[i]])
            ++z[i];
        if(i+z[i]-1 > r){
            r = i+z[i]-1;
            l = i;
        }
    }
    return z;
}

void solve(){
    ll n;
    cin>>n;
    pll a[n];
    fr(i, n) {
        cin>>a[i].first;
        a[i].second = i;
    }

    sort(a, a+n, greater<pll>());

    ll res = 0ll;
    ll st = 0, en = n-1, pos;

    map<pii, ll> mp;    /// ans
    mp[{0, n}] = a[0].first*(llabs(a[0].second - 0));   /// placing in the start
    mp[{-1, n-1}] = a[0].first*(llabs(a[0].second - n + 1));    /// placing in the last

    rep(i, 1, n-1){
        map<pii, ll> tmp;   /// temp map

        for(auto it: mp){
            /// there are 2 choices to place new element for this pair
            st = it.first.first + 1;
            en = it.first.second - 1;


            if(st + n - 1 - en != i) continue;


            tmp[{st, en + 1}] = max(tmp[{st, en + 1}], it.second + a[i].first*(llabs(a[i].second - st)));
            tmp[{st - 1, en}] = max(tmp[{st - 1, en}], it.second + a[i].first*(llabs(a[i].second - en)));
        }

        mp = tmp;
    }

    ll ans = 0;

    for(auto it: mp){
        ans = max(ans, it.second);
    }

    cout<<ans;

}

const int N = 2005;
ll dp[N][N] = {};

void solve_dp(){
    ll n;
    cin>>n;
    pll a[n+1];
    rep(i, 1, n){
        cin>>a[i].first;
        a[i].second = i;
    }

    sort(a+1, a+n+1, greater<pll>());

    int L, R;
    rep(i, 1, n){
        ll pos = a[i].second;
        fr(j, i){
            L = j;
            R = i - 1 - L;  /// total elements filled are i - 1
            dp[L+1][R] = max(dp[L+1][R], dp[L][R] + llabs(L + 1 - pos)*a[i].first);

            R = j;
            L = i - 1 - R;
            dp[L][R+1] = max(dp[L][R+1], dp[L][R] + llabs(n - R - pos)*a[i].first);
        }
    }

    ll ans = 0;
    rep(i, 0, n){
        ans = max(ans, dp[i][n-i]);
    }

    cout<<ans;

}


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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve_dp();
    }

    return 0;
}



Measured memory_bytes: 26332
#include<iostream>

int main() {
	int d;
	while (std::cin >> d) {
		int s = 0;
		for (int i = 1; i*d < 600; i++) {
			s += (i*d) * (i*d) * d;
		}
		std::cout << s << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3076
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( " " ).map( Number );
  var d = Math.sqrt( Math.pow( data[0]-data[2], 2 )+Math.pow( data[1]-data[3], 2 ) ).toFixed(5);
  console.log( d );
});

Measured memory_bytes: 15628
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int c = a - b;
    if (c == 0) {
        cout << "a == b" << endl;
    } else if (c > 0) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3076
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,t;
  cin >> a >> b >> t;
  int sum = 0;
  for(int i = a; i <= t; i += a)
  {
    sum += b;
  }
  cout << sum;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int h,w; cin >> h >> w;
    vector<vector<int>> hos(h+2,vector<int>(1,0));
    vector<vector<int>> wos(w+2,vector<int>(1,0));
    vector<string> grid(h);
    rep(i,h) cin >> grid.at(i);
    rep(i,h){
        rep(j,w){
            if(grid.at(i).at(j) == '#'){
                hos.at(i+1).push_back(j+1);
                wos.at(j+1).push_back(i+1);
            }
        }
    }
    rep(i,h){
        hos.at(i+1).push_back(w+1);
    }
    rep(i,w){
        wos.at(i+1).push_back(h+1);
    }
    
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(grid.at(i).at(j) == '.'){
                int cnt = 0;
                int hosi,wosi;
                hosi = lower_bound(hos.at(i+1).begin(), hos.at(i+1).end(), j+1) - hos.at(i+1).begin();
                cnt += hos.at(i+1).at(hosi) - hos.at(i+1).at(hosi - 1) - 1;
                wosi = lower_bound(wos.at(j+1).begin(), wos.at(j+1).end(), i+1) - wos.at(j+1).begin();
                cnt += wos.at(j+1).at(wosi) - wos.at(j+1).at(wosi - 1) - 1;
                cnt--;
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

inline int read() {
	int x;
	scanf("%d", &x);
	return x;
}

const int S = 1e5 + 10;
int n, m, a[S], tot = 0; 

int main() {
	n = read(); m = read();
	for (int i = 1; i <= m; i++)
		tot += read();
	if (tot >= n) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
first_B, last_A, both = 0, 0, 0
ans = 0
for s in S:
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A': both += 1
    elif s[0] == 'B': first_B += 1
    elif s[-1] == 'A': last_A += 1
if both <= 1:
    if last_A <= first_B: last_A += both
    else: first_B += both
    ans += max(min(first_B, last_A), 0)
else:
    ans += max(both-1, 0) + (1 if first_B else 0) + (1 if last_A else 0) + max(min(first_B-1, last_A-1), 0)
print(ans)

Measured memory_bytes: 3700
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
string S;
cin>>S;
ll K;
cin>>K;
bool all=true;
rep(i,S.size()){
    if(S[i]!=S[0])all=false;
}
if(all){
    cout<<(S.size()*K)/2<<endl;
    return 0;
}
ll min_one=0;
bool pre=false;
rep(i,S.size()-1){
    if(S[i]==S[i+1]){
        if(pre){
            pre=false;
        }
        else{
        min_one++;
        pre=true;
        }
    }
    else{
        pre=false;
    }


}
ll min_two=0;
S+=S;
pre=false;
rep(i,S.size()-1){
    if(S[i]==S[i+1]){
        if(pre){
            pre=false;
        }
        else{
        min_two++;
        pre=true;
        }
    }
    else{
        pre=false;
    }


}
cout<<min_one+(min_two-min_one)*(K-1)<<endl;

return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
int a,b,c,m,f,r;
while(1){
scanf("%d %d %d",&m,&f,&r);
if(m==-1&&f==-1&&r==-1)
break;
a=m+f;
if(a>=80)
printf("A\n");
if(a>=65&&a<80)
printf("B\n");
if(m!=-1&&f!=-1&&a>=50&&a<65)
printf("C\n");
if(m!=-1&&f!=-1&&a>=30&&a<50&&r<50)
printf("D\n");
if(m!=-1&&f!=-1&&a>=30&&a<50&&r>=50)
printf("C\n");
if(m!=-1&&f!=-1&&a<30)
printf("F\n");
if(m==-1||f==-1)
printf("F\n");
}
return 0;
}

Measured memory_bytes: 584
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=[list(sorted(ST()))[::-1] for _ in range(N)]
    ans=""
    for i in range(len(S[0])):
        s = S[0].pop()
        ok = True
        for T in S[1:]:
            if not T:
                ok = False
                break
            t = T[-1]
            while t<s:
                T.pop()
                t = T[-1]
                if t>=s:
                    break
            if t!=s:
                ok = False
                break
            else:
                T.pop()
        if ok:
            ans+=s
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long int
#define MAX_N 51
#define INF 20000000000
using namespace std;

ll n;

ll search(ll x){
    ll b = n/x;
    if((x+b)<2) return INF;
    return (x+b-2);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >>n;
    ll g = (ll) sqrtl(n);
    ll min_d = n;
    for(ll a = 1; a <= g; a++){
        if(n%a != 0) continue;
        ll dist = search(a);
        min_d = min(min_d, dist);
    }
    cout<< min_d <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    int count[n];
    count[0]=0;
    for(int i=1; i<=n; i++)
    {
        if(s[i-1]=='A'&&s[i]=='C')
        {
            count[i]=count[i-1]+1;
        }else
            {
                count[i]=count[i-1];
            }
    }
    int l[q],r[q];
    REP(i,q) {
        cin >> l[i] >> r[i];
        cout<<count[r[i]-1]-count[l[i]-1]<<endl;
    }
}

Measured memory_bytes: 2176
import java.util.Scanner;

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

        int x = stdIn.nextInt();
        int a = stdIn.nextInt();

        if (x < a)
            System.out.println(0);
        else
            System.out.println(10);
    }
}


Measured memory_bytes: 23636
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline
    n, m = [int(x) for x in input().rstrip().split(" ")]

    ans = [0 for _ in range(n)]

    for i in range(m):
        a, b = [int(x) for x in input().rstrip().split(" ")]
        ans[a-1] += 1
        ans[b-1] += 1

    print("\n".join([str(a) for a in ans]))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61912
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
  inline int pw(int a, int k) {
    int ans = 1;
    for (; k; k >>= 1, a = mul(a, a))
      if (k & 1) ans = mul(ans, a);
    return ans;
  }
  inline int inv(int n) {
    return pw(n, mo - 2);
  }
}

namespace binom {
  const int NN = 3e5 + 233;
  int fac[NN], ifac[NN];
  inline void init(void) {
    int m = 3e5;
    fac[0] = 1;
    for (int i = 1; i <= m; i ++)
      fac[i] = mul(fac[i - 1], i);
    ifac[m] = inv(fac[m]);
    for (int i = m - 1; i >= 0; i --)
      ifac[i] = mul(ifac[i + 1], i + 1);
  }

  inline int Bi(int n, int m) {
    if (n < 0) return 0;
    else if (m == n || m == 0) return 1;
    else return mul(fac[n], mul(ifac[m], ifac[n - m]));
  }
}
using namespace binom;
int A, B, C, N, ans;

/*
  1.1
  2.31
  3.333
  4.22
  4.2332
  4.23332
*/
inline int cao(int a, int b, int c, int d) {
  return mul(mul(Bi(a + b + c + d, a), Bi(b + c + d, b)),
             mul(Bi(c + d, c), Bi(d, d)));
}

int main(void) {
  init();
  read(N); read(A); read(B); read(C);
  for (int two = 0; two <= A; two ++)
    for (int three = 0; three <= C / 3; three ++) {
      int one = A - two;
      if (B % 2 == 1) continue;
      int four = B / 2;
      int resC = C - three * 3 - two;
      if (resC < 0) continue;
      auto gao = [](int n, int m) {
        if (n == 0) return 1;
        if (m == 0) return 0;
        return Bi(n + m - 1, m - 1);
      };
       // cout << one << " " << two << " " << three << " " << four << " " << mul(fac[one + two + three + four],
       //                                                                        gao(resC, four)) << "\n";
       ans = add(ans, mul(cao(one, two, three, four),
                         gao(resC, four)));
    }
  cout << ans << "\n";
}


Measured memory_bytes: 2560
N = int(input())
W = [input() for _ in range(N)]

def check() :
    siri = W[0][-1]
    double = [W[0]]
    for i in range(1, N) :
        if W[i] in double :
           return 'No'
        double.append(W[i])
        
        atama = W[i][0]
        if atama != siri :
            return 'No'
            
        siri = W[i][-1]
    return 'Yes'
    
print(check())

Measured memory_bytes: 38384
from copy import deepcopy

def color(c,h,w):
    if len(h) != 0:
        for i in h:
            for j in range(W):
                c[i][j] = 'R'

    if len(w) != 0:
        for i in w:
            for j in range(H):
                c[j][i] = 'R'

    return c

def cunt(c):
    tot = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == "#":
                tot+=1
    return tot

H,W,K = map(int, input().split())
c = []
for i in range(H):
    tmp = list(input())
    c.append(tmp)

ans = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        h = []
        w = []
        for  k in range(H):
            if ((i>>k) & 1):
                h.append(k)
        for k in range(W):
            if ((j >> k) & 1):
                w.append(k)
        _copy = deepcopy(c)
        tmp = color(_copy,h,w)
        # for _tmp in tmp:
            # print(_tmp)
        _cunt = cunt(tmp)
        # print(_cunt)
        if _cunt == K:
            ans+=1

print(ans)

Measured memory_bytes: 9356
#include<bits/stdc++.h> 
using namespace std; 
int main() 
{ 	
	cin.tie(0); 	
	cout.tie(0); 
	ios::sync_with_stdio(false); 
	int count; 	
	cin >> count; 
	int *a = new int[count]; 	
	for(int i = 0; i < count; i++)
	{
		cin >> a[i]; 
	}	
	
	deque<int> dq; 
	for (int i = 0; i < count; i++) 
	{ 		
		if (i % 2 == 0) 		
		dq.push_front(a[i]); 
		if (i % 2 == 1) 	
		dq.push_back(a[i]); 
	} 
	if (count % 2 != 0) 	
	{ 	
		for (int i = 0; i < dq.size(); i++) 		
		{ 			cout << dq[i] << " "; 		} 	
	} 
	else 
	{ 	
		for (int i = dq.size()-1; i >=0; i--) 	
		{ 			
		cout << dq[i] << " "; 	
		} 
	} 	
	return 0; 
}


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

int main () {
  int matrix[100][100]={ 0 },input_vector[100]={ 0 },output_vector[100]={ 0 },matrix_row,matrix_column,vector_column,matrix_element,vector_element,output_vector_element=0;
  cin >> matrix_row >> matrix_column;

  for (int i=0;i<matrix_row;++i) {
    for (int j=0;j<matrix_column;++j) {
	  cin >> matrix_element;
	  matrix[i][j] = matrix_element;
	}
  }
  for (int i=0;i<matrix_column;++i) {
	cin >> vector_element;
    input_vector[i] = vector_element;
  }

  for (int i=0;i<matrix_row;++i) {
    for (int j=0;j<matrix_column;++j) {
      output_vector_element = output_vector_element + (input_vector[j] * matrix[i][j]);
    }
    cout << output_vector_element <<endl;
	output_vector_element = 0;
  }
  return 0;
}

Measured memory_bytes: 3084
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();

        int ans = 0;
        for (int i = 1; i <=K ; i++) {
            for (int j = 1; j <= K; j++) {
                for (int k = 1; k <=K ; k++) {
                    ans += gcd(gcd(i,j),k);
                }
            }
        }
        System.out.println(ans);
    }

    static int gcd(int a, int b ){
        if (a == 0)
            return b;

        return gcd(b%a, a);
    }

}


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

int main(int argc, char const *argv[]) {
    long long x;
    cin >> x;

    long long m = 100;
    int year = 0;
    while (m < x) {
        m += m / 100;
        ++year;
    }

    cout << year << endl;
    return 0;
}


Measured memory_bytes: 3608