akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
#include<string>
#include<algorithm>
using namespace std;

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

int main(){
        int m;
        cin>>m;
        string s;
        for(int i=0;i<m;i++){
                cin>>s;
                set<string>t;
                for(int j=0;j<s.size();j++){
                        string u=s.substr(0,j);
                        string v=s.substr(j);
                        string u1=u,v1=v;
                        if(u.size()>=2){
                                reverse(u.begin(),u.end());
                        }
                        if(v.size()>=2){
                                reverse(v.begin(),v.end());
                        }
                        t.insert(u1+v1),t.insert(u1+v),t.insert(u+v1),t.insert(u+v),t.insert(v1+u1),t.insert(v1+u),t.insert(v+u1),t.insert(v+u);
                }
                cout<<t.size()<<endl;
        }
        return 0;
}



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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

std::map<ll,ll> factor(ll n){
   map<ll,ll> ret;
   ll count = 0;
   while (n%2 == 0){
      count++;
      n = n/2;
   }
   ret[2] = count;

   for (ll f = 3; f <= sqrt(n); f = f+2){
      count= 0;
      while (n%f == 0){
         count++;
         n = n/f;
      }
      if( count != 0 ){
         ret[f] = count;
      }
   }

   if( n > 2 ){
      ret[n] = 1;
   }
   return ret;
}

int main(){
   std::cout<<std::fixed<<std::setprecision(10);

   ll N;

   cin >> N;

   map<ll,ll> f = factor(N);

   ll count = 0;
   for( auto p : f ){
      //DEBUG("%lld %lld", p.first, p.second);
      ll i = 1;
      while( i <= p.second ){
         //DEBUG("i=%lld", i);
         count++;
         p.second -=i;
         i++;
      }
   }
   cout << count << endl;
}


Measured memory_bytes: 3728
/*input
200

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const ll mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
    		for(int k=1;k<=n;k++){
    			sum+=1ll*__gcd(__gcd(i,j),k);
    		}
    	}
    }
    cout<<sum<<endl;
    return 0;
}		

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll N, K;
	cin >> N >> K;
	if (K % 2 != 0) {
		ll H = N / K;
		cout << H * H * H << endl;
	}
	else {
		ll H = N / K;
		ll I = N / (K / 2) - H;
		cout << H * H * H + I * I * I << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int n;
unsigned long long x[200003], c;
unsigned long long sum[200003];

int main() {
	cin >> n >> c;
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + x[i];
	unsigned long long ans = 2e18;
	for (unsigned long long t = 1; t <= n; t++) {
		unsigned long long s = c*(t + n);
		for (int i = n; i > 0; i -= t) {
			unsigned long long k = (n - i + t) / t;
			if (k == 1) s += 5 * (sum[i] - sum[i > t ? i - t : 0]);
			else s +=(2*k + 1)*(sum[i] - sum[i > t ? i - t : 0]);
		}
		ans = min(ans, s);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <ctype.h>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  string x[100];
  int n,l;
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(x[i].compare(x[j])<0){
            swap(x[i],x[j]);
        }
    }
  }
  for(int i=0;i<n;i++){
    cout<<x[i];
  }
}




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

using namespace std;

long long i,j,k,N,a,b,c,ans;

int main()
{
  cin>>N;
  ans=0;
  
  for(i=1;i<=N;i++)
  {
    k=N/i;
    ans+=i*k*(k+1)/2;
  }
  
  cout<<ans;
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
#define pii pair<int,int>
#define ll long long
#define s second
#define f first
 
int n,m;
 
int main(){
  cin >> n >> m;
  if(n==m){cout << "Yes";}
  else{cout << "No";}
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, m: usize, k: usize, a: [usize; n], b: [usize; m]);

    let mut max_books = 0;
    let mut a_count = 0;
    let mut a_sum = 0;

    let mut ruiseki = Vec::new();
    ruiseki.push(0);
    for i in 0..m {
        ruiseki.push(ruiseki[i] + b[i]);
    }

    for i in 0..n + 1 {
        //累積和から謎の処理
        // 二分探索
        let mut l = 0;
        let mut r = m + 1;
        while (r as isize - l as isize).abs() > 1 {
            let lr = (l + r) / 2;
            if ruiseki[lr] + a_sum <= k {
                l = lr;
            } else {
                r = lr;
            }
        }

        if ruiseki[l] + a_sum <= k {
            max_books = std::cmp::max(max_books, a_count + l);
        }
        if i == n {
            break;
        }
        a_sum += a[i];
        a_count += 1;
    }

    println!("{}", max_books);
}


Measured memory_bytes: 11028
#include <cstdio>
#include <cmath>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 100005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

int a[maxn],b[maxn];
int jie[maxn];

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if((a[i]|k)==k)
            ans+=b[i];
    }
    jie[0]=1;
    for(int i=1;i<=29;i++)
    {
        jie[i]=jie[i-1]*2;
    }
    for(int i=1;i<=29;i++)
    {
        if(k&jie[i])
        {
            int temp=(k^jie[i])|(jie[i]-1);
            ll cnt=0;
            for(int j=1;j<=n;j++)
            {
                if((a[j]|temp)==temp) cnt+=b[j];
            }
            ans=max(ans,cnt);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int d=sc.nextInt();
    if(a+b>c+d)System.out.println("Left");
    else if(a+b<c+d)System.out.println("Right");
    else System.out.println("Balanced");
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 1e5 + 100;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 2147483647
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

//1-indexed

int n;//range
int s[4*100005];//n=1e5
int t;

int hyoka(int a,int b){//min
  if(a<b)return a;
  else return b;
}

//?????????
void sset(int n,vi d){
  int i;
  for(t=1;t<n;t*=2);
  for(i=0;i<n;i++)s[t+i]=d[i];
  for(;i<t;i++)s[t+i]=INF;
  for(i=t-1;i;i--)s[i]=hyoka(s[i*2],s[i*2+1]);
}

//update
//i???????????°??????n????????´
void sud(int i,int n){
  for(s[i+=t]=n;i/=2;)
    s[i]=hyoka(s[i*2],s[i*2+1]);
}

//?????¨?????????
//[a,b)???????????¨sout(a,b,1,0,t);
int sout(int a,int b,int i,int l,int r){
  if(r<=a || b<=l)return INF;
  if(a<=l && r<=b)return s[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}



int main(void) {
  int i,j;
  int n,q;
  cin>>n>>q;
  vi d(n,INF);
  sset(n,d);
  int c,x,y;
  rep(i,q){
    cin>>c>>x>>y;
    if(c)cout<<sout(x,y+1,1,0,t)<<endl;
    else sud(x,y);
  }
}

Measured memory_bytes: 4676
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;



int main(void){
    long long N;
    string S;
    map<string,int> mp;
    long long ans=0;

    cin>>N;

    for(int i=0;i<N;i++){
        cin>>S;
        mp[S]++;
    }
    ans = mp.size();

    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 19228
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAX 101
using namespace std;

char s[MAX];
long long k;
int main() {
    while(~scanf("%s%lld",s,&k)) {
        int one = 0;
        while(s[one] && s[one] == '1') one ++;
        if(one >= k) printf("1\n");
        else printf("%c\n",s[one]);
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define maxn 100005
int n,m;
struct per
{
	int a[maxn];
	per(){ memset(a,0,sizeof(a)); }
}p,q;
per operator * (per a,per b)
{
	per c;
	for(int i=1;i<=n;i++) c.a[i]=a.a[b.a[i]];
	return c;
}
per operator ^ (per a,int k)
{
	per res;
	for(int i=1;i<=n;i++) res.a[i]=i;
	while(k)
	{
		if(k&1) res=res*a;
		a=a*a;
		k>>=1;
	}
	return res;
}
per inv(per a)
{
	per b;
	for(int i=1;i<=n;i++) b.a[a.a[i]]=i;
	return b;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&p.a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&q.a[i]);
	int x=(m-1)/6,y=m%6;
	per ip=inv(p),iq=inv(q),h=q*ip*iq*p,A=h^x,B;
	if(y==1) B=p;
	else if(y==2) B=q;
	else if(y==3) B=q*ip;
	else if(y==4) A=A*q,B=ip;
	else if(y==5) A=A*q*ip,B=iq;
	else A=A*q*ip,B=iq*p;
	per ans=A*B*inv(A);
	for(int i=1;i<=n;i++) printf("%d ",ans.a[i]);
}

Measured memory_bytes: 19328
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [None]*n
    dp[0], dp[1] = 0, abs(h[0]-h[1])
    for i in range(2, n):
        di = 10**9
        hi = h[i]
        for j in range(max(0, i-k), i):
            dj = dp[j] + abs(h[j]-hi)
            if di > dj:
                di = dj
        dp[i] = di
    print(dp[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13980
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPS(i,n) for(int i=0; i<(n); i++)
#define REPinit(a,n) for(int i=a; i<(n); i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int A,B,X;
  cin >> A >> B >> X;
  
  
  if(A<=X && (X-A)<=B) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

#define ll long long;
int main() {
	int n,m, cnt = 0;
	cin >> n >> m;
	vector< vector< bool > > adj(n, vector< bool > (n, 0));
	vector< int > pp(n);
	for (int i=0; i<n; i++)	pp[i] = i;
	for (int i=0; i<m; i++) {
		int u,v;
		cin >> u >> v;
		--u,--v;
		adj[u][v] = 1;
		adj[v][u] = 1;
	}
	do {
		if (pp[0] != 0) continue;
		int i;
		for (i=0; i+1<n; i++) if (adj[pp[i]][pp[i+1]] == 0) break;
		if (i == n-1) cnt++;
	}
	while (next_permutation(pp.begin(),pp.end()));
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
using namespace std;
int dp[20][20];
int main(){
	for(int i=0;i<20;i++)
		for(int j=0;j<20;j++)
			dp[i][j]=-1;
	for(int i=5;i<15;i++)
		for(int j=5;j<15;j++)
			dp[i][j]=0;
	int x,y,s;
	int maxo,zero;
	char z;
	while(cin>>x>>z>>y>>z>>s){
		if(s==1){
			dp[x+5][y+5]++;
			if(dp[x-1+5][y+5]!=-1)
				dp[x-1+5][y+5]++;
			if(dp[x+1+5][y+5]!=-1)
				dp[x+1+5][y+5]++;
			if(dp[x+5][y-1+5]!=-1)
				dp[x+5][y-1+5]++;
			if(dp[x+5][y+1+5]!=-1)
				dp[x+5][y+1+5]++;
		}
		if(s==2){
			for(int i=x-1+5;i<=x+1+5;i++){
				for(int j=y-1+5;j<=y+1+5;j++){
					if(dp[i][j]!=-1)
						dp[i][j]++;
				}
			}
		}
		if(s==3){
			for(int i=x-1+5;i<=x+1+5;i++){
				for(int j=y-1+5;j<=y+1+5;j++){
					if(dp[i][j]!=-1)
						dp[i][j]++;
				}
			}
			if(dp[x-2+5][y+5]!=-1)
				dp[x-2+5][y+5]++;
			if(dp[x+2+5][y+5]!=-1)
				dp[x+2+5][y+5]++;
			if(dp[x+5][y-2+5]!=-1)
				dp[x+5][y-2+5]++;
			if(dp[x+5][y+2+5]!=-1)
				dp[x+5][y+2+5]++;
		}
		maxo=1,zero=0;
		for(int i=0;i<20;i++){
			for(int j=0;j<20;j++){
				if(dp[i][j]>maxo)
					maxo=dp[i][j];
				if(dp[i][j]==0)
					zero++;
			}
		}
	}
	cout<<zero<<endl;
	cout<<maxo<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 200000
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
ll n;
vvl mul(vvl m1,vvl m2){
	vvl ret(n,vl(n));
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			for(ll k=0;k<n;k++) ret[i][j]=(ret[i][j]+(m1[i][k]*m2[k][j]%mod))%mod;
		}
	}
	return ret;
}
vvl PW(vvl m,ll k){
	if(k==1) return m;
	vvl t=m;
	vvl t1=PW(m,k/2);
	vvl ret=mul(t1,t1);
	if(k&1) return mul(ret,t);
	else return ret;
}
void solve(){
	ll k;
	cin>>n>>k;
	vvl m(n,vl(n));
	rep(i,0,n) rep(j,0,n) cin>>m[i][j];
	vvl ans=PW(m,k);
	ll no=0;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			no=(no+ans[i][j])%mod;
		}
	}
	cout<<no<<endl;
	
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 2944
<?php
$n = int();
$a = ints();
$i = 1;
foreach($a as $b){
    if($b == $i){
        $i++;
    }
}
if($i == 1){
    echo -1;
}else{
    echo $n-$i+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 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: 27120
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { 
		ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; 
	}
	return x = 1, y = 0, a;
}
ll modInverse(ll a,ll p=mod){
	ll x,y;
	euclid(a,p,x,y);
	return ((x%p+p)%p);
}
void solve(){
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v==w){cout<<"NO\n";return;}
	ll tim=abs(b-a)/(v-w);
	if(abs(b-a)<=t*(v-w))cout<<"YES\n";
	else cout<<"NO\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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




using namespace std;




int main(){

long long a, b;

cin >> a >> b;

if(b>=0&&a<=0){
    cout << "Zero" ;
}

else if(a>0 && b>0){
    cout << "Positive";
}
else if(a<0 && b<0){
    if(abs(a-b+1)%2==1)cout << "Negative";
    else cout << "Positive";
}


return 0;}


Measured memory_bytes: 256
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	int a,b,c,d; cin>>a>>b>>c>>d;
	int t1 = c/b; if(c%b!=0) t1++;
	int t2 = a/d; if(a%d!=0) t2++;
	if(t1<=t2) cout<<"Yes"<<endl; else cout<<"No"<<endl;		
	return 0;
}

Measured memory_bytes: 3608
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for i, (Ai, Bi) in enumerate(AB):
    graph[Ai - 1].append(Bi - 1)
    graph[Bi - 1].append(Ai - 1)

import heapq
    
MY_INF = 1000000007
q = [(0, 0)]
d = [MY_INF] * N
d[0] = 0
while len(q) > 0:
    dist, src = heapq.heappop(q)
    for dst in graph[src]:
        dist_tmp = dist + 1
        if d[dst] > dist_tmp:
            d[dst] = dist_tmp
            heapq.heappush(q, (dist_tmp, dst))

for src in range(N):
    if src == 0:
        print('Yes')
        continue
    #
    dist_min = MY_INF
    ans = 0
    for dst in graph[src]:
        if dist_min > d[dst]:
            dist_min = d[dst]
            ans = dst + 1
    #
    print(ans)

Measured memory_bytes: 71104
inline fun str() = readLine()!!
inline fun int() = str().toInt()
inline fun long() = str().toLong()

inline fun read(d:String = " ") = str().split(d)
inline fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
inline fun list() = list {toInt()}.toIntArray()

inline fun <T> T.print() = this.also(::println)

fun main() {
	abc000X()
}

fun abc000X() {
	val (n,m) = list()
	println(n*m)
}


Measured memory_bytes: 36448
N, M, X = map(int, input().split())
C = [0] * N
A = [0] * N
AA = [list(map(int, input().split())) for i in range(N)]
# 金額と理解度を分ける
for i in range(len(AA)):
    C[i] = AA[i][0]
    A[i] = AA[i][1:]
# -1判定のために
ans = sum(C) + 1
# 2**n で全パターン探索数となる
for p in range(2 ** N):
    Y = [0] * M
    cnt = 0
    for i, c in enumerate(C):
        if p % 2 == 1:
            cnt += c
            for j, a in enumerate(A[i]):
                Y[j] += a
        p //= 2
        # ループ数に対して毎回2を割り、その数の余りを1か0の判定を行うと全パターンとできる
        # 1となったものの理解度と金額を足し上げていく
    # M 数のうち最小値がX以上であれば金額をansに入れる
    ans = min(ans, cnt) if min(Y) >= X else ans
print(ans if ans <= sum(C) else -1)

Measured memory_bytes: 9128
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve(System.in, System.out);
    }

    /*
    F V F M V
    F V F M F M V
    F V F M F V M
    F V F M F M F M V
    F V F M F V M F M
    F V F M F V M F M F M
     */
    public static void solve(InputStream is, PrintStream os) {
        try (Scanner sc = new Scanner(is)) {
            int n = sc.nextInt();
            String[] seat = new String[n];
            seat[0] = read(0, sc, os);
            seat[n - 1] = read(n - 1, sc, os);
            if ("Vacant".equals(seat[0]))
                return;
            int left = 0;
            int right = n - 1;
            while (right - left > 1) {
                int mid = left + (right - left) / 2;
                seat[mid] = read(mid, sc, os);
                if ("Vacant".equals(seat[mid]))
                    return;
                if (isOk(seat, left, mid, right))
                    right = mid;
                else
                    left = mid;
            }

        }
    }

    /**
     * [0,i)で空席が無ければ、iが偶数なら席0と席iの性別は同じで、iが奇数なら席0と席iの性別は異なる
     *
     * @param seat
     * @param left
     * @param mid
     * @param right
     * @return
     */
    private static boolean isOk(String[] seat, int left, int mid, int right) {
        if (!seat[left].equals(seat[mid]) && (mid - left) % 2 == 0)
            return true;
        if (!seat[right].equals(seat[mid]) && (right - mid) % 2 == 0)
            return false;
        if (seat[left].equals(seat[mid]) && (mid - left) % 2 == 1)
            return true;
        if (seat[right].equals(seat[mid]) && (right - mid) % 2 == 1)
            return false;
//        if (seat[left].equals(seat[mid]) && (mid - left) % 2 == 0)
//            return false;
//        if (seat[right].equals(seat[mid]) && (right - mid) % 2 == 0)
//            return true;
//        if (!seat[left].equals(seat[mid]) && (mid - left) % 2 == 1)
//            return false;
//        if (!seat[right].equals(seat[mid]) && (right - mid) % 2 == 1)
//            return true;
        return true;
    }

    private static String read(int n, Scanner sc, PrintStream os) {
        os.println(n);
        os.flush();
        String line = sc.next();
        return line;
    }
}


Measured memory_bytes: 24356
#include<stdio.h>

int main(){
	int n,x,ways,i,j,k;
	while(1){
		ways=0;
		scanf("%d %d",&n,&x);
		if((n==0)&&(x==0)){
			break;
		}
		for(i=1;i<=n;i++){
			for(j=2;j<=n;j++){
				for(k=3;k<=n;k++){
					if((i+j+k==x)&&(i!=j)&&(i!=k)&&(j!=k)&&(i<j)&&(j<k)){
						//printf("%d+%d+%d=%d\n",i,j,k,i+j+k);
						ways++;
						
					}
					
				}
				
			}
			
		}
		
		printf("%d\n",ways);
		
	}
	
	return 0;
	
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;

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

// Problem Specific Parameter:

#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}



ll a[5010];
ll b[210][5010];

int L[5010],R[5010];
ll imos[5010][5010];


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


	rep(i,1,n) cin >> a[i];
	rep(i,1,n) a[i]+=a[i-1];

	rep(i,n)rep(j,m) cin >> b[j][i];

	rep(i,m){
		stack<int> stk;

		rep(j,n){
			while(stk.size() and b[i][j]>b[i][stk.top()]) stk.pop();
			L[j]=(stk.empty())?0:stk.top()+1;
			stk.push(j);
		}

		while(stk.size()) stk.pop();

		rrep(j,n){
			while(stk.size() and b[i][j]>b[i][stk.top()]) stk.pop();
			R[j]=(stk.empty())?n-1:stk.top()-1;
			stk.push(j);
		}

		//rep(j,n) error(j,L[j],R[j]);

		using pll=pair<ll,ll>;
		vector<pll> ary;
		rep(j,n) ary.push_back(pll(b[i][j],j));
		sort(rbegin(ary),rend(ary));

		rep(j,n){
			ll val=ary[j].first,pos=ary[j].second;
			imos[L[pos]][pos]+=val;
			imos[pos+1][pos]-=val;
			imos[L[pos]][R[pos]+1]-=val;
			imos[pos+1][R[pos]+1]+=val;
		}
	}

	rep(i,n)rep(j,1,n) imos[i][j]+=imos[i][j-1];
	rep(i,1,n)rep(j,1,n) imos[i][j]+=imos[i-1][j];

	ll ans=0LL;
	rep(l,n)rep(r,l,n) chmax(ans,imos[l][r]-(a[r]-a[l]));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 204004
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, cnt[26], mod = 1e9 + 7;
string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> s;
    for(auto &i : s) cnt[i - 'a']++;
    int ans = 1;
    for(int i = 0 ; i < 26 ; i++)
        ans = 1LL * ans * (cnt[i] + 1) % mod;
    ans--;
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
void read(int &x)
{
	x=0;
	char ch=getchar();
	int pd=1;
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
		{
			pd=-pd;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	x*=pd;
}
void write(const int &x)
{
	char ggg[10001];
	int s=0;
	int tmp=x;
	if(tmp==0)
	{
		putchar('0');
		return;
	}
	if(tmp<0)
	{
		tmp=-tmp;
		putchar('-');
	}
	while(tmp>0)
	{
		ggg[s++]=tmp%10+'0';
		tmp/=10;
	}
	while(s>0)
	{
		putchar(ggg[--s]);
	}
}
int n,sum;
bitset<4000010>f;
signed main()
{
	read(n);
	f[0]=1;
	for(register int i=1;i<=n;++i)
	{
		int x;
		read(x);
		f|=f<<x;
		sum+=x;
	}
	for(register int i=(sum+1)/2;i<=sum;++i)
	{
		if(f[i])
		{
			write(i);
			return 0;
		}
	}
} 

Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i,j,n,c=1,s;
  cin >> n;
  for(int t=0;t<n;t++){
    cin >> s;
    cout << "Case " << c++ << ":" << endl;
    for(i=0;i<10;i++){
      s *= s;
      while(s >= 1000000) s -= 1000000;
      s /= 100;
      cout << s << endl;
    }

  }
  return 0;
}

Measured memory_bytes: 0
/**
 	Template created by Danel Batyrbek
 	All rights are reserved 2017 (lol)
*/

#include <bits/stdc++.h>

#define speed_up ios_base :: sync_with_stdio(0);cin.tie(0)
#define fr first
#define sc second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define debug(x) cerr << x << '\n';
#define YES "YES"
#define NO "NO"
#define skip continue
#define left(x) x << 1
#define rght(x) x << 1 | 1
#define forn(x, y, z) for(int x = y; x <= z; ++ x)
#define for1(x, y, z) for(int x = y; x >= z; -- x)
#define fname ""
using namespace std;

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

const int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int N3 = 1e3 + 10;
const int INF = 2e9 + 10;
const ll LINF = 2e18;

int n, cnt[N3], mx, mn = INF, ok = 1;

int main(){
#ifndef DEBUG
	if(fname != ""){
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	}
#endif
	cin >> n;
	forn(i, 1, n){
		int x;
		cin >> x;
		cnt[x] ++;
		mx = max(mx, x);
		mn = min(mn, x);
	}
	if((mx + 1) / 2 > mn || cnt[(mx + 1) / 2] > 1 + (mx & 1)) ok = 0;
	forn(i, (mx + 1) / 2, mx){
		if(!cnt[i]) ok = 0;
	}
	if(!ok) cout << "Impossible";
	else cout << "Possible";
	return 0;
}

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

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

  int d1, d2, d3, d4;
  d1 = n / 1000;
  d2 = n / 100 - n / 1000 * 10;
  d3 = n / 10  - n / 100  * 10;
  d4 = n       - n / 10   * 10;
  
  if ((d1 == d2 && d2 == d3) ||
      (d2 == d3 && d3 == d4)   ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

// -----------------------------------------------------------------------------

void solve() {
    int k; cin >> k;
    int re = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            int g = __gcd(a, b);
            for (int c = 1; c <= k; ++c) {
                re += __gcd(g, c);
            }
        }
    }
    cout << re << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}
int change(string s){
  if (s == "Male"){
    return 0;
  }else if(s == "Female"){
    return 1;
  }else{
    return 2;
  }
}
int p[1000000] = {0};
bool C(int x){
  cout << x << endl;
  string s;
  cin>>s;
  p[x] = change(s);
  if (p[x] == 2){
    exit(1);
  }
  if (p[0] == abs(p[x] - x%2)){
    return true;
  }else{
    return false;
  }
}

int main(){
  string s;
  cin>>s;
  if (s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    if(n%2){
        cout << fixed << setprecision(10) << ((n/2)+1.0) / n << endl;
    }else{
        cout << fixed <<setprecision(10) << 1.0 / 2.0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

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

vector<int> A(20);

vector<vector<int>> x(20), y(20);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll N; cin >> N;
  
  vector<ll> A(N);
  REP(i,N) cin >> A[i];
  if(N == 1){
    cout << "YES" << endl;
    return 0;
  }
  ll sum = 0;
  REP(i,N) sum += A[i];

  if(sum % (N*(N+1)/2) != 0){
    cout << "NO" << endl;
    return 0;
  }

  vector<ll> v;
  ll tim = sum/(N*(N+1)/2);
  ll t = 0;

  REP(i,N){
    if(i == N-1){
      v.push_back(A[0]-A[N-1]);
    }else{
      v.push_back(A[i+1] - A[i]);
    }
    v[i] -= tim;
  }

  REP(i,N){
    if(abs(v[i])%N != 0){
      cout << "NO" << endl;
      return 0;
    }
    tim -= abs(v[i])/N;
  }

  if(tim == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 4980
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<list>

using namespace std;

int main() {
	int x;
	while(cin >> x) {
		if(x >= 30)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	} 
}

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

int main()
{
	
	ll x,y;
	cin>>x>>y;
	if(y%2==0 && (y>=2*x && y<=4*x))
		cout<<"Yes";
		else
			cout<<"No";
	return 0;
}

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


def solve():

    initial_cost = 1

    # (x,y) list
    xy_list = []
    for i in range(N):
        x, y = map(int, input().split())
        xy_list.append((x, y))
    xy_list_sorted = sorted(xy_list, key=lambda a: a[0])

    if N == 1 or N == 2:
        return initial_cost

    xy_sub_dic = {}
    for i in range(N):
        for j in range(N):
            xs = xy_list_sorted[j][0] - xy_list_sorted[i][0]
            ys = xy_list_sorted[j][1] - xy_list_sorted[i][1]
            if xs != 0 or ys != 0:
                if xy_sub_dic.get((xs, ys)) is None:
                    xy_sub_dic[(xs, ys)] = 1
                else:
                    xy_sub_dic[(xs, ys)] += 1

    xy_sub_dic_sorted = sorted(xy_sub_dic.items(), key=lambda a: a[1], reverse=True)

    return initial_cost + (N - 1) - xy_sub_dic_sorted[0][1]
print(solve())

Measured memory_bytes: 3572
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let area: u32 = a * b;
    let perimeter: u32 = 2 * (a + b);
    println!("{} {}", area, perimeter);
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,m,K;cin >> n >> m >> K;
    for(int k = 0;k <= n;k++)for(int l = 0;l <= m;l++){
        if(k*(m-l) + (n-k)*l == K){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000
#define INF 0x3f3f3f3f
#define FOR(x,k) for(int x=1;x<=k;x++)

int math[20];
int imath[20];
int main()
{
    shutdown;
    int n,sum,temp=1;
    cin>>n;
    FOR(i,n){
        cin>>math[i];
    }
    FOR(i,n){
        if(math[i]%2==0)
            imath[i]=2;
        else
            imath[i]=1;
    }
    sum=pow(3,n);
    FOR(i,n){
        temp*=imath[i];
    }
    cout<<sum-temp<<endl;
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  N %= 10;

  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    cout << "hon" << endl;
  } else if (N == 0 || N == 1 || N == 6 || N == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 3592
use v6;

get;

for +<<(lines>>.words) -> ($a, $b, $c, $d) {
  if $b > $a || $b > $d {
    say "No";
    next;
  }
  if $b < $c {
    say "Yes";
    next;
  }
  my $g = $b gcd $d;
  say ($b - $g + $a % $g > $c) ?? "No" !! "Yes";
}


Measured memory_bytes: 77592
package main

import (
    "fmt"
    "bufio"
    "sort"
    "os"
    "strconv"
    "math"
)

func main() {
    sc := NewScanner()
    n := sc.NextInt()
    h := sc.NextInt()

    a := make([]int, n, n)
    b := make([]int, n, n)

    for i := 0; i < n; i++ {
        a[i] = sc.NextInt()
        b[i] = sc.NextInt()
    }
    sort.Ints(a)
    sort.Ints(b)

    max_attack := a[n-1]
    ans := 0
    for i := n-1; i >= 0; i-- {
        if h <= 0 {
            break
        }
        if b[i] < max_attack {
            break
        } else {
            h -= b[i]
            ans++
        }
    }
    fmt.Println( ans + int(math.Max(0, float64((h+max_attack-1)/max_attack)) ))
}

type Scanner struct {
	r *bufio.Reader
	buf []byte
	p   int
}

func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}

func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace std;
const int N=301, mod= 1e9+7;
ll res[N][N],dist[N][N];

void solve(int n,int l){

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

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(dist[i][j]<=l) res[i][j]=1;
		}
	}

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

}

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

	int n,m,l;
	cin>>n>>m>>l;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dist[i][j]=1e13;
			res[i][j]=1e13;
		}
		dist[i][i]=0;
	}
	
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		dist[u][v]=w;
		dist[v][u]=w;
	}

	solve(n,l);

	int q;
	cin>>q;
	while(q--){
		int u,v;
		cin>>u>>v;
		cout<<(res[u][v]>=1e13?-1:res[u][v]-1)<<"\n";
	}

    yogeshk972();
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
int a[N];
int main() {
	int n, k;
	readin(n); readin(k);
	int l = 1;
	for (int i = 1; i <= n; i ++) readin(a[i]);
	for (int i = k + 1; i <= n; i ++, l ++) {
		if (a[i] > a[l]) puts("Yes");
		else puts("No");
	}
	return 0;
}




Measured memory_bytes: 4412