akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    bool even = false, odd = false;
    vector<pair<long long int, long long int>> point(n);
    for(int i=0; i<n; i++){
        long long int x, y;
        cin >> x >> y;
        point[i] = make_pair(x, y);

        if((x + y) % 2 == 0) even = true;
        else                 odd  = true;
    }
    if(even == true && odd == true){
        cout << -1 << endl;
        return 0;
    }

    // output
    if(odd  == true) cout << 31 << endl << 1 << " ";
    if(even == true) cout << 32 << endl << 1 << " " << 1 << " ";

    vector<long long int> pow2(32, 1);// 1 ~ 2^31
    for(int j=0; j+1<32; j++){
        pow2[j+1] = pow2[j] * 2;
        if(j+1 == 31) break;
        cout << pow2[j+1] << " ";
    }
    cout << endl;

    // each point
    for(int i=0; i<n; i++){
        long long int x = point[i].first;
        long long int y = point[i].second;
        if(even == true){
            x -= 1;
            cout << 'R';
        }

        vector<char> xdir = {'L', 'R'}, ydir = {'D', 'U'};
        if(x < 0LL){ xdir = {'R', 'L'}; x = abs(x); }
        if(y < 0LL){ ydir = {'U', 'D'}; y = abs(y); }

        long long int cx = 0, cy = 0;
        for(int j=0; j<31; j++){
            if(j == 30){
                if(x != 0LL){
                    cout << xdir[1];
                    cx += pow2[j];
                }
                else{
                    cout << ydir[1];
                    cy += pow2[j];
                }
            }
            else if(y == 0LL || x % pow2[j+1] == pow2[j]){
                if(y == 0 && x - pow2[j] == 0){
                    x += pow2[j];
                    cout << xdir[0];
                    cx -= pow2[j];
                }
                else if((x + pow2[j]) % pow2[j+2] == y % pow2[j+2]){
                    x -= pow2[j];
                    cout << xdir[1];
                    cx += pow2[j];
                }
                else{
                    x += pow2[j];
                    cout << xdir[0];
                    cx -= pow2[j];
                }
            }
            else{// y % pow2[j+1] == pow2[j]
                if(x == 0LL && y - pow2[j] == 0LL){
                    y += pow2[j];
                    cout << ydir[0];
                    cy -= pow2[j];
                }
                else if((y + pow2[j]) % pow2[j+2] == x % pow2[j+2]){
                    y -= pow2[j];
                    cout << ydir[1];
                    cy += pow2[j];
                }
                else{
                    y += pow2[j];
                    cout << ydir[0];
                    cy -= pow2[j];
                }
            }
        }
        //cout << " : (" << cx << ", " << cy << ")";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
from math import sqrt,ceil,floor
def mi():return map(int,input().split())
def li():return list(mi())
def ii():return int(input())


x=ii()


for i in range(1000000):
    x3=x-pow(i,5)
    x2=abs(x3)
    x1=x2**(1/5)
    x1=int(x1)
    if(pow(x1,5)==x2):
        if(x3>0):
            x1*=(-1)
        print(i,x1)
        break
        

Measured memory_bytes: 62564
#include <bits/stdc++.h>
#include<stdlib.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define prf pair<ld,ld>
#define vct vector<ll>
#define vpt vector<pr>
#define vcf vector<ld>
#define vpf vector<prf>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for(i = 0; i < (1LL*n); i++)
#define Fr(i, n) for(i = n - 1; i >= 0; i--)
 
struct custom_hash{
    static uint64_t splitmix64(uint64_t x){
        x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const{
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
 
void prv(vct v){for (ll i=0;i<v.size();i++)cout<<v[i]<<" ";cout << "\n";}
void prn(ll n){cout<<n<<"\n";}
void prs(string n){cout<<n<<"\n";}
void deb(string s, ll n){cout<<s<<" : "<<n<<"\n";}
void prmt(mat m){for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);}
 
mat getRzMat(ll m,ll n, ll ini=0){mat mt;mt.assign(m,vector<ll>(n,ini));return mt;}
 
ll poww(ll x, ll y, ll m){
    ll res = 1;
    while (y){
        if (y%2 == 0){x = (x * x) % m;y = y / 2;}
        else{res = (res * x) % m;y--;}
    }
    return res;
}
 
vct divsors(ll n){
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++){if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
mat mt;
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
ll q;
ll i, j;
ll a, b, c, d, w;
ll mod = 1000000007;
ld epi = 0.00000001;
ll cas=0;
ll cnt=0;

void solve(){

    cin>>n;
    vct v(n);
    F(i,n)cin>>v[i];

    ll gc=v[0];
    for(i=1;i<n;i++)gc=__gcd(v[i],gc);
    if(gc>1){
        prs("not coprime");
        return;
    }

    vct cnt(1000001,0);
    vct siev=sieve(1000001);
    F(i,n){
        ll cr=v[i];
        while(cr>1){
            cnt[cr]++;
            cr=cr/siev[cr];
        }
    }
    ll flg=0;
    for(ll i=2;i<=1000000;i++)if(cnt[i]>1)flg=1;

    if(flg)prs("setwise coprime");
    else prs("pairwise coprime");


}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout<<fixed<<setprecision(10);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    while (t--){
        solve();
        cas++;
    }
    return 0;
}
 


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

vector<int> G[30];
bool g[30];

int d[30][30];
const int INF = 1e5;

/*bool dfs(int now, int pre){
	if(g[now] == true) return false;
	bool res = true;
	//cout << now << endl;
	g[now] = true;
	set<int> st;
	for(int i = 0; i < G[now].size(); i++){
		int next = G[now][i];
		//if(next == pre) continue;
		if(st.count(next)) continue;
		st.insert(next);
		res &= dfs(next, now);
	}
	return res;
}*/

void wf(){
	for(int k = 0; k < 26; k++){
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < 26; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	return;
}

int main(){
	int n;
	while(1){
		for(int i = 0; i < 26; i++){
			G[i].clear();
			for(int j = 0; j < 26; j++) d[i][j] = INF;
			d[i][i] = 0;
		}
		cin >> n;
		if(n == 0) break;
		vector<string> s(n);
		for(int i = 0; i < n; i++){
			cin >> s[i];
		}
		bool f = true;
		for(int i = 0; i < n - 1; i++){
			for(int j = 0; j < s[i].size(); j++){
				if(s[i + 1].size() == j){
					f = false; break;
				}
				if(s[i][j] != s[i + 	1][j]){
					G[s[i][j] - 'a'].push_back(s[i + 1][j] - 'a');
					//cout << s[i][j] << "->" << s[i + 1][j] << endl;
					break;
				}
			}
		}
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < G[i].size(); j++){
				d[i][G[i][j]] = -1;
			}
		}
		wf();
		//int e[26][26] = {};
		//for(int i = 0; i < 26; i++) for(int j = 0; j < 26; j++) e[i][j] = d[i][j];
		//wf();
		for(int i = 0; i < 26; i++){
			//cout << d[i][i] << endl;
			if(d[i][i] != 0) f = false;
			//for(int j = 0; j < 26; j++){
			//	if(d[i][j] != e[i][j]) f = false;
			//}
		}
		/*for(int j = 0; j < 26; j++){
		//cout << j << " " << f << endl;
			for(int i = 0; i < 26; i++) g[i] = false;
			f &=  dfs(j, -1);
		}*/
		if(f) cout << "yes" << endl;	
		else cout << "no" << endl;
	}
}

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

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

}



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int A, B;

        A = sc.nextInt();
        B = sc.nextInt();

        out.println( (A + B) - ((A + B)/24)*24);
        
        
        sc.close();
    }
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1e3 + 10;

int N;

ll A[MAX_N][MAX_N];

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

bool is_prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int get_prime() {
    static int x = 2;
    while (!is_prime(x)) x++;
    int res = x; x++;
    return res;
}

void paint(int x, int y, int dx, int dy, ll v) {
    while (x >= 1 && x <= N && y >= 1 && y <= N) {
        A[x][y] *= v;
        x += dx; y += dy;
    }
}

int main() {
    scanf("%d", &N);
    if (N == 2) {
        printf("4 7\n23 10\n");
        return 0;
    }
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= N; j++)
            A[i][j] = 1;
    for (int i = 1; i <= N; i++) {
        if (!(i + 1 & 1)) {
            paint(1, i, 1, 1, get_prime());
        }
    }
    for (int i = 2; i <= N; i++) {
        if (!(i + 1 & 1)) {
            paint(i, 1, 1, 1, get_prime());
        }
    }
    for (int i = 1; i <= N; i++) {
        if (!(i + 1 & 1)) {
            paint(1, i, 1, -1, get_prime());
        }
    }
    for (int i = 2; i <= N; i++) {
        if (!(i + N & 1)) {
            paint(i, N, 1, -1, get_prime());
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (i + j & 1) {
                for (int dx = -1; dx <= 1; dx++) {
                    for (int dy = -1; dy <= 1; dy++) {
                        if (abs(dx) + abs(dy) == 1) {
                            int x = i + dx, y = j + dy;
                            if (x >= 1 && x <= N && y >= 1 && y <= N) {
                                A[i][j] = lcm(A[i][j], A[x][y]);
                            }
                        }
                    }
                }
                A[i][j]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++)
            printf("%lld ", A[i][j]);
        printf("\n");
    }
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll i,j,k,l,n,m;
    cin>>m>>n;
    ll ar[n+1],s=0;
    for(i=1;i<=n;i++){
        cin>>ar[i];
        s+=ar[i];
    }
    if(s>m){
        cout<<"-1"<<endl;
    }
    else{
        cout<<(m-s)<<endl;   
    }
    return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	int n, a;
	cin >> n >> a;
	int minv = a, maxv = INT_MIN;
	rep(i,1,n) {
		cin >> a;
		maxv = max(maxv, a - minv);
		minv = min(minv, a);
	}
	cout << maxv <<endl;
	return 0;
}

Measured memory_bytes: 1164
def isTriangle(a,b,c):
    if a==b or b==c or a==c:
        return False
    
    if a+b>c and b+c>a and a+c>b:
        return True
    else:
        return False
N = int(input())
L = list(map(int, input().split()))
ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if isTriangle(L[a],L[b],L[c]):
                ans+=1
print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

queue<int> que;
void Search(int n, vector<list<int>> & d, vector<int> & ans) {
	for (auto it = d[n].begin(); it != d[n].end(); it++) {
		if (ans[*it] == INF) {
			ans[*it] = n + 1;
			que.push(*it);
		}
	}
	if (!que.empty()) {
		n = que.front();
		que.pop();
		Search(n, d, ans);
	}
	return;
}

int main(void) {
	int n, m, i, a, b;
	cin >> n >> m;
	vector<list<int>> d(n);
	vector<int> ans(n, INF);
	ans[0] = 0;
	rep(i, m) {
		cin >> a >> b;
		a--; b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	Search(0, d, ans);
	printf("Yes\n");
	for (i = 1; i < n; i++)
		cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 18760
class AtCoder:
    def main(self):
        A, B = map(int, input().split())
        A = range(13)[A - 2]
        B = range(13)[B - 2]
        print('Alice' if A > B else 'Bob' if B > A else 'Draw')


if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 2940
#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;
using P = pair<ll, ll>;
double PI = 3.1415926535;
signed main() {
	string s; cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;

  vll a(n);
  REP(i, n)
    cin >> a[i];

  deque<ll> que;
  que.push_back(a[0]);
  REP1(i, n){
    auto it = lower_bound(que.begin(), que.end(), a[i]);
    if(it == que.begin())
      que.push_front(a[i]);
    else{
      it--;
      *it = a[i];
    }
  }

  cout << que.size() << endl;


}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

ll calc(vector<ll> &a, int p)
{
    ll ret = 0;
    for (auto x : a)
    {
        ret += (x - p) * (x - p);
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = INF;
    rep(i, 200)
    {
        ans = min(ans, calc(a, i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

//[1,n]
int bit[210000+1],n;

int sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

void add(int i,int x){
    while(i<=n){
        bit[i]+=x;
        i+=i&(-i);
        //cout<<i<<endl;
    }
}


int main(){
   ll ans=0;
   P a[210000];
   int num[210000];
   cin>>n;
   for(int i=0;i<n;i++){
       cin>>a[i].first;
       a[i].second=i;
   }
   sort(a,a+n);
   for(int i=0;i<n;i++){
       num[a[i].second]=i;
   }

   for(int j=0;j<n;j++){
       ans+=j-sum(num[j]+1);
       add(num[j]+1,1);
       //cout<<ans<<endl;
   }
   //cout<<sum(5)<<endl;
   cout<<ans<<endl;
}



Measured memory_bytes: 7968
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
auto constexpr infty<int> = 1'100'100'100;
template<>
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int N;
  while (cin >> N && N) {
    vector<lli> scores;
    REP(i, N) {
      lli S; cin >> S;
      scores.push_back(S);
    }
    sort(begin(scores), end(scores));
    scores[0] = scores[N-1] = 0;
    cout << accumulate(begin(scores), end(scores), 0) / (N-2) << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n)    for(int i=j;i<n;i++)
#define per(i, j, n)    for(int i=n;i>j;--i)
#define fase_read_init  const int MAXS = 32*1024*1024;char buf[MAXS],*ch;
#define read(x)         while(*ch<=32) ++ch;for(x=0; *ch>='0'; ++ch) x=x*10+*ch-'0';
#define read_init       ch=buf-1;fread(buf,1,MAXS,stdin);
#define SIZE(a)         ((int)a.size())
#define ALL(a)          a.begin(), a.end()
#define LL              ((l + r) >> 1)
#define RR              (LL + 1)
#ifdef chutzpah
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{";for(auto &i : t) os<<i<<",";os<<"\b}";return os;}
template<class S, class T>  ostream& operator<<(ostream &os, const pair<S,T>  &t) {return os<<"("<<t.first<<","<<t.second<<")";}
void debug_out() {cerr << endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}
#define dbg(...) cerr<<"#"<<setw(3)<<setiosflags(ios::left)<<__LINE__<<"["<<#__VA_ARGS__"]:", debug_out(__VA_ARGS__);
#else
#define dbg(...) 42
#endif
template<class T> inline bool MX(T &l,const T &r) {return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r) {return l>r?l=r,1:0;}
typedef long long           ll;
typedef unsigned long long  ull;
typedef pair<int, int>      pii;
const double  EPS  = 1e-8;
const int     INF  = 0x3f3f3f3f;
const int     MOD  = (int)1e9 + 7;
const int     MAXN = (int)2e5 + 5;

int main() {
    int n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    int g = __gcd(n, m);
    int a = n / g, b = m / g;
    for(int i = 0, j = 0; i < n; i += a, j += b) {
        if(s[i] != t[j]) {
            return cout << -1 << endl, 0;
        }
    }
    return cout << 1LL * n * m / g << endl, 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	int64 n, m, v, p;
	cin >> n >> m >> v >> p;
	vector<int64> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
    
	sort(all(a));
	int64 ans = p;
	
	int64 t = n - p;
	int64 sum = 0;
	for (int64 i = t - 1; i >= 0; --i) {
	    int64 cnt = v - p - i;
		if (cnt <= 0) {
		    if (a[i] + m >= a[t]) ++ans;
			sum += a[t] - a[i];
			continue;
		}
		int64 res = m * cnt - sum;
		if (res <= 0) {
		    if (a[i] + m >= a[t]) ++ans;
			sum += a[t] - a[i];
			continue;
		}
		int64 h = res / (t - i);
		if (res % (t - i) != 0) ++h;
		if (a[i] + m >= a[t] + h) ++ans;
		sum += a[t] - a[i];
	}
	
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int bias=12800;
    int h,w;
    cin>>h>>w;
    int a[h][w],b[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>b[i][j];
    vector<vector<vector<int>>>dp(h,vector<vector<int>>(w,vector<int>(bias*2,0)));
    dp[0][0][bias+a[0][0]-b[0][0]]=1;
    dp[0][0][bias-a[0][0]+b[0][0]]=1;
    int ans=bias;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=80;k<bias*2-80;k++){
                if(dp[i][j][k]){
                    if(i<h-1)dp[i+1][j][k+a[i+1][j]-b[i+1][j]]=1,dp[i+1][j][k-a[i+1][j]+b[i+1][j]]=1;
                    if(j<w-1)dp[i][j+1][k+a[i][j+1]-b[i][j+1]]=1,dp[i][j+1][k-a[i][j+1]+b[i][j+1]]=1;
                }
            }
        }
    }
    for(int i=0;i<bias*2;i++)if(dp[h-1][w-1][i])ans=min(ans,abs(bias-i));
    cout<<ans<<endl;
    return 0;
}

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

int n, ans, temp=-1;

int count(int n){
    int ans = 0;
    while(n%2 == 0){
        ans++;
        n/=2;
    }
    return ans;
}

int main(){
    cin >> n;
    for(int i=1, a; i<=n; i++){
        a = count(i);
        if(temp < a){
            ans = i;
            temp = a;
        }
    }
    cout << ans << endl;
}
 


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

namespace ITP1_9_D
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字列strに対して与えられた命令の列を実行するプログラム
            // 命令① print a b：strのa文字目からb文字目を出力
            // 命令② reverse a b：strのa文字目からb文字目までを逆順にする
            // 命令③ replace a b p：strのa文字目からb文字目までをpに置きかえる

            // 1行目：文字列str
            // 2行目：命令の数q
            // 3～q+n行目：命令

            //問題の不備 a,bは何文字目かではなく、文字列のインデックスを示している。

            string str = Console.ReadLine();                                // 1行目を読み込み文字列をstrに取得
            int q = int.Parse(Console.ReadLine());                          // 2行目を読み込み命令の数をqに取得

            for (int i = 0; i < q; i++)                                     // 命令の数だけ以下を繰り返す
            {
                string[] cmnd = Console.ReadLine().Split(' ');              // 命令の行を取得
                int a = int.Parse(cmnd[1]);                                 
                int b = int.Parse(cmnd[2]);

                if (cmnd[0] == "print")                                     // 命令がprintだった時の処理
                {
                    Console.WriteLine(str.Substring(a, b - a + 1));
                }

                else if (cmnd[0] == "reverse")                              // 命令がreverseだった時の処理
                {
                    string str1 = str.Substring(0, a);                      // 反転しない部分前半
                    string str2 = str.Substring(a, b-a+1);                  // 反転する文字列
                    string str3 = str.Substring(b+1);                       // 反転しない部分後半
                    str2 = string.Join("", str2.Reverse());                 // str2を反転
                    str = str1 + str2 + str3;
                }

                else if (cmnd[0] == "replace")                              // 命令がreplaceだった時の処理
                {
                    string p = cmnd[3];                                     // 置き換えた後の文字列pを取得
                    string str1 = str.Substring(0, a);                      // 置きかえない部分前半
                    string str2 = str.Substring(b + 1);                     // 置きかえない部分後半
                    str = str1 + p + str2;

                    //System.Text.StringBuilder replace = new System.Text.StringBuilder(str);
                    //string strTgt = str.Substring(a, b + 1);
                    //replace.Replace(strTgt, p, a, b + 1);
                    //str = replace.ToString();
                }
            }



        }
    }
}



Measured memory_bytes: 18340
#include <bits/stdc++.h>
#define MOD 1000000007
#define md %998244353
#define INF 2e9
#define EPS 1e-9
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define endl "\n"
#define FOR(i,a,b) for (long long i = a; i < b; i++)
#define REV(i,a,b) for (long long i = a; i > b; i--)
#define mset(a, v) memset(a, v, sizeof(a))
#define fd(n) fixed<<setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<long long> vi;
typedef std::vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll solve(ll x,ull y,ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   
  ll n,i,j;
  cin>>n;
  ll a[n];
  
  for(i=0;i<n;i++)cin>>a[i];
  
  ll dp[n+1]={0};
  
  dp[1]=0;
  dp[2]=abs(a[1]-a[0]);
  
  
  for(i=3;i<=n;i++)
  {
  	
  	dp[i]=min( dp[i-1] + abs( a[i-1]-a[i-2]),dp[i-2] + abs(a[i-1] - a[i-3]) );
  	
  	
  	
  }
  
  
  cout<<dp[n];
   
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, K;
  cin >> N >> K;

  if (K % 2 == 0) {
    ll count1 = 0;
    ll count2 = 0;
    rep(i, N + 1) {
      if (i == 0) {
        continue;
      }
      if (i % K == 0) {
        count1++;
      }
      if (i % K == K / 2) {
        count2++;
      }
    }
    ll ans = 0;
    ans += count1 * count1 * count1;
    ans += count2 * count2 * count2;
    COUT(ans);
  } else {
    ll count = 0;
    rep(i, N + 1) {
      if (i == 0) {
        continue;
      }
      if (i % K == 0) {
        count++;
      }
    }
    ll ans = count * count * count;
    COUT(ans);
  }

  return 0;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

a, b = list(map(int, sys.stdin.readline().split()))
if a + b == 15:
    print('+')
elif a*b == 15:
    print('*')
else:
    print('x')


Measured memory_bytes: 14540
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn insertion_sort(mut a: Vec<i32>, n: usize) {
  for i in 1..n {
    let v = a[i];
    let mut j = i;
    while j >= 1 && a[j - 1] > v {
      a[j] = a[j - 1];
      j -= 1;
    }
    a[j] = v;
    println!("{}", a.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
  }
}

fn main() {
  let n: usize = read();
  let a: Vec<i32> = read_vec();

  println!("{}", a.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
  
  insertion_sort(a, n);
}



Measured memory_bytes: 5056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		String s=sc.next();
		int a=0;
		for(int i=0; i<s.length(); i++){
			if(s.charAt(i)=='o') {
				a++;
			}
		}
		if(a+15-s.length()>=8) {
			pl("YES");
		}
		else {
			pl("NO");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    set< int > st;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        st.insert(a);

    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 4e3 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int dp[N][N];

pair <int, int> p[N][N];

int a[N], b[N];

int main () {
	boost;
	string s, t;
	cin >> s >> t;
	int ns = s.size(), nt = t.size();
	for (int i = 0 ; i < ns ; ++ i)
		a[i + 1] = (int) (s[i] - 'a');
	for (int i = 0 ; i < nt ; ++ i)
		b[i + 1] = (int) (t[i] - 'a');
	for (int i = 1 ; i <= ns ; ++ i) {
		for (int j = 1 ; j <= nt ; ++ j) {
			if (a[i] == b[j])
				dp[i][j] = dp[i - 1][j - 1] + 1, p[i][j] = {i - 1, j - 1};
			if (dp[i][j] <= dp[i - 1][j])
				dp[i][j] = dp[i - 1][j], p[i][j] = {i - 1, j};
			if (dp[i][j] <= dp[i][j - 1])
				dp[i][j] = dp[i][j - 1], p[i][j] = {i, j - 1};
		}
	}
	string ans = "";
	while (ns && nt) {
		if (p[ns][nt].first != ns && p[ns][nt].second != nt) {
			ans += s[ns - 1];
		}
		tie (ns, nt) = p[ns][nt];
	}
	reverse (ans.begin(), ans.end());
	cout << ans;
}

Measured memory_bytes: 145536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    REP(i,3) REP(j,3) {
        cin >> c[i][j];
    }
    bool pos = true;
    REP(i,2)
    {
        dump(c[i+1][0]-c[i][0])
        dump(c[i+1][1]-c[i][1])
        dump(c[i+1][2]-c[i][2])

        dump(c[i+1][0]-c[i][0] == c[i+1][1]-c[i][1] && c[i+1][1]-c[i][1] == c[i+1][2]-c[i][2])

        if(c[i+1][0]-c[i][0] == c[i+1][1]-c[i][1] && c[i+1][1]-c[i][1] == c[i+1][2]-c[i][2]) ;
        else {
            dump("hoge")
            pos = false;
        }
    }
    REP(i,2)
    {
        dump(c[2][i+1]-c[2][i])
        dump(c[1][i+1]-c[1][i])
        dump(c[0][i+1]-c[0][i])

        if(c[2][i+1]-c[2][i] == c[1][i+1]-c[1][i] && c[1][i+1]-c[1][i] == c[0][i+1]-c[0][i]) ;
        else {
            dump("hoge")
            pos = false;
        }
    }
    if(pos) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 256
n, t = map(int, input().split())
min_c = 10000
for i in range(n):
    c, tt = map(int, input().split())
    if tt <= t:
        min_c = min(min_c, c)
if min_c < 10000:
    print(min_c)
else:
    print('TLE')



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

#define ll long long
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;

string str[2];
string X[] = {".","#",".","#"};
string Y[] = {"#",".",".","#"};

char A[] = {'.','#','.','#'};
char B[] = {'#','.','.','#'};

int main() {

	int i, j;
	int N;

	cin >> N;

	int ind;
	bool flag = 1;

	string ans;

	while(1)
	{
		bool done = 0;
		for(i = 0; i < 4; i++)
		{
			if(flag)
			{
				str[0].push_back(A[i]);
				str[1].push_back(B[i]);
			}
			else
			{
				str[0].insert(0,X[i]);
				str[1].insert(0,Y[i]);
			}
			cout << str[0] << "\n" << str[1] << "\n";
			fflush(stdout);
			cin >> ans;
			if(ans == "T")
			{
				done = 1;
				break;
			}
			else if(ans == "F")
			{
				if(flag)
				{
					str[0].pop_back();
					str[1].pop_back();
				}
				else
				{
					str[0].erase(0,1);
					str[1].erase(0,1);
				}
				done = 0;
			}
			else
				return 0;
		}
		if(!done)
		{
			flag ^= 1;
		}
	}

	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctype.h>
using namespace std;
int main() {
    int N; cin >> N;
    int ans=0;
    for (int i=0;i<N;i++){
        int a_i; cin >> a_i;
        while (a_i%2==0) {
            a_i /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;



int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll N; ll ret = 0;
    cin >> N;
    
    for(ll i = 1; i * i <= N; i++)
    {
        if(N % i != 0) continue;
        ll B = N / i;
        // A <= B
        if(i < B - 1)
            ret += B - 1;
    }
    
    cout << ret << endl;
    return 0;
}


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


int main(){
   int n;
   cin >> n;
   int ans=0;
   int mi=-inf;
   rep(i,n){
       int h;
       cin >> h;
       if(h>=mi) ans++;
       mi=max(mi,h);
   }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define SZ(x) ((int)(x.size()))
#define FOI(i,a,n) for(int (i)=int(a);(i)<=int(n);++(i))
#define FOD(i,a,n) for(int (i)=int(a);(i)>=int(n);--(i))
#define IN(x,y) ((y).find((x))!=(y).end())
#define ALL(t) t.begin(),t.end()
#define MSET(tabl,i) memset(tabl, i, sizeof(tabl))
#define PSET(x,y) fixed<<setprecision(y)<<lf(x)
#define DBG(c) cout<<#c<<" = "<<c<<endl;
#define RTIME ((double)clock()/(double)CLOCKS_PER_SEC)

template<typename T,typename S>inline bool REMIN(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool REMAX(T&a,const S&b){return a<b?a=b,1:0;}

typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;

int bit(ll x, int pos){ return (x >> pos) & 1; }
ll power(ll base, ll exp, ll c = 1e9 + 7) { if(!exp) return 1; ll r = power(base, exp >> 1, c); r=(r*r)%c; if(exp&1) r=(r*base)%c; return r; }

ll T,N,M,K;  
int a,b,c;
string s1,s2;

const lf PI = 2*acos(0);
const ll INF = 1e9 + 4;
const int NMAX = 3e5+5;
const ll MOD = 1000000007;

	

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	ll A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	ll goal = B - A;
	N --;

	FOI(nc, 0, N) {
		if(goal >= nc * C - (N - nc) * D and goal <= nc * D - (N - nc) * C) {
			cout << "YES";
			return 0;
		}
	}
	
	cout << "NO";

	return 0;
}


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

const int mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, 60) {
        ll x = 0;
        rep(j, n) if (a[j]>>i & 1) x++;
        ll now = x * (n-x) % mod;
        rep(j, i) now = now * 2 % mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;


int n, w;
int a[110][2];
ll dp[110][100100];

int main()
{
    memset(dp, 0x3f, sizeof dp);

    scanf("%d%d", &n, &w);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 2; ++j)
            scanf("%d", &a[i][j]);
    ll ans = 0 ;
    int mxV = 100000;
    dp[n][0] = 0;
    for (int i = n-1; i >= 0; --i)
    {
        dp[i][0] = 0;
        for (int j = 1; j <= mxV; ++j)
        {
            dp[i][j] = dp[i+1][j];
            if (j-a[i][1] >= 0)
                dp[i][j] = min(dp[i+1][j-a[i][1]] + a[i][0], dp[i][j]);
        }
    }
    for (int i = 100000 ; i >= 0; --i)
        for (int j = 0 ; j < n; ++j)
            if (dp[j][i] <= w)
            {
                printf("%d\n", i);
                return 0;
            }

    return 0;
}


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


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

T = UnionFind(N)
ans = [0]*M
ans[M-1] = N*(N-1)//2
for i in reversed(range(M-1)):
    a = A[i+1]
    b = B[i+1]
    if T.isSameGroup(a, b):
        ans[i] = ans[i+1]
    else:
        ans[i] = ans[i+1] - T.Count(a) * T.Count(b)
    T.Unite(a, b)

for i in range(M):
    print(ans[i])


Measured memory_bytes: 99292
#include<stdio.h>
int main(void)
{
	int num1,num2;
	scanf("%d %d",&num1,&num2);
	
	if(num1>num2)
	{
		printf("a > b\n");
	}
	if(num1<num2)
	{
		printf("a < b\n");
	}
	if(num1==num2)
	{
		printf("a == b\n");
	}
	
	return 0;
}

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

vector<int> par;
vector<int> rnk;
vector<int> num;
int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    par[x] = y;
    num[y] += num[x];
    num[x] = 0;
  } else {
    par[y] = x;
    num[x] += num[y];
    num[y] = 0;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  int n, m;
  cin >> n >> m;
  par.resize(n);
  rnk.resize(n);
  num.resize(n);
  rep(i, n) { par[i] = i, rnk[i] = 0, num[i] = 1; }
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    unite(--a, --b);
  }
  int mx = INT_MIN;
  rep(i, n) mx = max(mx, num[i]);
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 5524
#include <iostream>

 using namespace std;

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - h * 60 ;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl;

   return 0;
}



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

int main(void)
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a == 5 && b == 5 && c == 7 ||
    a == 5 && b == 7 && c == 5 ||
    a == 7 && b == 5 && c == 5 ) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 3520
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var A = sc.ArrayInt(N);
        var a = A.OrderByDescending(val => val).ToArray();
        for (int i = 0; i < N; i++) {
            if (A[i] == a[0]) {
                WriteLine(a[1]);
            } else {
                WriteLine(a[0]);
            }
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 22464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  cin >> N;
 
  int startSheet, finishSheet;
  int sumNinzu = 0;
  rep(i, N) {
    cin >> startSheet >> finishSheet;
    
    // 計算
    sumNinzu += finishSheet - startSheet + 1;
  }
  
  cout << sumNinzu;
}

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]
d = {}
alp = W[0][-1]
d[W[0]] = True
for i in range(1, N):
    if W[i] in d:
        print("No")
        exit()
    if alp != W[i][0]:
        print("No")
        exit()
    d[W[i]] = True
    alp = W[i][-1]
print("Yes")


Measured memory_bytes: 3064