akhauriyash/Code-Regression huggingface dataset:
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define double long double
    const int INF=0x3f3f3f3f;
    const ll LLINF=0x3f3f3f3f3f3f3f3fll;
    ll qread()
    {
        ll ans=0;char c=getchar();int f=1;
        while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) {num=-num;putchar('-');}
        if(num>9) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);puts("");}
    #define FR first
    #define SE second
    #define MP make_pair
    #define pr pair<int,int>
    #define PB push_back
    #define vc vector
    void chmax(int &x,const int y) {x=x>y?x:y;}
    void chmin(ll &x,const int y) {x=x<y?x:y;}
    const int MAX_N=2e2+10,MAX_M=1e5+10;
    const ll MOD=1e9+7;
    void add(int &x,int y) {x+=y;if(x>=MOD) x-=MOD;if(x<0) x+=MOD;}

    ll f[MAX_N][MAX_M];int a[MAX_N];
    void main()
    {
        int n=qread(),now=qread();for(int i=1;i<=n;i++) a[i]=qread();sort(a+1,a+n+1);reverse(a+1,a+n+1);
        for(int i=0;i<MAX_M;i++) f[n][i]=i%a[n];
        for(int i=n-1;i>=1;i--)
            for(int j=0;j<MAX_M;j++)
                f[i][j]=(f[i+1][j%a[i]]+f[i+1][j]*(n-i)%MOD)%MOD;
        write(f[1][now]);
    }
};
int main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 157184
#include<iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
long long A[100001];
long long root(int x){
    if(A[x]==x) return x;
    else return A[x]=root(A[x]);
}
int main(){
    long long n,m,B[200000][2];
    long long ans[200000]={0},C[200000];
    cin>>n>>m;
    for(int i=1;i<=n;i++) A[i]=i;
    rep(i,n) C[i+1]=1;
    rep(i,m) cin>>B[i][0]>>B[i][1];
    rep(i,m){
        long long a=B[m-i-1][0],b=B[m-i-1][1];
        if(root(a)==root(b)) ans[i+1]=ans[i];
        else{
            a=root(a),b=root(b);
            if(a<b) {long long c=a;a=b,b=c;}
            A[a]=b;
            long long x=C[a],y=C[b];
            C[b]+=C[a],C[a]=0;
            ans[i+1]=ans[i]-x*(x-1)/2-y*(y-1)/2+C[b]*(C[b]-1)/2;
        }
    }
    long long z=n*(n-1)/2;
    rep(i,m) cout<<z-ans[m-i-1]<<endl;
}

Measured memory_bytes: 8192
# -*- coding: utf-8 -*-
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
diff_A = []
for n in range(N-1):
    diff_A.append(A[n+1] - A[n])
diff_A.append(K - A[-1] + A[0])

print(sum(diff_A)-max(diff_A))        


Measured memory_bytes: 25832
#include <bits/stdc++.h>
#define inf 0x3f3f3f
using namespace std;
int main()
{
    int a,b;
    char c;
    scanf("%d %c %d",&a,&c,&b);
    if(c=='+')
        printf("%d\n",a+b);
    else
        printf("%d\n",a-b);
    return 0;
}
















//int n,m;
//struct node
//{
//    int u,w;
//};
//int u,v,w;
//vector<node>vec[1005];
//queue<int>q;
//int dis[1005],vis[1005];
//void spfa()
//{
//    while(!q.empty())
//        q.pop();
//    q.push(1);
//    dis[1]=0;
//    vis[1]=1;
//    while(!q.empty())
//    {
//        int now=q.front();
//        q.pop();
//        vis[now]=0;
//        int len=vec[now].size();
//        for(int i=0;i<len;i++)
//        {
//            node next=vec[now][i];
//            int nu=next.u,nw=next.w;
//            if(dis[nu]>dis[now]+nw)
//            {
//                dis[nu]=dis[now]+nw;
//               if(vis[next.u]==0)
//               {
//                   q.push(next.u);
//                   vis[next.u]=1;
//               }
//            }
//
//        }
//    }
//}
//int main()
//{
//    int t;
//    scanf("%d",&t);
//    for(int k=1;k<=t;k++)
//    {
//        scanf("%d%d",&n,&m);
//        memset(dis,inf,sizeof(dis));
//        memset(vis,0,sizeof(vis));
//       for(int i=0;i<m;i++)
//       {
//           scanf("%d %d %d",&u,&v,&w);
//           vec[u].push_back({v,w});
//           vec[v].push_back({u,w});
//       }
//       spfa();
//       printf("Scenario #%d:\n%d\n",k,dis[n]);
//    }
//    return 0;
//}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N, M;
bool E[601][601];
int kazu[601];
double memo[601];
double dfs(int v) {
	if (memo[v] != -1) return memo[v];
	double ret = 0;
	for (int i = v + 1; i <= N; i++) if (E[v][i]) {
		ret += dfs(i);
	}
	return memo[v] = 1 + ret / kazu[v];
}

double K[601];
double omomi(int v) {
	if (K[v] != -1) return K[v];
	double ret = 0;
	rep1(i, v - 1) if (E[i][v]) {
		ret += omomi(i) / kazu[i];
	}
	return K[v] = ret;
}

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


	N = getint(), M = getint();
	rep1(i, M) {
		int s = getint();
		kazu[s]++;
		E[s][getint()] = 1;
	}

	rep1(i, N) memo[i] = -1;
	memo[N] = 0;

	double kotae = dfs(1);

	rep1(i, N) K[i] = -1;
	K[1] = 1;

	double saishou = 0;
	rep1(i, N) {
		if (kazu[i] > 1) {
			double saidai = 0;
			double kei = 0;
			for (int j = i + 1; j <= N; j++) if (E[i][j]) {
				kei += dfs(j);
				chmax(saidai, dfs(j));
			}
			double are = (kei - saidai) / (kazu[i] - 1) - kei / kazu[i];
			are *= omomi(i);
			chmin(saishou, are);
		}
	}

	printf("%.12f", kotae + saishou);

	Would you please return 0;
}

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

lint n, k, q;
multiset<lint> as;

int main() {
    cin >> n >> k >> q;
    for(lint i = 0; i < q; i++) {
        lint a;
        cin >> a;
        as.insert(--a);
    }

    for(lint i = 0; i < n; i++) {
        lint c = as.count(i);
        cout << (k - (q - c) <= 0 ? "No" : "Yes") << endl;
    }
}

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

int main(){
  string s;
  cin >> s;
  string word;
  int n = s.length();
  for(int i=0;i<n;i++){
    word+="x";
  }
  s.replace(0,n,word);
  cout << s << endl;

}

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

using namespace std;

vector<long long> enumDivisor(long long n){
    vector<long long> res;
    for(long long i = 1; i*i <= n; i++){
        if(n % i) continue;
        res.push_back(i);
        if(i*i != n) res.push_back(n/i); 
    }
    return res;
}

int main()
{
    long long n;
    cin >> n;
    int ans = 0;
    vector<long long> nDivisor = enumDivisor(n);
    for(long long i : nDivisor){
        if(i == 1) continue;
        long long tmp = n;
        while(tmp % i == 0) tmp /= i;
        if(tmp % i == 1) ans++;
    }
    vector<long long> nMinusDvisior = enumDivisor(n-1);
    ans += nMinusDvisior.size() -1;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

pair<double, double> operator+(const pair<double, double> &a, const pair<double, double> &b){
    return make_pair(a.first+b.first, a.second+b.second);
}
pair<double, double> operator-(const pair<double, double> &a, const pair<double, double> &b){
    return make_pair(a.first-b.first, a.second-b.second);
}
pair<double, double> operator*(const pair<double, double> &a, const double &b){
    return make_pair(a.first*b, a.second*b);
}
pair<double, double> operator*(const double &b, const pair<double, double> &a){
    return make_pair(a.first*b, a.second*b);
}
pair<double, double> operator/(const pair<double, double> &a, const double &b){
    return make_pair(a.first/b, a.second/b);
}
pair<double, double> rot90(const pair<double, double> &a){
    return make_pair(-a.second, a.first);
}

void next_koch(vector<pair<double, double>> &pts){
    vector<pair<double, double>> new_pts;
    new_pts.push_back(pts[0]);
    for(int i=1;i<pts.size();i++){
        auto a = pts[i-1], b = pts[i];
        new_pts.push_back(a+(b-a)/3.0);
        new_pts.push_back(a+(b-a)/2.0+rot90(b-a)*sqrt(3)/6.0);
        new_pts.push_back(a+2.0*(b-a)/3.0);
        new_pts.push_back(b);
    }
    pts.clear();
    for(int i=0;i<new_pts.size();i++) pts.push_back(new_pts[i]);
}

int main(){
    vector<pair<double, double>> pts;
    pts.push_back(make_pair(0.0, 0.0));
    pts.push_back(make_pair(100.0, 0.0));
    
    int n;
    cin >> n;
    for(int i=0;i<n;i++) next_koch(pts);

    for(int i=0;i<pts.size();i++) cout << pts[i].first << ' ' << pts[i].second << endl;
    return 0;
}


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    string s;
    cin>>n;
    cin>>s;
   // sort(s.begin(),s.end());
    //cout<<s<<endl;
    int d=s.size();
    for(int i=0;i<d;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            c++;
    }

    cout<<c<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int A,B;
  int sub;
  int count;
  int result;
  int loop,digit_loop;
  
  cin >> A >> B;
  sub = B-A;
  //cout << sub << endl;
  
  for(loop=0;loop <= sub; loop++){
    int number = A+loop;
    int digit = 0;
    int number_sep[5];
    //cout << number << endl;
    
    for(digit_loop=0;digit_loop < 5; digit_loop++){
      number_sep[digit] = number % 10;
      number = number /10;
      //cout << number_sep[digit] <<" " <<  digit << endl;
      digit++; 
    }
    if((number_sep[digit-1] == number_sep[0] )
     && (number_sep[digit-2] == number_sep[1] )){
      result++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int s, w;
  cin >> s >> w;
  if (w >= s) cout << "unsafe\n";
  else cout << "safe\n";
  return 0;
}

Measured memory_bytes: 3640
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

const mod = 10^^9+7;
alias mint = FactorRing!mod;

void main()
{
  int n, k; readV(n, k);
  int[] a; readA(n, a);

  auto dp = new mint[][](n+1, k+1);
  dp[0][0] = 1;

  foreach (i; 1..n+1) {
    auto dps = dp[i-1].cumulativeSum;
    foreach (j; 0..k+1)
      dp[i][j] = dps[max(0, j-a[i-1])..j+1];
  }

  writeln(dp[$-1][$-1]);
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) union { long vl; struct { int vi2; int vi; } } else union { long vl; int vi; }
  alias FR = FactorRing!(m, pos);
  @property static init() { return FR(0); }
  @property int value() { return vi; }
  @property void value(int v) { vi = mod(v); }
  alias value this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref auto opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const { static if (pos) return v%m; else return (v%m+m)%m; }
  pure auto mod(long v) const { static if (pos) return cast(int)(v%m); else return cast(int)((v%m+m)%m); }

  static if (!pos) pure ref auto opUnary(string op: "-")() { return FR(mod(-vi)); }

  static if (m < int.max / 2) {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vi"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vi"~op~"r")); return this; }
  } else {
    pure ref auto opBinary(string op)(int r) if (op == "+" || op == "-") { return FR(mod(mixin("vl"~op~"r"))); }
    ref auto opOpAssign(string op)(int r) if (op == "+" || op == "-") { vi = mod(mixin("vl"~op~"r")); return this; }
  }
  pure ref auto opBinary(string op: "*")(int r) { return FR(mod(vl*r)); }
  ref auto opOpAssign(string op: "*")(int r) { vi = mod(vl*r); return this; }

  pure ref auto opBinary(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opBinary!op(r.vi); }
  ref auto opOpAssign(string op)(ref FR r) if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(r.vi); }
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c;
  if(a<b){
    d=a;
    a=b;
    b=d;
  }
  if(a<c){
    d=a;
    a=c;
    c=d;
  }
  cout<<10*a+b+c<<endl;
  
  return 0;
  
}
  

Measured memory_bytes: 256
def main():
    n = int(input())
    v = [int(i) for i in input().split()]
    c = [int(i) for i in input().split()]
    #b = input()
    ans = 0
    for i in range(n):
        if v[i] - c[i] > 0:
            ans += v[i] - c[i]

    print(ans)

main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n; cin >> n;
    vint x(n),y(n),h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];

    FOR(cx,0,101){
        FOR(cy,0,101){
            //int H=h[0]+abs(x[0]-cx)+abs(y[0]-cy);
            int H;
            rep(i,n){
                if(h[i]!=0){
                    H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                }
            //cout<<H<<endl;
            //if(H==1) cout<<cx<<cy<<H<<endl;
            }
            bool can=true;
            rep(i,n){
                //if(h[i]==0) continue;
                if(h[i]==0){
                    if(H-abs(x[i]-cx)-abs(y[i]-cy)>0){
                        can=false;
                        break;
                    }
                }else if(H!=h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
                    can=false;
                    break;
                }
            }
            if(can) cout<<cx<<' '<<cy<<' '<<H<<endl;
        }
    }
    
    rep(i,n){
        //cout<<"max{H-|"<<x[i]<<"-Cx|-|"<<y[i]<<"-Cy|,0}="<<h[i]<<endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 3e5;
const char newl = '\n';

vl parent(MAX), depth(MAX);
 
ll find(ll x) {if(parent[x]==x) return x; return parent[x] = find(parent[x]);}
 
void unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  
  if(depth[x] < depth[y]) {
    parent[x] = y;
  }else {
    parent[y] = x;
    if(depth[x] == depth[y]) depth[x]++;
  }
}

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

  ll h, w, m;
  cin >> h >> w >> m;
  
  vl column(h), row(w);
  map<pl, ll> exist_bomb;

  ll x, y;
  rep(i, m) {
    cin >> x >> y;
    x--; y--;
    
    column[x]++;
    row[y]++;
    exist_bomb[pl (x, y)] = 1;
  }
  
  ll cmax=0, rmax=0;
  rep(i, h) chmax(cmax, column[i]);
  rep(i, w) chmax(rmax, row[i]);
  
  vl C, R;
  rep(i, h) if(column[i] == cmax) C.push_back(i);
  rep(i, w) if(row[i] == rmax) R.push_back(i);

  for(ll i: C) for(ll j: R) {
    if(exist_bomb[pl (i, j)] != 1) {cout << cmax + rmax << newl; return 0;}
  }
  
  cout << cmax + rmax - 1 << newl;
  return 0;
}

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

def solve(N: int, X: int):
    # amount[i] = level iバーガーのP+Bの総数
    amount = [0]*N
    amount[0] = 5
    for i in range(N-1):
        amount[i+1] = amount[i]*2 + 3

    # amount[i] = level iバーガーのPの総数
    p_amount = [0]*N
    p_amount[0] = 3

    for i in range(N-1):
        p_amount[i+1] = p_amount[i]*2 + 1
    
    # レベルNバーガーの下からX個に含まれるPの個数を返す
    def dfs(n,x) -> int:
        if x == 0:
            return 0
            
        if n == 1:
            if x == 1 or x == 0:
                return 0
            elif 2<= x <= 4:
                return x-1
            else:
                return 3


        half = (amount[n-1]-3)//2 + 1
        if x <= half:
            return dfs(n-1,x-1)
        else:
            res = x-half-1
            return p_amount[n-2]+1+dfs(n-1,res)
    
    print(dfs(N,X))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        if(a < b && b < c)System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 26216
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

const int MaxN = 2e5 + 5;

vector<int> gb[MaxN], gr[MaxN];

int dep[MaxN], fa[MaxN], d[MaxN];
bool safe[MaxN], vis[MaxN];

int main() {
  ios_base::sync_with_stdio(false);
  int n, sx, sy;
  cin >> n >> sx >> sy;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    gr[x].emplace_back(y);
    gr[y].emplace_back(x);
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    gb[x].emplace_back(y);
    gb[y].emplace_back(x);
  }
  queue<int> Q;
  Q.push(sy);
  fa[sy] = -1;
  vis[sy] = true;
  while (!Q.empty()) {
    int k = Q.front();
    for (int x : gb[k]) {
      if (!vis[x]) {
        Q.push(x);
        vis[x] = true;
        dep[x] = dep[k] + 1;
        fa[x] = k;
      }
    }
    Q.pop();
  }
  for (int i = 1; i <= n; ++i) {
    for (int k : gr[i]) {
      if (![](int x, int y) -> bool {
        return fa[x] == fa[y] || fa[x] == y || x == fa[y] || fa[fa[x]] == y || x == fa[fa[y]];
      } (i, k)) {
        safe[i] = safe[k] = true;
      }
    }
  }
  if (safe[sx]) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  memset(d, 0xff, sizeof d);
  d[sx] = 0;
  Q.push(sx);
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    if (d[k] >= dep[k]) {
      continue;
    }
    if (safe[k]) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, dep[k] * 2);
    for (int x : gr[k]) {
      if (vis[x] && d[k] + 1 < dep[x] && [](int x, int y) -> bool {
        return fa[x] == fa[y] || fa[x] == y || x == fa[y] || fa[fa[x]] == y || x == fa[fa[y]];
        } (k, x)) {
        d[x] = d[k] + 1;
        vis[x] = false;
        Q.push(x);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    string s;
 	cin >> s;
    rep(i,s.size()){
        if((i+1)%2 == 0) {
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n,m,l = map(int, input().split())

d=[[sys.maxsize]*(n) for _ in range(n)]
e=[[sys.maxsize]*(n) for _ in range(n)]
for i in range(n):
  d[i][i] = 0
  e[i][i] = 0

for _ in range(m):
  a,b,c = map(int, input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

d=floyd_warshall(csr_matrix(d))
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      e[i][j] = 1

e=floyd_warshall(csr_matrix(e))

q=int(input())
for _ in range(q):
  s,t = map(int, input().split())
  if e[s-1][t-1] == sys.maxsize:
    print(-1)
  else:
    print(int(e[s-1][t-1]-1))

Measured memory_bytes: 21104
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

char s[26+1]; int slen;

int idx[26];

void run() {
	scanf("%s",s); slen=strlen(s);

	REP(i,26) idx[i]=-1; REP(i,slen) idx[s[i]-'a']=i;
	REP(i,26) if(idx[i]==-1) {
		s[slen++]='a'+i; s[slen]='\0'; printf("%s",s); return;
	}
	for(int i=slen-1;i>=0;--i) {
		int x=s[i]-'a';
		FOR(y,x+1,26) if(idx[y]>i) {
			s[i]='a'+y; slen=i+1; s[slen]='\0'; printf("%s",s); return;
		}
	}
	printf("-1\n");
}

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


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

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; string s;
  cin >> n >> s;
  int count = 0;
  for(int i=0; i<n-2; ++i){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') count++;
  }
  cout << count ;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
template<class T> _inline void read(T &x){
	T res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
template<class T> inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int h,a;
int main(){
	read<int>(h);
	read<int>(a);
	int ans;
	if(h%a==0) ans=h/a;
	else ans=h/a+1;
	print<int>(ans);
	puts("");
	exit(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  ll ans = 999999999999;
  ll left = A[0];
  ll right = sum - A[0];
  for (int i = 1; i < N; i++) {
    ll res = abs(right - left);
    ans = min(ans,res);
    left += A[i];
    right -= A[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5128
//c++

#include <bits/stdc++.h>
#define F_I ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
typedef long long ll;

int main()
{
	F_I;
	
	int input;
	cin >> input;
	if (input == 1)
		cout << 0 << '\n';
	else
		cout << 1 << '\n';
	return 0;
}

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

int N, M;
string s[100], t[100];

int main(){
    cin >> N;
    for(int i=0;i<N;i++)    cin >> s[i];
    cin >> M;
    for(int i=0;i<M;i++)    cin >> t[i];
    
    int ans = 0;
    for(int i=0;i<N;i++){
        int res = 0;
        for(int j=0;j<N;j++){
            if(s[i] == s[j])    res++;
        }
        for(int j=0;j<M;j++){
            if(s[i] == t[j])    res--;
        }
        ans = max(ans, res);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll n;string s,t;cin>>n>>s>>t;
  string ans="";
  for(ll i=0;i<n;i++){
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;

	std::vector<std::string> wdays = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	auto it = std::find(wdays.begin(), wdays.end(), S);
	std::cout << (wdays.end() - it) << "\n";
}


Measured memory_bytes: 512
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

for n, i in enumerate(permutations(sorted(p))):
    if i == p:
        pn = n

for n, i in enumerate(permutations(sorted(q))):
    if i == q:
        qn = n
print(abs(pn-qn))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W,N;
  cin >> H >> W >> N;
  
  vector<string> S(H);
  for (int i=0; i<H; i++) cin >> S.at(i);
  
  vector<pair<int,int>> cheese_map(N+1);
  for (int i=0; i<H; i++) {
     for (int j=0; j<W; j++) {
       char c = S.at(i).at(j);
       if ( '1' <= c && c <= '9' ) {
         int n = c - '0';
         cheese_map.at(n) = make_pair( j, i);
       }
       if ( c == 'S') cheese_map.at(0) = make_pair( j, i);
     }
  }
  int time = 0;
  vector<int> xm = {-1, 0, 1, 0};
  vector<int> ym = { 0,-1, 0, 1};
  queue<pair<int, int>> q;
  
  for(int i=0; i<N; i++) {
    vector<vector<int>> time_map(H, vector<int>(W, -1));
    pair<int, int> st = cheese_map.at(i);
    pair<int, int> gl = cheese_map.at(i+1);
    time_map.at( st.second ).at( st.first ) = time;
    q.push( st );
    
    while (!q.empty()) {
      pair<int, int> sp = q.front(); 
      int sx = sp.first;
      int sy = sp.second;
      q.pop();
      
      for (int i=0; i<4; i++) {
        int x = sx + xm.at(i);
        int y = sy + ym.at(i);
        if ( x < 0 || W <= x ) continue;
        if ( y < 0 || H <= y ) continue;
        if ( S.at(y).at(x) == 'X' ) continue;
        if ( time_map.at(y).at(x) == -1) {
          q.push( make_pair( x, y ) );
          time_map.at(y).at(x) = time_map.at(sy).at(sx) + 1;
        }
      }
    }
    time = time_map.at( gl.second ).at( gl.first );
  }
  
  cout << time << endl;

}


Measured memory_bytes: 7696
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#define int long long
using namespace std;
vector<int>p, ps;
bool b[5736397];
void f(int k) {
	p.push_back(k);
	ps.push_back(ps.back() + k);
	b[ps.back()] = 1;
	return;
}
signed main() {
	ps.push_back(0); b[0] = 1;
	f(2);
	for (int i = 3; i <= 10000; i += 2) {
		bool b00l = 1;
		for (int j = 0; j < p.size(); j++) 
			if (i%p[j] == 0)b00l = 0;
		if (b00l)f(i);
	}
	int n;
	while (cin >> n, n) {
		int ans = 0;
		for (int i = 0; i < ps.size(); i++) {
			if (ps[i] - n < 0)continue;
			if (b[ps[i] - n])ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 6888
import numpy as np
sheet = np.zeros((3,3))
for i in range(3):
    sheet[i] = list(map(int, input().split()))

N = int(input())

for _ in range(N):
    b = int(input())
    for r in range(3):
        for c in range(3):
            if sheet[r,c] == b:
                sheet[r,c] = 0

rows = np.sum(sheet, axis=0)
if 0 in list(rows):
    print("Yes")
    exit()
cols = np.sum(sheet, axis=1)
if 0 in list(cols):
    print("Yes")
    exit()
if (sheet[0,0] + sheet[1,1] + sheet[2,2]) == 0:
    print("Yes")
    exit()
if (sheet[0,2] + sheet[1,1] + sheet[2,0]) == 0:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 21820
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
int n;cin>>n;
string s;
int i;
for(i=0;i<n;i++){
  cin>>s[i];
}
int red=0,black=0;
for(i=0;i<n;i++){
  if(s[i]=='R') red++;
  else black++;
}

if(red>black) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long int
    #define ld long double
    #define yorn(f) cout<<((f)?"Yes":"No")<<endl;
    #define YORN(f) cout<<((f)?"YES":"NO")<<endl;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define repi(i, n) for (int i = 1; i < (int)(n); i++)
    #define all(x) (x).begin(), (x).end()
    #define put(x) cout << x << endl;
    #define println(x) cout << x << endl;
    using namespace std;
    int main()
    {
        int n, m;
        cin >> n >> m;

        if (abs(n - m) >= 2) {
            put(0);
            return 0;
        }

        ll MOD = 1000000007;
        ll N = 1;
        repi(i, n + 1) N = (N * i) % MOD;
        ll M = 1;
        repi(i, m + 1) M = (M * i) % MOD;

        if (abs(n - m) == 1) {
            // n! * m!;
            put((N * M) % MOD);
        }
        else {
                put(( ((2 * N) % MOD) * M) % MOD);
        }
        return 0;
    }


Measured memory_bytes: 3616
n = gets.to_i
as = gets.split.map(&:to_i)

x = as.first
y = as.inject(:+) - x
ans = (x - y).abs

1.upto(n - 2) do |i|
  a = as[i]

  x += a
  y -= a
  diff = (x - y).abs
  ans = diff if diff <= ans
end

puts ans


Measured memory_bytes: 27304
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  vector<int> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];

  vector<int> used(N);
  int ret = 0;
  for (int i = 0; i < N; ++i) {
    if (used[i])
      continue;
    if (i + 1 == a[a[i] - 1]) {
      ++ret;
      used[i] = 1;
      used[a[i] - 1] = 1;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 1024
<?php
$a = str();
$b = str();

echo lcstr($a, $b);

function lcstr($str1, $str2){
    global $dp,$dpf;
    lcs($str1, $str2);
    $i = strlen($str1) - 1;
    $j = strlen($str2) - 1;
    $ret = '';
    while($i >= 0 && $j >= 0){
        switch($dpf[$i][$j]){
            case 1:
                $ret .= $str1[$i];
                $i--;$j--;
                break;
            case 2:
                $i--;
                break;
            case 3:
                $j--;
                break;
        }
    }
    return strrev($ret);
}

function lcs($str1, $str2){
    global $dp,$dpf;
    $l1 = strlen($str1);
    $l2 = strlen($str2);
    $dp = array_fill(-1, $l1+1, array_fill(-1, $l2+1, 0));
    for($i = 0; $i < $l1; $i++){
        $dpb = $dp[$i-1];
        $dpi = &$dp[$i];
        $si = $str1[$i];
        $dpfi = [];
        for($j = 0; $j < $l2; $j++){
            if($si == $str2[$j]){
                $dpi[$j] = $dpb[$j-1] + 1;
                $dpfi[$j] = 1;//斜めからきた
            }elseif($dpb[$j] > $dpi[$j-1]){
                $dpi[$j] = $dpb[$j];
                $dpfi[$j] = 2;//上からきた
            }else{
                $dpi[$j] = $dpi[$j-1];
                $dpfi[$j] = 3;//左からきた
            }
        }
        $dpf[] = $dpfi;
    }
    return $dp[$l1 - 1][$l2 - 1];
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}


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

int main(){
  int A,B;
  cin>>A>>B;
  int z = 0;
  while(A<=B){
    if(A/10000 == A%10){
      if((A-A/10000*10000)/1000 == (A-A%10)/10%10)
        z++;
    }
  A++;
  }
  cout<<z<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;

ll N;
ll ans = 0;

ll rec(ll n, ll m) {

  if (n <= N) {
    if ( (m & (1<<0)) && (m & (1<<1)) && (m & (1<<2)) ) ans++;
  }
  else {
    return 0;
  }
  
  rec(n*10 + 3, m | 1);
  rec(n*10 + 5, m | 2);
  rec(n*10 + 7, m | 4);

  return 0;
  
}

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

  cin >> N;

  rec(3, 1<<0);
  rec(5, 1<<1);
  rec(7, 1<<2);

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


Measured memory_bytes: 3172
# 10_C
import math

while True:
    n = int(input())
    if n == 0:
        break
    else:
        sigma = 0
        n_list = list(map(int, input().split()))
        avg = sum(n_list) / n
        for i in range(n):
            sigma += (n_list[i] - avg) ** 2
        a = math.sqrt(sigma / n)
        print(abs(a))


Measured memory_bytes: 5696
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]

flag = 0
for i in range(n):
    if data[i][2] > 0:
        flag = 1
        break

if flag == 0:
    print(data[0][0], data[0][1], 0)
else:
    for cx in range(0, 101):
        for cy in range(0, 101):
            for i in range(n):
                if data[i][2] > 0:
                    H = abs(data[i][0]-cx) + abs(data[i][1]-cy) + data[i][2]
            check = 0
            for i in range(n):
                if data[i][2] != max(0, H - abs(data[i][0]-cx) - abs(data[i][1]-cy)):
                    check = 1
            if check == 0:
                print(cx, cy, H)
                exit()

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int dp[1<<16];
int d[16][17];

int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++)
			for(int j=0;j<n+1;j++)
				scanf("%d",&d[i][j]);
		for(int i=0;i<(1<<16);i++) dp[i]=(1<<30);
		dp[0]=0;
		for(int i=0;i<(1<<n);i++) {
			for(int j=0;j<n;j++) {
				if(!(i&(1<<j))) {
					int v=d[j][0];
					for(int k=0;k<n;k++)if(i&(1<<k))v=min(v,d[j][k+1]); 
					dp[i+(1<<j)]=min(dp[i+(1<<j)],dp[i]+v);
				}
			}
		}
		printf("%d\n",dp[(1<<n)-1]);
	}
}

Measured memory_bytes: 1284
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k;cin>>k;
  ll t=7%k;
  rep(i,0,3000000){
    if(t==0){
      cout<<i+1<<endl;
      return 0;
    }
    t=(10*t+7)%k;
  }
  cout<<-1<<endl;
  return 0;
}

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

int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long i,j,n,a,b,c,d,ans,A,B;
	string s1,s2,s3;
	cin>>a>>b;
	if(b>=a)cout<<"unsafe";
	else cout<<"safe";
	
	
    }
	return 0;
}

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

using namespace std;

int main()
{
	int N, K;
  int x = 1;

  cin >> N >> K;
  
  for(int i = 0; i < N; i++){
   if(x > K)
     x += K;
	else
      x *= 2;
  }
  cout << x << endl;
  
}

Measured memory_bytes: 256
def check (A):
    for i in range(len(A)-1):
        if A[i]*A[i+1] == 1:
            return False
            break
    return True

def check_zero (B):
    for i in range(len(B)-2):
        if B[i] == 0 and B[i+1] == 0 and B[i+2] == 0:
            return True
            break
    return False

[N,A,B,C,D] = list(map(int,input().split()))
S_ori = str(input())
S = [0]*len(S_ori)
for i in range(len(S)):
    if S_ori[i] == ".":
        S[i] = 0
    else:
        S[i] = 1

if D > C:
    if check(S[B-1:D]) == False:
        print("No")
    else:
        if check(S[A-1:C]) == True:
            print("Yes")
        else:
            print("No")
else:
    if check(S[B-1:D]) == False:
        print("No")
    else:
        if check_zero(S[B-2:D+1]) == True:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 5956
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    bool f=false;
    for(int i=0;i<S.length();i++){
        if(S==T){
            f=true;
            break;
        }
        string tmp = S.substr(1);
        S = tmp+S[0];
    }
    if(f) cout << "Yes" << endl;
    else  cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input()) 
en = str(n)
if (en[-1:]=="2" or en[-1:]=="4" or en[-1:]=="5" or en[-1:]=="7" or en[-1:]=="9"):
	print("hon")
elif (en[-1:]=="0" or en[-1:]=="1" or en[-1:]=="6" or en[-1:]=="8"):
	print("pon")
else:
	print("bon")

Measured memory_bytes: 9072
s = input()
l = s[2:len(s)-1]
for i in s:
    if i not in "abcdefghijklmnopqrstuvwxyzAC":
        print("WA")
        exit()
else:
    if s[0]=="A" and l.count("C")==1:
        print("AC")
    else:
        print("WA")

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

bool comp(P x,P y){return x.first <y.first ;}


int main(){
    int N,M;
    ll ans=0;ll total;
    cin >>N >>M;
    vector<P> A(N);
    for (int i=0;i<N;i++){
        cin >>A[i].first >>A[i].second;
    }
    sort(A.begin(),A.end(),comp);

    total=M;
   for (int i=0;i<N;i++){
    ll val;ll hon;
    val=A[i].first;
    hon=A[i].second;
    if(total>hon){
        total-=hon;
        ans+=hon*val;
       // cout <<val <<" " <<hon << " " <<idx <<endl;
    }else{
        ans+=total*val;
         //    cout <<val <<" " <<total << " " <<idx <<endl;

        break;
    }

   }
    cout <<ans <<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 998244353
#define mkp make_pair
typedef long long ll;
using namespace std;

#define MAX_N 4000040
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

int main(){
  ll N,M;
  cin>>N>>M;

  setComb();

  ll nans=0;
  for(ll k=0;k<M;k++){
    ll res=hcomb(N-1,k);
    mul(res,N);
    add(nans,res);
  }

  ll ans=0;
  for(ll k=0;k<=min(N,M);k++){
    if(k%2!=M%2) continue;
    ll res=hcomb(N,(3*M-k)/2);
    mul(res,comb(N,k));
    add(ans,res);
  }

  add(ans,-nans+MOD);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 93952
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=0;i<b+2;i++) cout<<"#";
    cout<<endl;
    for(int i=0;i<a;i++)
    {
        string s;
    cin>>s;
        cout<<"#"<<s<<"#"<<endl;
    }
     for(int i=0;i<b+2;i++) cout<<"#";
}

Measured memory_bytes: 256
Program ABC159B
   implicit none
   integer::n,m,i,j,judge
   character(100)::s,t

      read(*,*) s
      n=len_trim(s)
      t=s(1:(n-1)/2)
      m=len_trim(t)

      do i=1,(n-1)/2
         if (s(i:i)/=s(n-i+1:n-i+1)) then
            judge=0
            exit
         else
            judge=1
         end if
      end do

      if (judge==1) then
         do j=1,m/2
            if(t(j:j)/=t(m-j+1:m-j+1)) then
               judge=0
               exit
            else
               judge=1
            end if
         end do
      end if

      if (judge==1) then
         print *,'Yes'
      else
         print *,'No'
      end if
      stop

   End program ABC159B

Measured memory_bytes: 256
N,M,L,*A = list(map(int, open(0).read().split()))
B = A[N*M:]
A = A[:N*M]

for n in range(N):
    ss = []
    for l in range(L):
        s = 0
        for m in range(M):
            a = A[n*M + m]
            b = B[m*L + l]
            s += a * b
        ss.append(s)
    print(" ".join(map(str, ss)))



Measured memory_bytes: 7684
N = int(input())
l = input().split()
p = []
for i in range(N):
    p.append((int(l[i]),i))

p.sort()

s = N
ans = 0
for i in range(N):
    (a,b) = p[i]
    if b < s:
        ans += 1
        s = b
print(ans)

Measured memory_bytes: 51248
n=int(input())

  
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors  
sosu = make_divisors(n)

leng = len(sosu) 
if leng %2 ==1:
  print(sosu[(leng-1)//2]*2-2)
else:
  print(sosu[leng//2]+sosu[(leng//2)-1]-2)
  

Measured memory_bytes: 3264