akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> A(N);
  vector<int> P(N);
  vector<int> Q(N);
  REP(i, N) A[i] = i + 1;
  for(auto &i : P) cin >> i;
  for(auto &i : Q) cin >> i;
  int p, q, cnt = 1;
  do{
    if(A == P) p = cnt;
    if(A == Q) q = cnt;
    cnt++;
  }while(next_permutation(A.begin(), A.end()));
  cout << abs(p - q) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
int main(){
  int r;
  std::cin >> r;
  std::cout << r*r*3 << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int x[n];
  int y[n];
  int a[n];
  for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>a[i];
  int left = 0;
  int i;
  int right = w;
  int up = 0;
  int down = h;
  for(i=0;i<n;i++){
    if(a[i]==1){
      left = max(left,x[i]);
    }else if(a[i]==2){
      right = min(right,x[i]);
    }else if(a[i]==3){
      up = max(up,y[i]);
    }else{
      down = min(down,y[i]);

    }
  }
  int ans = (right-left)*(down-up);
  if(right<=left || down<=up)ans = 0;
  cout<<ans<<endl;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define print(s)      cerr << s << endl
#define print(a, b)      cerr << a << " "  << b << endl
#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class AABC333 {
public:
	void solve(std::istream& in, std::ostream& out) {
			int a, b;
			in >> a >> b;
			int x = a * b, y = a * b * 3;
			if((x & 1) || (y & 1))out << "Yes";
			else out << "No";
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	AABC333 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov
//export PATH=PATH:~/.local/bin
int modPow(long long a, long long n, long long p) {
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}

vvll comb(ll n) {
    vvll v(n + 1,vll(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll p=998244353;

int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    ll k;
    cin >> k;
    ll nc=1;
    ll count=0;
    vll mpow(n,1);
    ll a=m-1;
    mpow[0]=1;
    repi(i,1,n){
        if (i == 1) mpow[i]=a % p;
        else if (i % 2 == 1) mpow[i]=(a * mpow[i-1]) % p;
        else{
            long long t = mpow[i / 2];
            mpow[i]= t*t % p;
        }
    }
    rep(i,k+1){
        count+=nc*mpow[n-i-1]%p;
        nc=(nc*(n-i-1)%p*modinv(i+1,p))%p;
        count%=p;
    }
    if(count<0) count+=p;
    cout << count*m%p << endl;
}

Measured memory_bytes: 4812
#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;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int> edge[100010];
int64_t ans=1;
int64_t k;

void bfs(int from, int64_t cost, int par){
	ans*=cost;
	ans%=MOD;
	cost=par!=-1?k-1:k;
	for(int to:edge[from]){
		if(to==par) continue;
		bfs(to, --cost, from);
	}
}

int main() {
	int n; cin>>n;
	cin>>k;
	rep(i,n-1){
		int a,b; cin>>a>>b;
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	bfs(0, k, -1);
	cout<<ans<<endl;
	return 0;
}

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

def solution():
    if N==1:
      return M
    
    if M-N < M//N:
        for n in range(N, M+1):
            if M%n==0:
                return M//n
    else:
        for m in range(M//N, 0, -1):
            if M%m==0:
                return m

print(solution())
            


Measured memory_bytes: 2940
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT = mp::cpp_int;
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    INT X;
    cin >> X;
    for (INT i = -1000; i < 1000; i++)
    {
        for (INT j = -1000; j < 1000; j++)
        {
            if (i * i * i * i * i - j * j * j * j * j == X)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3696
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var mod = 998244353;
function mul(a,b){return ((a>>16)*b%mod*65536+(a&65535)*b)%mod;}
function inv(a){for(var b=mod,u=1,v=0,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}

console.log(main());
function main(){
  var n = o.a();
  var ans = pow(3,n);
  var fac = 1;
  for(var i = 0, m = n>>1, p2 = 1; i < m; i++){
    p2 = p2 * 2 % mod;
    ans -= mul(fac,p2);
    fac = mul(mul(fac,n-i),inv(i+1));
  }
  ans%=mod
  return ans<0?ans+mod:ans;
}

Measured memory_bytes: 12108
import java.util.*;

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

        int N = scanner.nextInt();

        int[][] A = new int[2][N];

        for(int i=0; i<2; i++){
            for(int j=0; j<N; j++){
                A[i][j] = scanner.nextInt();
            }
        }

        for(int i=0; i<2; i++){
            for(int j=0; j<N; j++){
                if(i == 1){
                    if(j >=  1){
                        A[i][j] = Math.max(A[i][j]+A[i-1][j], A[i][j]+A[i][j-1]);
                    }else{
                        A[i][j] =A[i][j]+A[i-1][j];
                    }
                }else{
                     if(j >= 1){
                        A[i][j] = A[i][j]+ A[i][j-1];
                    }
                }
            }
        }

        System.out.println(A[1][N-1]);
    }
}


Measured memory_bytes: 21844
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//
ll a[200010], b[200010];

int main() {
	ll n; cin >> n;

	ll x;
	rep(i, n)a[i] = 0;
	rep(i, n)b[i] = 0;

	rep(i, n) {
		cin >> x;
		if (i + x < n)a[i + x]++;
		if (i - x > 0)b[i - x]++;
	}

	ll sum = 0;
	rep(i, n)if (a[i] > 0 && b[i] > 0)sum += a[i] * b[i];

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 6740
from collections import deque
N = int(input())
connection =[[] for i in range(N)]
for i in range(1,N):
    u,v,w = (int(x) for x in input().split())
    u -=1
    v -=1
    connection[u].append((v,w))
    connection[v].append((u,w))
#
start=0
node =[None]*N
node[start] =0
dq =deque()
dq.append(start)

#
while dq:
    sarch =dq.popleft()
    for nv,w in connection[sarch]:
        if node[nv] is None:
            node[nv] = (node[sarch] +w) %2
            dq.append(nv)   
print(*node,sep="\n")

Measured memory_bytes: 40708
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(void){
    int n,s[1000],sum;
    double a;
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++)cin>>s[i];
        sum=0;
        for(int i=0;i<n;i++)sum+=s[i];
        double avg=double(sum)/n;
        double var=0.0;
        for(int i=0;i<n;i++)var+=pow(s[i]-avg,2.0);
        a=sqrt(var/n);
        printf("%.8f\n",a);
    }
    return 0;
}

Measured memory_bytes: 3236
#include<iostream>
#include<stdio.h>
using namespace std;

int a[10000],n;

int solve(int i,int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res=solve(i+1,m) || solve(i+1,m-a[i]);
    return res;
}

int main(){
    int q,m,i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>m;
        if(solve(0,m))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


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

int main() {
  int N,X;
  cin >> N >> X ;
  vector<int> m(N);
  for (int i=0;i<N;i++){
    cin >> m[i] ;
    X-=m[i];
  }
  sort(m.begin(),m.end());
  int answer=N+X/m[0];
  
    cout<< answer <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int ans=0, count=0;
  for(int i=0;i<s.size();i++){
    char c = s[i];
    if(c=='A' || c=='C' || c=='G' || c=='T'){
      count++;
    }else{
      ans=max(ans, count);
      count=0;
    }
  }
  cout << max(ans, count) << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

int N;

// dp[i][j][k] = 寿司が1個乗っている皿がi個、2個乗っている皿がj個、3個乗っている皿がk個あるときの
double dp[310][310][310];
double rec(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if(0 < i) res += rec(i-1, j, k) * i;
    if(0 < j) res += rec(i+1, j-1, k) * j;
    if(0 < k) res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i+j+k);

    return dp[i][j][k] = res;
}

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

    cin >> N;
    int one = 0, two = 0, three = 0;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        if(a == 1) ++one;
        else if(a == 2) ++two;
        else ++three; 
    }

    memset(dp, -1, sizeof(dp));

    printf("%.12lf\n", rec(one, two, three));
    
    return 0;
}

Measured memory_bytes: 233216
#include <stdio.h>

int main()
{
	int a[102], i, j, N, cop, ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (a[i] < a[j]) {
				cop = a[i];
				a[i] = a[j];
				a[j] = cop;
			}
		}
	}
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (a[i] == a[j]) {
				a[j] = -545613;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (a[i] != -545613) {
			ans++;
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int_Max 2147483647
#define ll_Max 9223372036854775807
#define REP(i,f,n) for(int i=f; i<(n); i++)

int main()
{
  ll ans = 0;
  string s;
  cin >> s;
  ll n = s.length();
  if(n % 2 == 0)n -= 1;
  for(int i=n-1 ; i>=2 ; i-=2){
    int j = i/2;
    string s2 = s.substr(0,i);
    string h1 = s2.substr(0,j);
    string h2 = s2.substr(j,i);
    //cout << s2 << " : " << j << "/ "<< h1 << " : " << h2 << endl;
    if(h1 == h2){
      ans=i;
      break;
    }
  }
  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll power(ll a,ll n)
{
    ll res=1;
    while(n)
    {
        if(n%2) res=(res*a)%mod,n--;
        else a=(a*a)%mod,n/=2;
    }
    return res;
}
main()
{
   ll n;
   cin>>n;
   ll ans=power(10,n);
   ans+=mod;
   ans%=mod;
   ans-=(2*power(9,n));
   ans+=mod;
   ans%=mod;
   ans+=power(8,n);
   ans+=mod;
   ans%=mod;
   cout<<ans<<endl;
}



Measured memory_bytes: 3588
n = int(input())
list_a = list(map(int, input().split()))
dict_a = {}
for number in list_a:
    try:
        dict_a[number//400] += 1
    except KeyError:
        dict_a[number//400] = 1
count = 0
count_niji = 0
for key,value in dict_a.items():
    if key < 8:
        count += 1
    else:
        count_niji += value
if count == 0:
    print(1,count_niji)
else:
    print(count,count + count_niji)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
long long a,b,ans=65,n;
int main()
{
    cin>>a;
    for(register int s=0;s<a;s++)
    {
        cin>>b;
        n=0;
        while(b%2==0)
        {
            b=b/2;
            n++;
        }
        ans=min(ans,n);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    #aの大きい順に、左右どちらかの端から埋めていく
    n=II()
    aa=LI()
    dp=[[0]*(n+1) for _ in range(n+1)]
    #dp[l][r]...左からl人、右からr人埋まっているときの最大値
    for s,(i,a) in enumerate(sorted(enumerate(aa),key=lambda x:-x[1])):
        for l in range(s+1):
            r=s-l
            pre=dp[l][r]
            dp[l+1][r]=max(dp[l+1][r],pre+abs(l-i)*a)
            dp[l][r+1]=max(dp[l][r+1],pre+abs(n-1-r-i)*a)
    ans=0
    for l in range(n+1):
        ans=max(ans,dp[l][n-l])
    print(ans)

main()

Measured memory_bytes: 100264
N = int(input())
zero = 0
r_zero = 0
l_zero = 0
mod = 1000000007
from collections import defaultdict
from math import gcd
dic = defaultdict(int)
for i in range(N):
    A, B = map(int, input().split())
    if A==0 and B==0:
        zero += 1
        continue
    elif A==0:
        r_zero += 1
    elif B==0:
        l_zero += 1
    else:
        g = gcd(A, B)
        A //= g
        B //= g
        if A<0:
            A, B = -A, -B
        dic[(A, B)] += 1

dickey = list(dic.keys())
s = set(dickey)
nopair = N-zero-r_zero-l_zero
ans = pow(2, r_zero, mod)+pow(2, l_zero, mod)-1
for a, b in dickey:
    if a*b>0 and (b, -a) in s:
        ans *= (pow(2, dic[(a, b)], mod)+pow(2, dic[(b, -a)], mod)-1)%mod
        nopair -= (dic[(a, b)]+dic[(b, -a)])
ans *= pow(2, nopair, mod)
print((ans-1+zero)%mod)

    

Measured memory_bytes: 61268
a,b,c;
main(d,e,f)
{
  for(;scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f),~a;printf("%d\n",(365*d+d/4-d/100+d/400+306*(e+1)/10-428+f)-(365*a+a/4-a/100+a/400+306*(b+1)/10-428+c))){
    b>2?:(a--,b+=12);
    e>2?:(d--,e+=12);
  }
  exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long v[301],a[301][90001],b[301][90001];
int main()
{
	long long j,i,ans=0,ans1=0,n,s=1,sum=0;
	scanf("%d",&n);
	for (i=0;i<n;i++)
	{
		scanf("%lld",&v[i]);
		s=s*3%998244353;
		sum+=v[i];
	}
	a[0][0]=b[0][0]=1;
	for(i=0;i<n;i++)
	{
		for(j=0;j<=90000;j++)
		{
			a[i+1][j]=(2*a[i][j]+a[i+1][j])%998244353;
			a[i+1][j+v[i]]=(a[i][j]+a[i+1][j+v[i]])%998244353;
			b[i+1][j]=(b[i+1][j]+b[i][j])%998244353;
			b[i+1][j+v[i]]=(b[i+1][j+v[i]]+b[i][j])%998244353;
		}
	}
	for(i=0;i<=90000;i++)
		if(sum<=i*2)
			ans=(ans+a[n][i])%998244353;
	if(sum%2==0)
		ans1=b[n][sum/2];
	printf("%lld",(((s-3*ans)%998244353+3*ans1)%998244353+998244353)%998244353);
	return 0;
}

Measured memory_bytes: 422784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (int)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

vector<vector<ll>> init(int x){

    vector<vector<ll>> ans(x+1,vector<ll>(0));

    for(int i=1;i <= x;i++)
    {
        for(int j=0;j <= i;j++)
        {
            if(j==0 || j==i) ans[i].emplace_back(1);
            else ans[i].emplace_back(ans[i-1][j-1]+ans[i-1][j]);            
        }
    }
    return ans;
}


int BS(vector<ll> v,ll x){
  int ue=-1,st=siz(v);

  while(abs(ue-st)>1){
    int mid=(ue+st)/2;

    if(v[mid]>=x)ue=mid;
    else st=mid;
  }
  return ue;
}


signed main(){
  int n,a,b,ansi=1;cin>>n>>a>>b;
  ll cnt=0,ans=-1;
  vector<vector<ll>> c=init(52);

  vector<ll> v(n,-1),sum(b+1,0); 
  rep(i,n)cin>>v[i];

  sort(all(v),greater<ll>());

  for(int i=1;i <= b;i++)
  {
    sum[i]=v[i-1]+sum[i-1];
  }



  for(int i=a;i <= b;i++)
  {
    if(i*ans<=sum[i]*ansi){
      ans=sum[i];
      ansi=i;

      if(i*ans < sum[i]*ansi) cnt=0;

      int nmx=BS(v,v[i-1]),mx=BS(v,v[i-1]+1);
      //cout<<nmx<<":"<<mx<<endl;
      
      cnt+=c[nmx-mx][i-mx-1];
      
    }
    
  }

  printf("%.11Lf\n",((long double)ans/ansi));
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int H, W, A, B;
	scanf("%d %d %d %d", &H, &W, &A, &B);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i < B)printf(j < A ? "1" : "0");
			else printf(j < A ? "0" : "1");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

template<typename T, typename U> istream & operator>>(istream & s, pair<T, U> & p) { return (s >> p.FI >> p.SE); }
template<typename T, typename U> ostream & operator<<(ostream & s, pair<T, U> const & p) { return (s << p.FI << " " << p.SE); }

int main() {
	IN(int, n, m);
	vector<pair<int, int>> v(m);
	cin >> v;
	
	auto f = [&](int x) {
		string s = to_string(x);
		if_not(SI(s) == n) { return false; }
		RF(e, v) {
			if_not(s[e.FI - 1] - '0' == e.SE) { return false; }
		}
		return true;
	};
	
	int ans = -1;
	inc(i, 1000) {
		if(f(i)) { ans = i; break; }
	}
	OUT(ans);
}


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(){
    ll n,m,p;
    cin >> n >> m >> p;
    ll a,b,c;

    vector <vector <ll>> h(m,vector <ll> (3));
    rep(i,m){
        cin >> a >> b >> c;
        --a;
        --b;
        c-=p;
        h[i][0]=a;
        h[i][1]=b;
        h[i][2]=c;
    }

    int ko=0;
    ll ma=-1001001001001001;
    vector <ll> ans(n,ma),ans2(n);
    ans[0]=0;
    ans2=ans;
    ll t=0;
    vector <ll> go(n,ma);
    while(1){
        //cout << t << ko << endl;
        ++t;
        rep(i,m){
            if(h[i][1]==(n-1) and ans[h[i][0]]!=ma){
                if(go[h[i][0]]<ans[h[i][0]]+h[i][2]){
                    ko=0;
                    go[h[i][0]]=ans[h[i][0]]+h[i][2];
                }
            }
            if(ans[h[i][1]]<ans[h[i][0]]+h[i][2] and ans[h[i][0]]!=ma){
                //ko=0;
                ans[h[i][1]]=ans[h[i][0]]+h[i][2];
            }
        }
        if(ans[n-1]==ans2[n-1] and ans[0]==ans2[0]){
            ++ko;
        }
        else{
            ko=0;
        }
        ans2=ans;
        if(ko==n*3){
            if(ans[n-1]<0){
                ans[n-1]=0;
            }
            break;
        }
        if(t==(n*8)){
            ans[n-1]=-1;
            break;
        }
    }

    cout << ans[n-1] << endl;


    

    return 0;
}

Measured memory_bytes: 3836
import java.util.Scanner;

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

		int n = 0;
		int m = 0;
		int s = 0;
		int g1 = 0;
		int g2 = 0;

		

		while (true) {
			n = scan.nextInt();
			m = scan.nextInt();
			s = scan.nextInt();
			g1 = scan.nextInt();
			g2 = scan.nextInt();

			if (n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0)
				break;
			s--;
			g1--;
			g2--;

			int last_cost = Integer.MAX_VALUE / 10;
			
			int kithi1[] = new int[m];
			int kithi2[] = new int[m];
			int cost[][] = new int[n][n];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (i != j)
						cost[i][j] = Integer.MAX_VALUE / 10;
				}
			}

			for (int i = 0; i < m; i++) {
				kithi1[i] = scan.nextInt();
				kithi2[i] = scan.nextInt();
				cost[kithi1[i] - 1][kithi2[i] - 1] = scan.nextInt();
				//cost[kithi2[i] - 1][kithi1[i] - 1] = cost[kithi1[i] - 1][kithi2[i] - 1];
			}

			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						if (cost[i][j] > cost[i][k] + cost[k][j]) {
							cost[i][j] = cost[i][k] + cost[k][j];
						}
					}
				}
			}

			for (int i = 0; i < n; i++) {
				if (last_cost > cost[s][i] + cost[i][g1] + cost[i][g2])
					last_cost = cost[s][i] + cost[i][g1] + cost[i][g2];
			}

			System.out.println(last_cost);
		}
		scan.close();
	}

}

Measured memory_bytes: 62868
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int main() {
	int n, pv = 0;
	scanf("%d", &n);
	long long ans = 0;
	for(int i = 0;i < n;i++){
		int a;
		scanf("%d", &a);
		if(a > pv) pv = a;
		else ans += (long long) (pv - a);
	}
	printf("%lld\n", ans);
	return 0;
}
//ios_base::sync_with_stdio(false);
//cin.tie(0);
//tod-ngen


Measured memory_bytes: 3788
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

struct sp{
	bool operator()(const pair<int,int> &left,const pair<int,int> &right){
		if(left.first==right.first){
			return left.second<right.second;
		}
		return left.first>right.first;
	}
};

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0&&m==0) break;

		vector<pair<int,int> > map;
		for(int i=0;i<m;i++){
			pair<int,int> p(0,i+1);
			map.push_back(p);
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				int r;
				cin>>r;
				if(r==1){
					map[j].first++;
				}
			}
		}
		
		stable_sort(map.begin(),map.end(),sp());
		
		for(int i=0;i<map.size()-1;i++){
			cout<<map[i].second<<" ";
		}
		cout<<map[map.size()-1].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 916
# 実行時間超過

N=int(input())
n = list(map(int, input().split()))

for i in range(N-1):
    if n[i+1]-n[i]>=1:
        n[i+1]-=1
    elif n[i+1]-n[i]<=-1:    
        print("No")
        exit()
print("Yes")

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    auto copy_P = P;
    auto copy_Q = Q;
    sort(P.begin(), P.end());
    sort(Q.begin(), Q.end());

    int p_i = 1;
    int q_i = 1;

    do {
        int cnt = 0;
        for(int i = 0; i < N; ++i) {
            if(P[i] == copy_P[i]) ++cnt;
        }
        ++p_i;
        if(cnt == N) break;
    } while(next_permutation(P.begin(), P.end()));

    do {
        int cnt = 0;
        for(int i = 0; i < N; ++i) {
            if(Q[i] == copy_Q[i]) ++cnt;
        }
        ++q_i;
        if(cnt == N) break;
    } while(next_permutation(Q.begin(), Q.end()));

    cout << abs(p_i - q_i) << endl;
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int ans = a - b * 2;
			if (ans < 0) {
				ans = 0;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
import copy
N, M = [int(_) for _ in input().split()]
AB = [[int(_) - 1 for _ in input().split()] for _ in range(M)]

G = [set() for _ in range(N)]
a = set()
for ab in AB:
    G[ab[0]].add(ab[1])


def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]


ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if j in G[i]:
            Gn = copy.deepcopy(G)
            Gn[i].discard(j)
            a = [i for i in range(N)]
            for k in range(N - 1):
                for l in Gn[k]:
                    unite(a, k, l)
            par = set()
            for k in range(N):
                par.add(find(a, k))
            if len(par) > 1:
                ans += 1
print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pi pair<int,int>
#define ff first
#define ss second
const int N = 1e5 + 5;


int32_t main() { 
	int n;
	cin>>n;
	string s;
	vector<pi>v;
	int cnt = 0,c = 0;
	for(int i=0;i<n;i++){
		cin>>s;
		int open = 0,close = 0;
		for(char &c:s){
			if(c == '(')
				open++;
			else{
				if(open>0)
					open--;
				else
					close++;
			}
		}
		if(open>0 && close>0)
			v.push_back({open,close});
		else if(open>0)
			cnt+=open;
		else
			c+=close;
	}

	sort(v.begin(),v.end(),[&](pi a,pi b){
		return (a.ff-a.ss > b.ff-b.ss);
	});
	for(pi &p:v){
		cnt-=p.ss;
		if(cnt<0)
			break;
		cnt+=p.ff;
	}
	cnt -=c;
	if(cnt == 0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}	



Measured memory_bytes: 7260
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

char c[MAX_N];
vector<P> a;
int n;

int main()
{
	int cntj=0,cnti=0;
	scanf("%d",&n);
	char x;
	scanf("%c",&x);
	rep(i,n){
		scanf("%c",&c[i]);
		if(c[i] == 'I'){
			cnti++;
		}
	}
	ll mx = 0;
	ll ans1 = 0;
	rep(i,n){
		if(c[i] == 'J'){
			cntj++;
		}else if(c[i] == 'I'){
			cnti--;
		}else{
			a.push_back(P(cntj,cnti));
			ans1 += (ll)cntj*cnti;
		}
		mx = max(mx,(ll)cntj*cnti);
	}
	ans1 += mx;
	ll ans2 = 0;
	ll ans3 = 0;
	rep(i,a.size()){
		ans2 += (ll)(a[i].first+1)*a[i].second;
		ans3 += (ll)a[i].first*(a[i].second+1);
	}
	printf("%lld\n",max(max(ans1,ans2),ans3));
	return 0;
}

Measured memory_bytes: 3900
n = int(input())
data = []
name = set()
for i in range(n):
    s, p = input().split()
    name.add(s)
    p = int(p)
    data.append([i+1, s, p])
result = sorted(data, key=lambda x: x[2], reverse=True)
name_sorted = sorted(list(name))
for x in name_sorted:
    for y in result:
        if y[1] == x:
            print(y[0])

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

H,W = list(map(int,input().split()))
cell = []
for i in range(H):
    s=list(input().rstrip())
    cell.append(s)
h = set(range(H))
w = set(range(W))
sh = []
sw = []
for ih in range(H):
    for iw in range(W):
        if cell[ih][iw] == '#':
            sh.append(ih)
            sw.append(iw)
sh = set(sh)
sw = set(sw)
for iih in sh:
    for iiw in sw:
        print(cell[iih][iiw],end='')
    print('')

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

string S;
int dp[200005][2];

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    cin >> S;
    int inf = S.size() + 5;

    dp[0][0] = 1, dp[0][1] = -inf;

    for(int i=1; i<S.size(); i++)
    {
        if(S[i] == S[i-1])
        {
            dp[i][0] = 1 + dp[i-1][1];
            dp[i][1] = 1 + (i >= 2 ? max(dp[i-2][0], dp[i-2][1]) : 0);
        }
        else
        {
            dp[i][0] = 1 + max(dp[i-1][0], dp[i-1][1]);
            dp[i][1] = 1 + (i >= 2 ? max(dp[i-2][0], dp[i-2][1]) : 0);
        }
    }
    
    cout << max(dp[S.size() - 1][0], dp[S.size() - 1][1]) << "\n";
    return 0;
}


Measured memory_bytes: 2196
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int n,m;
    cin>>n>>m;
    if(n==m)
    	cout<<"Yes\n";
    else
    	cout<<"No\n";

    return 0;
}

Measured memory_bytes: 256
a = list()
for i in range(5):
    a.append(int(input()))
x, y = 0,float("inf")
for i in range(5):
    p = int(str(a[i])[-1])
    if p == 0:
        pass
    elif p < y:
        x = i
        y = p
for i in range(5):
    if i == x:
        pass
    elif not str(a[i])[-1] == "0":
        a[i] = (a[i]//10+1)*10
print(sum(a))

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------
		String s = sc.next();

		int n = s.length();

		boolean kaibun = true;
		for (int i = 0; i < n / 2; i++) {
			if (s.charAt(i) != s.charAt(n - 1 - i)) {
				kaibun = false;
				break;
			}
		}
		if (kaibun) {
			String s1 = s.substring(0, n / 2);
			int n1 = s1.length();
			boolean kaibun1 = true;
			for (int i = 0; i < n1; i++) {
				if (s1.charAt(i) != s1.charAt(n1 - 1 - i)) {
					kaibun1 = false;
					break;
				}
			}
			if (kaibun1) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		} else {
			out.println("No");
		}

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 27044
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, q;
	cin >> n >> q;
	queue<pair<string, int>> name_time;
	for (int i = 0; i < n; i++)
	{
		string name;
		int time;
		cin >> name >> time;
		name_time.push(make_pair(name, time));
	}

	int elaps = 0;
	while (!name_time.empty())
	{
		pair<string, int> tmpPair = name_time.front();
		name_time.pop();
		int sub = min(q, tmpPair.second);
		tmpPair.second -= sub;
		elaps += sub;
		if (tmpPair.second == 0) cout << tmpPair.first << " " << elaps << endl;
		else name_time.push(tmpPair);
	}
}


Measured memory_bytes: 6204
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if(N==1) {
            System.out.println(M);
            return;
        }
        int ans = 1;
        for(int i = 2; i*i<=M; i++) {
            if(M%i != 0) continue;
            int b = M/i;
            if(i>=N) ans = Math.max(ans, b);
            if(b>=N) ans = Math.max(ans, i);
        }
        System.out.println(ans);
    }
}

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

int main(){
    char a[15], b[10], c[10];
    scanf("%s %s %s", a,b,c);
    int al = strlen(a), bl = strlen(b), cl = strlen(c);
    if (a[al-1] == b[0] && b[bl-1] == c[0]){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
    int ans=0;
    cin>>s;
    for(int i=0;i<=(s.size()+1)/2;i++){
    	if(s[i]!=s[s.size()-1-i]){
          s[i]=s[s.size()-1-i];
          ans++;
        }
    }
      cout<<ans;
}

Measured memory_bytes: 256
// abc166_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

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

    map<int, int> memo;
    REP(i, N){
        memo[A[i]-i]++;
    }

    ll ans = 0;
    REP(i, N) {

        int x = -(A[i]-i) - 2 * i;
        ans += memo[x];

        memo[A[i] - i]--;

    }

    print(ans);


    return 0;
}


Measured memory_bytes: 21084
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	vector<ll> h(n);
	ll ans = 0;
	ll idou = 0;
	rep(i, n)
	{
		cin >> h[i];
	}

	for(int i=1;i<n;i++)
	{
		if (h[i - 1] >= h[i])
		{
			idou++;
		}
		else
		{
			ans = max(ans, idou);
			idou = 0;
		}
		if (i == n - 1)
		{
			ans = max(ans, idou);
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 1024
import math
k = int(input())
su = 0
lis = []
for x in range(1, k+1):
  for y in range(1, k+1):
    a = math.gcd(x, y)
    lis.append(a)

for z in range(1, k+1):
  for p in lis:
    ans = math.gcd(p, z)
    su += ans
  
print(su)

Measured memory_bytes: 9292
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
# include <set>
# include <iomanip>
# include <functional>
# include <queue>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}


int main() {
	int a = 0;
	cin >> a;
	cout << a * a * 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;

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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N+1), B(N);
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];

  long long cnt = 0;
  rep(i, N){
    if (B[i] >= A[i]){
      B[i] -= A[i];
      cnt += A[i];
      A[i] = 0;
    }else{
      A[i] -= B[i];
      cnt += B[i];
      B[i] = 0;
    }
    if (B[i] == 0){
      continue;
    }
    if (B[i] >= A[i+1]){
      B[i] -= A[i+1];
      cnt += A[i+1];
      A[i+1] = 0;
    }else{
      A[i+1] -= B[i];
      cnt += B[i];
      B[i] = 0;
    }
  } 
  cout << cnt << endl;
}

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

int main(void){
    int a[100010], n, sa[100010], m;
    cin >> n >> m;
    for(int i=0;i<m;++i){
        cin >> a[i];
    }
    sort(a, a+m);
    for(int i=0;i<m-1;++i){
        sa[i] = max(a[i+1], a[i]) - min(a[i+1], a[i]);
    }
    sort(sa, sa+(m-1));
    int ans=0;
    for(int i=0;i<(m-n);++i){
        ans += sa[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024