akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

string s;

LL solve(int last, bool less, int cnt)
{
    if (cnt == 1)
        return 1;
    LL ans = 0;
    int b = 1;
    bool nz = false;
    FOR(nxt, last + 1, SZ(s))
    {
        if (!less && s[nxt] == '0' && !nz)
        {
            b++;
            continue;
        }
        else
        {
            nz = true;
        }
        if (nxt != last + b || less)
        {
            ans += solve(nxt, true, cnt - 1) * 9;
        }
        else
        {
            ans += solve(nxt, false, cnt - 1);
            ans += solve(nxt, true, cnt - 1) * (s[nxt] - '1');
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> s >> k;
    LL ans = 0;
    FOR(i, 0, SZ(s))
    {
        if (i != 0)
            ans += solve(i, true, k) * 9;
        else
        {
            ans += solve(i, false, k);
            ans += solve(i, true, k) * (s[0] - '1');
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
    long long int ans=0;
    int k;

    cin>>k;

    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            int temp=__gcd(i,j);
            for(int l=1;l<=k;l++)
            {
                ans+=__gcd(temp,l);
            }
        }
    }


    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a!=c)puts("1");
	else puts("0");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int a,b; cin >> a >> b;
    cout << (a-1) * (b-1) << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int gcd(int a,int b){
	if(a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
int main(){
	int N,X;
	cin>>N>>X;
	vector<int> x(N);
	for(int i=0;i<N;i++){
		cin>>x[i];
	}
	int a=abs(X-x[0]);
	for(int i=1;i<N;i++){
		a=gcd(a,abs(X-x[i]));
	}
	cout<<a<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  double r = 0;
  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      r += x;
    } else if (u == "BTC") {
      r += 380000.0 * x;
    }
  }
  cout << fixed << setprecision(5) << r << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> cnt(MAX + 1);
    for (auto &i : A) cnt[i]++;

    vector<ll> sum(MAX + 1);
    rep(i, MAX) {
        sum[i + 1] = sum[i] + cnt[i+1] * (cnt[i+1] - 1) / 2;
    }

    for (int &i : A) {
        ll ans = sum[i - 1] + sum[MAX] - sum[i];
        ans += (cnt[i] - 1) * (cnt[i] - 2) / 2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S,ans="No";
  cin>>S;
  rep(i,0,S.size()-1){
    if(S.substr(i,2)=="AC"){
      ans="Yes";
      break;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())

stations = []
for _ in range(N-1):
    c, s, f = map(int, sys.stdin.readline().split())
    stations.append((c, s, f))

for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        c, s, f = stations[j]
        if t <= s:
            t = s + c
        else:
            tmp = t - s
            t = s + f * ((tmp - 1) // f + 1) + c

    print(t)
print(0)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
 
int dp[N][111][2];
char s[N];
int n,d;
int calc(int idx , int sum,bool b){
	
	if(idx==n){
		return !sum;
	}
 
	int&ret = dp[idx][sum][b];
	if(ret!=-1)
		return ret;
	ret = 0;
	for(int i = 0 ; i<=(b?9:(s[idx]-'0')) ; i++){
		
		ret +=calc(idx+1,(sum+i)%d,b||(i<s[idx]-'0'));
		ret%=M;
	}
 
	return ret;
}
 
int main() {
	scanf("%s",s);
	n = strlen(s);
	cin >> d;
	setDP(dp);
	cout << (calc(0,0,0)+M-1)%M<< endl;
 
 
    return 0;
}

Measured memory_bytes: 174592
from collections import defaultdict
road = int(input())
while road > 0:
    connect = defaultdict(list)
    # weight = defaultdict(defaultdict(float("inf")))
    answer = [[float("inf") if n != m else 0 for n in range(10)] for m in range(10)]
    for _ in range(road):
        c1, c2, w = (int(n) for n in input().split(" "))
        connect[c1].append(c2)
        connect[c2].append(c1)
        answer[c1][c2] = w
        answer[c2][c1] = w
    city = max(connect.keys()) + 1
    for i in range(city):
        for j in range(city):
            for k in range(city):
                answer[j][k] = min(answer[j][k], answer[j][i] + answer[i][k])
    sum_ans = [-1 , float("inf")]
    for i in range(city):
        if sum(answer[i][:city]) < sum_ans[1]:
            sum_ans = [i, sum(answer[i][:city])]
    print(*sum_ans)
    road = int(input())

Measured memory_bytes: 8044
#include <iostream>
using namespace std;
int main(){
  std::string s;
  std::string p;
  std::string g;
  cin >>  s>>  p;
  int count = 0;
  int i=0;
  int j= 0;
  int f = 0;
  for(i = 0;i < s.length();i++){
    int k = i;
    for(j = 0;j < p.length();j++){
      if(s[k] != p[j]){
        count = 0;
        break;
      }else{
        k++;
        count++;
        if(k == s.length()){
          k = 0;
        }
      }
    }
    if(count == p.length()){
      break;
    }
  }
  if(count == p.length()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<time.h>
using namespace std;
int main()
{
int h,w,l,i,j,k,n;
scanf("%d%d",&h,&w);
l=h*2;
char g[108][108]={0};
char p[308][308]={0};
getchar();
for(i=1;i<=h;i++)
{
    for(j=1;j<=w;j++)
    {
        scanf("%c",&g[i][j]);
    }
    getchar();
}
for(i=1;i<=l;i++)
{
    for(j=1;j<=w;j++)
    {
        p[i][j]=g[(i+1)/2][j];
        printf("%c",p[i][j]);
    }
    printf("\n");
}
    return 0;
}


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

inline int ctoi(char c){
  return c - '0';
}

int main(void){
  int n, k;
  std::cin >> n >> k;
  std::string s;
  std::cin >> s;

  std::vector<int> v;
  if(s[0]=='0') v.push_back(0);
  char prev='-';
  int count=0;
  for(int i=0; i<s.size(); i++){
    if(prev != s[i]){
      if(count>0) v.push_back(count);
      count = 1;
      prev = s[i];
    }else{
      count++;
    }
  }
  v.push_back(count);
  if(s[s.size()-1]=='0') v.push_back(0);

  if(v.size() <= k*2+1){
    std::cout << s.size() << std::endl;
    return 0;
  }

  //for(const auto& elem: v){
  //  std::cout << elem << " ";
  //}
  //std::cout << std::endl;
  
  int st=0, ed=2*k;
  int now_sum = 0;
  for(int i=st; i<=ed; i++){
    now_sum += v[i];
  }
  int max_sum = now_sum;
  //std::cout << st << " " << ed << " " << now_sum << std::endl;
  while(ed+2<v.size()){
    now_sum -= v[st++];
    now_sum -=v[st++];
    now_sum +=v[++ed];
    now_sum +=v[++ed];
    //std::cout << st << " " << ed << " " << now_sum << std::endl;
    if(max_sum < now_sum) max_sum = now_sum;
  }

  std::cout << max_sum << std::endl;

  return 0;
  
}


Measured memory_bytes: 1020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Weight
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (input == null)
                {
                    break;
                }
                int num = int.Parse(input);
                List<int> weight = new List<int>();
                for (int i = 9; i >=0; --i)
                {
                    double temp = Math.Pow(2, i);

                    if (temp <= num)
                    {
                        num -= (int)temp;
                        weight.Add((int)temp);
                    }
                }

                weight.Sort();
                foreach (int item in weight)
                {
                    Console.Write(item);
                    if (weight.IndexOf(item) < weight.Count - 1)
                    {
                        Console.Write(" ");
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                }
            }
        }
    }
}



Measured memory_bytes: 15880
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int h,n;
	cin>>h>>n;
	ll sum=0;
	rep(i,0,n){
		int temp;
		cin>>temp;
		sum+=temp;
	}
	if(sum>=h){
		cout<<"Yes"<<endl;
	} else{
		cout<<"No"<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

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

int main(void) {
	char s[10 + 1];
	char T[10 + 1 + 1];
	int count;

	scanf("%s",s);
	scanf("%s",T);

	count = strlen(s);
	if (count + 1 == strlen(T)) {
		if (strncmp(s,T,count)==0) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <cmath>

using namespace std;

double theta[1001];
double r[1001];

int main() {
    r[0] = 1; theta[0] = 0;
    for (int i = 1; i <= 1000; i++) {
        r[i] = sqrt(r[i-1] * r[i-1] + 1.0);
        theta[i] = theta[i-1] + asin(1.0 / r[i]);
    }

    int n;
    while (cin >> n) {
        if (n == -1) break;
        double x = r[n-1] * cos(theta[n-1]);
        double y = r[n-1] * sin(theta[n-1]);
        cout << x << endl << y << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    vector<int> B(N+1), C(N+1);
    REP(i, N) B[A[i]]++;
    REP(i, N+1) C[B[i]]++;
    vector<int> D(N+1);
    long long hoge = 0, fuga = 0;
    for(int i=1; i<=N; i++) hoge += C[i];
    for(int i=1; i<=N; i++){
        D[i] = hoge + fuga / i;
        hoge -= C[i];
        fuga += i*C[i];
    }
    //cerr << A << endl;
    //cerr << B << endl;
    //cerr << C << endl;
    //cerr << D << endl;
    vector<int> ans(N+1);
    for(int i=1; i<=N; i++){
        ans[D[i]] = i;
    }
    for(int i=N-1; i>=0; i--)
        ans[i] = max(ans[i], ans[i+1]);
    //cerr << ans << endl;
    for(int i=1; i<=N; i++)
        cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vll a(3 * n);
    for(auto& e : a) cin >> e;

    vll min_b(3 * n);
    {
        priority_queue<ll> q;
        rrep(i, 3 * n, 2 * n){
            min_b[2 * n] += a[i];
            q.push(a[i]);
        }
        rrep(i, 2 * n, n){
            ll pre_sum = min_b[i + 1];
            min_b[i] = pre_sum;

            ll cur_diff = a[i];
            ll pre_diff = q.top();
            if(pre_diff > cur_diff){
                q.pop();
                q.push(cur_diff);
                min_b[i] = pre_sum - pre_diff + cur_diff;
            }
        }
    }

    ll res = -inf;
    {
        ll sum = 0LL;
        priority_queue<ll, vll, greater<ll>> q;
        rep(i, n){
            sum += a[i];
            q.push(a[i]);
        }
        chmax(res, sum - min_b[n]);

        rep(i, n, 2 * n){
            ll cur_diff = a[i];
            ll pre_diff = q.top();
            if(pre_diff < cur_diff){
                q.pop();
                q.push(cur_diff);
                sum = sum - pre_diff + cur_diff;
            }
            chmax(res, sum - min_b[i + 1]);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6760
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f,maxn=2e5+10;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];
int a[maxn],n,m;
bool used[1000000];
int main()
{
	int i,j,k,ans=0;
	cin>>n;
	memset(used,false,sizeof(used));
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)
		if(used[a[i]]==false)
		{
			if(a[i]!=a[i+1])
				ans++;
			for(j=1;j*a[i]<=1e6;j++)
				used[j*a[i]]=true;
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4912
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    a, b, c = map(int, input().split())
    abc = a + b - c
    
    if abc < 0:
        if abc ** 2 > 4 * a * b:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

ll x = 1e9 + 7; 
const int INF = 1001001001;


int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 2000; i++) {
    if ((i*8)/100 == a && (i*10)/100 == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

int main() {
    string n;
    cin >> n;
    vector<vector<int>> dp(n.size()+1,vector<int>(2,inf));
    dp[0][0] = 0;
    rep(i,n.size()) rep(j,2) {
        int now = n[n.size()-1-i]-'0';
        if(j) {
            if(!i) continue;
            dp[i+1][0] = min(dp[i+1][0],dp[i][j]+now);
            dp[i+1][1] = min(dp[i+1][1],dp[i][j]+(9-now));
        } else {
            dp[i+1][0] = min(dp[i+1][0],dp[i][j]+now);
            dp[i+1][1] = min(dp[i+1][1],dp[i][j]+(11-now));
        }
    }
    cout << min(dp[n.size()][0],dp[n.size()][1]) << endl;
}

Measured memory_bytes: 55940
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        if (N * h * n) >= (4 * h * n - N * (h + n)) > 0:
            if (N * h * n) % (4 * h * n - N * (h + n)) == 0:
                w = (N * h * n) // (4 * h * n - N * (h + n))
                print (h, n, w)
                exit()


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

using namespace std;


struct Node
{
      string city;
      int score, id;
      Node(string city = "", int score = 0, int id = 0) : city(city), score(score), id(id) {}

      bool operator < (const Node &p) const
      {
            if (city == p.city) return score > p.score;
            return city < p.city;
      }
};

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);
      cout << fixed << setprecision(1);



      int n;
      cin >> n;

      vector <Node> vec(n);

      for (int i = 0; i < n; i++)
      {
            cin >> vec[i].city >> vec[i].score;
            vec[i].id = i + 1;
      }
      sort(vec.begin(), vec.end());
      for (Node x : vec) cout << x.id << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
    int N,A,B;
    scanf("%d %d %d",&N,&A,&B);
    if((A*N)>B){
        printf("%d\n",B);
    }else{
        printf("%d\n",A*N);
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  bool gray = false;
  bool brown = false;
  bool green = false;
  bool sky = false;
  bool blue = false;
  bool yellow = false;
  bool orange = false;
  bool red = false;
  int rainbow = 0;
  int cnt = 0;
  
  for(int j=0; j<N; j++){
    if(vec.at(j) / 400  == 0){
      gray = true;
    }
    if(vec.at(j) / 400  == 1){
      brown = true;
    }
    if(vec.at(j) / 400  == 2){
      green = true;
    }
    if(vec.at(j) / 400  == 3){
      sky = true;
    }
    if(vec.at(j) / 400  == 4){
      blue = true;
    }
    if(vec.at(j) / 400  == 5){
      yellow = true;
    }
    if(vec.at(j) / 400  == 6){
      orange = true;
    }
    if(vec.at(j) / 400  == 7){
      red = true;
    }
    if(vec.at(j) / 400  >= 8){
      rainbow++;
    }
  }
    
  if(gray){
    cnt++;
  }
  if(brown){
    cnt++;
  }
  if(green){
    cnt++;
  }
  if(sky){
    cnt++;
  }
  if(blue){
    cnt++;
  }
  if(yellow){
    cnt++;
  }
  if(orange){
    cnt++;
  }
  if(red){
    cnt++;
  }
  
  bool change = false;
  if(cnt == 0){
    change = true;
    cnt = 1;
  }
  
  cout << cnt << " ";
  if(change){
    cnt = 0;
  }
  cout << cnt + rainbow << 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>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vector<int> high(n); rep(i, n) cin >> high[i];
  vector<vector<int> > v(n);
  
  rep(i, m) {
    int x, y; cin >> x >> y;
    --x; --y;
    v[x].push_back(y);
    v[y].push_back(x);
  }

  int ans = 0;
  for(int i = 0; i < n; ++i) {
    bool flag = 1;
    for(int j = 0; j < v[i].size(); ++j) {
      if(high[v[i][j]] >= high[i]) {
	flag = 0;
	break;
      }
    }
    ans += flag;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8744
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;
const int maxn = 3e5 + 20;
int arr[maxn];
LL last[maxn], per[maxn];
priority_queue<int>que;
priority_queue<int, vector<int>, greater<int> >qq;
void work() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; ++i) {
        scanf("%d", arr + i);
    }
    LL sum = 0;
    for (int i = 3 * n; i >= 2 * n + 1; --i) {
        last[i] = (long long int)1e18;
        sum += arr[i];
        que.push(arr[i]);
    }
    last[2 * n + 1] = sum;
    for (int i = 2 * n; i >= 1; --i) {
        if (arr[i] >= que.top()) {
            last[i] = sum;
        } else {
            sum -= que.top();
            que.pop();
            sum += arr[i];
            que.push(arr[i]);
            last[i] = sum;
        }
    }
//    for (int i = 1; i <= 3 * n; ++i) {
//        printf("%d ", last[i]);
//    }
    sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += arr[i];
        qq.push(arr[i]);
        per[i] = (long long int) -1e18;
    }
    per[n] = sum;
    for (int i = n + 1; i <= 3 * n; ++i) {
        if (arr[i] <= qq.top()) {
            per[i] = sum;
        } else {
            sum -= qq.top();
            qq.pop();
            qq.push(arr[i]);
            sum += arr[i];
            per[i] = sum;
        }
    }
    LL ans = -2e18;
    for (int i = 1; i <= 3 * n - 1; ++i) {
        ans = max(ans, per[i] - last[i + 1]);
    }
    cout << ans << endl;
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    work();
    return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define foi(i,n) for(int i = 0; i < n ; ++i)
#define pi pair<int,int>
#define pb push_back
#define debug cout << "here" << endl;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

int dp[10001][101][2];

int solve(string &s,int D,int d,int pos,bool tight){
   int answer =0 ;
   int ub = tight==1?(s[pos]-'0'):9;
   if(pos == s.length()-1){
        for(int i = 0 ;i <= ub ; i++) if(i%D==d) answer = (answer +1)%mod;
        return answer;
   }

   if(dp[pos][d][tight]!=-1) return dp[pos][d][tight];



   for(int i = 0 ; i <= ub ; i++){
        bool newTight = (tight&&(i==ub));
        answer = (answer%mod + solve(s,D,(D+d-(i%D))%D,pos+1,newTight)%mod)%mod;
   }

   return dp[pos][d][tight] = (answer%mod);
}




int32_t main(){
    memset(dp,-1,sizeof(dp));
    string k;int d;
    cin >> k >> d;
    cout << (solve(k,d,0,0,1) - 1+mod)%mod;
}


Measured memory_bytes: 17152
#include<stdio.h>

int main(void) {
   int N, A, B;

   scanf("%d", &N);
   if(N==1) {
      printf("Hello World\n");
   } else if(N==2) {
      scanf("%d", &A);
      scanf("%d", &B);
      printf("%d\n", A+B);
   }

   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int h,w;
string bomb[50];

bool inside(int i,int j){
	return i>=0 && j>=0 && i<h && j<w;
}

void replace(int i,int j){
	int cnt=0;
	for(int x=i-1;x<=i+1;x++)
		for(int y=j-1;y<=j+1;y++)
			if(inside(x,y) && bomb[x][y]=='#')
				cnt++;
	bomb[i][j] = '0'+cnt;
}

int main(void){
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>bomb[i];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(bomb[i][j]=='.')
				replace(i,j);
	for(int i=0;i<h;i++)
		cout<<bomb[i]<<endl;
} 

Measured memory_bytes: 256
H,W = map(int , input().split() )

"""考え方
普通に全探索して問題あるか無いかを確認して行く。
1行目、H行目、1列目、W列目だけは少し注意！！！
→0行目、H+1行目、0列目、W+1列目を追加する
"""

list_ = []
list_.append(['.' for i in range(W+2)])
for h in range(H):
  list_.append(list('.'+input()+'.'))
list_.append(['.' for i in range(W+2)])

ans = 'Yes'
for h in range(H):
  for w in range(W):
    ## 黒にする箇所があった時に、上下左右のいずれかに黒色の箇所があればOK！！！
    if list_[h][w] == '#':
      if list_[h-1][w] == '.':
        if list_[h+1][w] == '.':
          if list_[h][w-1] == '.':
            if list_[h][w+1] == '.':
              ans = 'No'
              break

print(ans)     

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int c=0;
  for (int i = 0; i < n; i++) {
    if (i+1!=v.at(i)) {
      c++;
    }
  }
  if (c==2 || c==0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from math import atan, pi

a, b, x = map(int, input().split())

res = 0

if a * a * b / 2.0 <= x:
    res = atan(2 * (a * a * b - x) / (a * a * a))
else:
    res = pi / 2 - atan(2 * x / (a * b * b))

print(res * 180.0 / pi)


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

int main() {
  map<string, int> card;

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (card.count(s)) {
      card[s]++;
    } else {
      card.emplace(s, 1);
    }
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    if (card.count(s)) {
      card[s]--;
    }
  }

  int ans = 0;
  for (auto c : card) {
    ans = max(ans, c.second);
  }

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


Measured memory_bytes: 256
n,y=map(int,input().split())
ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        tmp=i*10000+j*5000+(n-i-j)*1000
        if tmp == y:
            ans = ' '.join(map(str,[i,j,(n-i-j)]))
print(ans)

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, X, T;
	cin >> N >> X >> T;
	int res = (N + X - 1) / X * T;
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 3648
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

int len;
char a[16],b[16],c[16];

int dfs(int i,int k,int borrow){
	int res=0;
	rep(_,2){
		if(i==len){
			if(borrow==0){
				reverse(c,c+len);
				res=max(res,atoi(c));
				reverse(c,c+len);
			}
		}
		else{
			if(a[i]-borrow>=b[i]){
				c[i]=a[i]-borrow-b[i]+'0';
				res=max(res,dfs(i+1,k,0));
			}
			else{
				c[i]=a[i]-borrow+10-b[i]+'0';
				res=max(res,dfs(i+1,k,1));
			}
		}

		if(borrow==1 && k>0){
			borrow=0;
			k--;
		}
		else break;
	}

	return res;
}

int main(){
	int k; scanf("%s%s%d",a,b,&k);
	len=strlen(a);
	reverse(a,a+len);
	reverse(b,b+strlen(b));
	for(int i=strlen(b);i<len;i++) b[i]='0';

	printf("%d\n",dfs(0,k,0));

	return 0;
}

Measured memory_bytes: 0
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)
	//i=m -> n-1(昇順)
#define RREP(i,m,n) for(LL i=(m);i>=(n);i--)
	//i=m -> n(降順)

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel";
  }
  else{
    cout << "consonant" << endl;
  }
  
  return 0;
}


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

#print(N)
#print(list)

SU = sum(list)/N
SR = round(SU)

#print(SU)
#print(SR)

ANS = 0
for i in range(N):
  temp = (list[i] - SR)
  ANS += temp*temp

print(ANS)

Measured memory_bytes: 38628
s=gets.chomp*2
t=gets.chomp
center = s.length/2

ret = 0
pos = -1
t.each_char do |c|
  idx = s.index(c, pos+1)
  if idx.nil?
    p -1
    exit 0
  end

  ret += idx - pos
  pos = idx % center
end

p ret




Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;



void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    ll n;cin>>n;
    ll t=100;
    int ct=0;
    while(t<n){
        t+=t/100;
        ct++;
    }
    cout<<ct;
}


Measured memory_bytes: 3640
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------


int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	string N;
	cin >> N;
	string ans = "No";
	if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


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

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

int32_t main()
{
     IOS;

     int n,k;
     cin>>n>>k;
     
     int temp=n/2;
     if(n%2!=0)
          temp+=1;
     if(k<=temp)
          cout<<"YES";
     else
          cout<<"NO";
     
     return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	/*
	 * 122B - 1st Solution
	 * 
	 * Idea is to try all substrings of string s
	 * Every substring is defined from character i to character j
	 * To check if a substring is AGCT is by keeping a boolean good and check whether or not any character has it
	 * If it's good then update the answer if the length of the substring is bigger
	 * The length of the substring is j - i + 1 (+1 because we include the i-th character
	 * 
	 * Time Complexity O(N^3), Memory Complexity O(N)
	 * 
	 */
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int ans = 0;
		for(int i = 0; i<N; i++) {
			for(int j = i; j<N; j++) {
				boolean good = true;
				for(int k = i; k<=j; k++) {
					if(s.charAt(k) != 'A' && s.charAt(k) != 'G' && s.charAt(k) != 'C' && s.charAt(k) != 'T') {
						good = false;
					}
				}
				if(good) {
					ans = Math.max(ans, j - i + 1);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  int Ai; cin >> Ai;
  int vmax = 0;
  int cnt = 0;
  for (int i = 1; i < N; ++i) {
    int A; cin >> A;
    if (Ai >= A) {
      Ai = A; ++cnt;
    } else {
      Ai = A; cnt = 0;
    }
    vmax = max(vmax, cnt);
  }
  cout << vmax << endl;
}


Measured memory_bytes: 3604
function Main(input) {
    var n = input;
    input = input.split("").map(Number);
    var sum = 0;
    for(var i=0;i<input.length;i++){
        sum += input[i];
    }
    console.log(n%sum==0?"Yes":"No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#include <stdio.h>

int main(void) {
    int a, b, t;
    int i = 0;
    
    while(1) {
    	scanf("%d %d", &a, &b);
    	
    	if(a == 0 && b == 0) {
    	    break;
    	}
    	
    	if(a > b) {
    	    t = a;
            a = b;
    	    b = t;
    	}
    	
    	printf("%d %d\n", a, b);
    }
    
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll a,b,c,x,y;
   cin >>a>>b>>c>>x>>y;
   ll ans=0;
   if(a+b>=2*c){
       ans+=2*c*min(x,y);

   }
   else {
       ans+=a*min(x,y);
       ans+=b*min(x,y);
   }
    if(x>=y){
        x-=y;
        y=0;
    }
    else {
        y-=x;
        x=0;
    }
   ans+=min(2*c,a)*x;
   ans+=min(2*c,b)*y;
   cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int k;
  cin >> k;
  int x = 7 % k;

  set<int> s;
  int ans = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << ans << endl;
      return 0;
    }
    s.insert(x);
    x = (x * 10 + 7) % k;
    ans++;
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 50472
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

class DisjointSet{
    public:
        vector<ll> rank,p,siz;

        DisjointSet(){}
        DisjointSet(ll size){
            rank.resize(size,0);
            p.resize(size,0);
            siz.resize(size,1);
            rep(i,size) makeSet(i);
        }

        void makeSet(ll x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(ll x, ll y){
            return root(x) == root(y);
        }

    
        void unite(ll x, ll y){
            x = root(x);
            y = root(y);
            if(rank[x] > rank[y]){
                siz[x] += siz[y];
                p[y] = x;
            }
            else{
                siz[y] += siz[x];
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            } 
        }
        ll root(ll x){
            if(x != p[x]){
                p[x] = root(p[x]);
            }
            return p[x];
        }

        ll size(ll x){
            return siz[root(x)];
        }

};

ll kruskal(int N, vector<tuple<int,int,int>> G){
	ll res = 0;
	sort(G.begin(),G.end());
	DisjointSet uf(N);
	rep(i,G.size()){
		int a,b,c;
		tie(a,b,c) = G[i];
		if(!uf.same(b,c)){
			uf.unite(b,c);
			res += a;
		}
	}
	return res;
}
int main(){
	int N; cin >> N;
	vector<Pi> x(N),y(N);
	rep(i,N){
		cin >> x[i].first >> y[i].first;
		x[i].second = i;
		y[i].second = i;
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	vector<tuple<int,int,int>> G;
	rep(i,N-1){
		G.emplace_back(x[i+1].first-x[i].first,x[i+1].second,x[i].second);
		G.emplace_back(y[i+1].first-y[i].first,y[i+1].second,y[i].second);
	}
	ll ans = kruskal(N,G);
	cout << ans << endl;
}


Measured memory_bytes: 9584
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c,d,e,f,g,h,n,m,t,res;
vector<list<ll> >adj(100001);
bitset<100001>v;
vector<ll>val(100001,1);
void hi(ll x){
    v[x]=true;
    for(auto i=adj[x].begin();i!=adj[x].end();i++){
        if(!v[*i]){
            hi(*i);
            val[x]=max(val[x],1+val[*i]);
        }
        else{
            val[x]=max(val[x],1+val[*i]);
        }
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        adj[a].push_back(b);
    }
    c=0;
    for(int i=1;i<=n;i++){
        if(v[i])continue;
        hi(i);
    }
    for(int i=1;i<=n;i++){
        c=max(c,val[i]);
    }
    cout<<c-1<<endl;
    return 0;
}


Measured memory_bytes: 7808
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

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

  int count = 0;
  while(n){
    count++;
    n /= k;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //昇順
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> result(m);
  vector<vector<int>> hoge(m, vector<int>(n));
  int tmp;
  for (int i = 0; i < m; i++){
    cin >> tmp;
    for (int v = 0; v < tmp; v++){
      cin >> hoge[i][v];
    }
  }

  for (int i = 0; i < m; i++){
    cin >> result[i];
  }
  
  int count = 0;
  int kumi = 0;
  bool f = true;
  for (int bit = 0; bit < (1 << n); bit++){
    // cout << bitset<3>(bit) << endl;
    f = true;
    for (int i = 0; i < m; i++){
      for (int v = 0; v < hoge[i].size(); v++){
        if(hoge[i][v] == 0){continue;}
        if((bit >> (hoge[i][v] - 1)) & 1){
          count += 1;
        }
      }
      if(count%2 != result[i]){
        f = false;
        // break;
      }
      count = 0;
    }
    if(f){
      // cout << bitset<3>(bit) << endl;
      kumi += 1;
    }
  }
  cout << kumi << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

void solve(string S) {
  int ans = 753;
  int n = S.size();
  for (int i = 0; i <= n - 3; i++) {
    string s = S.substr(i, 3);
    int a = stoi(s);
    ans = min(ans, abs(753 - a));
  }
  printf("%d\n", ans);
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
typedef long long ll;

int main(void) {
  ll i, j, k, n;
  scanf("%lld", &n);
  ll a[n], b[n], flag[30];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &b[i]);
  for(i = 0; i < 30; ++i) {
    ll num = 0, tb[n], ta[n], na, now = 1 << i;
    for(j = 0; j < n; ++j) ta[j] = a[j] % (1 << (i + 1));
    for(j = 0; j < n; ++j) tb[j] = b[j] % (1 << (i + 1));
    /*for(j = 0; j < n; ++j) printf("%lld ", ta[j]);
    printf("\n");
    for(j = 0; j < n; ++j) printf("%lld ", tb[j]);
    printf("\n\n");*/
    std::sort(tb, tb + n);
    for(j = 0; j < n; ++j) {
      na = std::lower_bound(tb, tb + n, 2 * now - ta[j]) - std::lower_bound(tb, tb + n, now - ta[j]);
      na += std::lower_bound(tb, tb + n, 4 * now - ta[j]) - std::lower_bound(tb, tb + n, 3 * now - ta[j]);
      //printf("%lld ", na);
      num += na % 2;
      num %= 2;
    }
    if(num) flag[i] = 1;
    else flag[i] = 0;
  }
  ll ans = 0;
  for(i = 0; i < 30; ++i) if(flag[i]) ans += 1 << i;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B;
  cin >> A >> B;

  if (1 <= A && A <= 9 && 1 <= B && B <= 9){
    cout << A*B << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256