akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,a[N],ma[N],s,g[N][2],ans[N];
void chkmax(int &x,int y){if(x<y) x=y;}
struct segment_tree{
	int f[N<<2][2];
	void build(int x,int l,int r){
		f[x][0]=0;f[x][1]=-1e9;
		if (l==r) return;
		int mid=(l+r)>>1;
		build(x*2,l,mid);
		build(x*2+1,mid+1,r);
	}
	void modi(int x,int l,int r,int pos,int *val){
		if (l==r){f[x][0]=val[0];f[x][1]=val[1];return;}
		int mid=(l+r)>>1;
		if (pos<=mid) modi(x*2,l,mid,pos,val);
		else modi(x*2+1,mid+1,r,pos,val);
		f[x][0]=max(f[x*2][0],f[x*2+1][0]);
		f[x][1]=max(f[x*2][1],f[x*2+1][1]);
	}
	void que(int x,int l,int r,int pos,int *t){
		if (l>=pos) {chkmax(t[0],f[x][0]);chkmax(t[1],f[x][1]);return;}
		int mid=(l+r)>>1;
		que(x*2+1,mid+1,r,pos,t);
		if (pos<=mid) que(x*2,l,mid,pos,t);
	}
	void modify(int pos,int *val){modi(1,1,n,pos,val);}
	void query(int pos,int *t){que(1,1,n,pos,t);}
}f;
bool check(int cnt0,int m0,int cnt1,int m1){
	int g[2],v[2]={cnt1-cnt0+s,cnt0-cnt1+s};
	g[0]=0;g[1]=-1e9;f.query(m0,g);
	if ((v[0]>=0)&&(g[v[0]&1]>=v[0])) return 1;
	g[0]=0;g[1]=-1e9;f.query(m1,g);
	if ((v[1]>=0)&&(g[v[1]&1]>=v[1])) return 1;
	return 0;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),ma[i]=max(a[i],ma[i-1]);
	f.build(1,1,n);
	for (int i=n;i;i--){
		g[i][1]=-1e9;
		f.query(a[i],g[i]);s+=(a[i]==ma[i]);
		if (a[i]!=ma[i]) swap(g[i][0],g[i][1]);
		g[i][0]+=1+(a[i]==ma[i]);g[i][1]+=1+(a[i]==ma[i]);
		f.modify(a[i],g[i]);
	}
	g[0][1]=-1e9;
	int cnt0=0,cnt1=0,m0=0,m1=0;
	for (int i=1;i<=n;i++){
		f.modify(a[i],g[0]);s-=(a[i]==ma[i]);
		if (check(cnt0+(a[i]>m0),max(m0,a[i]),cnt1,m1)){cnt0+=(a[i]>m0);m0=max(m0,a[i]);ans[i]=0;}
		else {cnt1+=(a[i]>m1);m1=max(m1,a[i]);ans[i]=1;}
	}
	if (cnt0!=cnt1) puts("-1");
	else{
		for (int i=1;i<=n;i++) putchar(ans[i]+'0');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 10624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	int d = 1,dd=0;
	rep(i, n-1){
		d*=10;
	}
	dd = d*10;
	if(d==1){d = 0;}
	cin>>m;
	vint s(m),c(m);
	rep(i, m){
		cin>>s[i]>>c[i];
	}
	bool flag = true;
	for(int i = d;i<dd;i++){
		flag = true;
		rep(j, m){
			int t = i;
			rep(k, n-s[j]){
				t/=10;
			}
			if(t%10!=c[j]){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        List<Character> fr = new ArrayList<>();
        List<Character> bk = new ArrayList<>();
        String S = sc.next();
        int Q = sc.nextInt();
        boolean rev = false;
        for(int i=0;i<Q;i++){
            int qi = sc.nextInt();
            if(qi == 1){
                rev = !rev;
                continue;
            }
            int fi = sc.nextInt();
            String c = sc.next();
            Character ci = c.charAt(0);
            if((!rev && fi == 1) || (rev && fi == 2)){
                fr.add(ci);
            }else{
                bk.add(ci);
            }
        }
        StringBuilder bld = new StringBuilder();
        if(rev){
            for(int i=bk.size()-1;i>=0;i--){
                bld.append(bk.get(i));
            }
            char[] sC = S.toCharArray();
            for(int i=sC.length-1;i>=0;i--){
                bld.append(sC[i]);
            }
            for(Character c:fr){
                bld.append(c);
            }
        }else{
            for(int i=fr.size()-1;i>=0;i--){
                bld.append(fr.get(i));
            }
            bld.append(S);
            for(Character c:bk){
                bld.append(c);
            }
        }
        System.out.println(bld.toString());
    }


}


Measured memory_bytes: 135844
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e16;
//using Graph = vector<vector<int>>;

void dijkstra( vector<vector<pair<int, int>>> &G, int s, vector<int> &dist ){ //スタート地点を指定
  //コスト、向かう頂点でpair(コストが小さい順に並ぶ)
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
  dist.at(s) = 0;
  que.push(make_pair(0, s));
  while( !que.empty() ){
    pair<int, int> P = que.top();
    que.pop();
    int v = P.second;
    if( dist.at(v) < P.first ) continue;
    for( auto &next : G.at(v) ){
      if( dist.at(next.first) > dist.at(v) + next.second ){
        dist.at(next.first) = dist.at(v) + next.second;
        que.push({dist.at(next.first), next.first});
      }
    }
  }
}

signed main(){
  int V, E, r;
  cin >> V >> E >> r;

  //向かう先の頂点番号、コスト
  vector<vector<pair<int, int>>> G(V);
  vector<int> dist(V, INF);
  for( int i = 0; i < E; i++ ){
    int S, T, D;
    cin >> S >> T >> D;
    G.at(S).push_back({T,D});
  }
  dijkstra(G, r, dist);

  for( int i = 0; i < V; i++ ){
    if( dist.at(i) == INF ) cout << "INF" << endl;
    else cout << dist.at(i) << endl;
  }

 }



Measured memory_bytes: 19456
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n: Int = sc.nextInt
  val m: Int = sc.nextInt()
  val list: List[(Int, Int)] = List.fill(m)(sc.nextInt, sc.nextInt())

  val checkedMap = list.groupBy(_._1).values.foldLeft(Map[Int, Int]())((acc ,c) => {
    if (c.count(_ != c.head) != 0) {
      // 一つの桁について、複数の値が指定されていた場合は -1 を追加。
      acc.updated(c.head._1, -1)
    } else if (c.head._1 == 1 && c.head._2 == 0 && n != 1) {
      acc.updated(c.head._1, -1)
    } else {
      // 一つの桁について、指定されていた値が一つだけであれば、その桁と値のペアを Map に追加。
      acc.updated(c.head._1, c.head._2)
    }
  })

  val validatedMap = Range(1, n + 1).toList.foldLeft(Map[Int, Int]())((acc, c) => {
    acc.updated(c, checkedMap.getOrElse(c, 0))
  })

  if(validatedMap.values.toSeq.contains(-1)) {
    println(-1)
  } else {
    println(validatedMap.map(x => {
      if (x._1 == 1 && x._2 == 0 && n != 1) "1" else x._2.toString
    }).mkString(""))
  }
}

Measured memory_bytes: 55468
n=int(input())
taro=0
hanako=0
for i in range(n):
    t,h=map(str,input().split())
    if t>h:
        taro += 3
    elif h>t:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print(taro,hanako)


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  int sum = 0;
  rep(i,n){
    cin >> p[i];
    sum += p[i];
  }
  
  int y=sum/n;
  
  
  int answer=0;
  int answer2=0;
  rep(i,n){
    answer+=(y-p[i])*(y-p[i]);
  }
  rep(i,n){
    answer2+=(y+1-p[i])*(y+1-p[i]);
  }
  
  
  cout << min(answer,answer2) << endl;
  
  
}


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

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    int L, R, x=0, y=N;
    rep(i, M){
        scanf("%d %d", &L, &R);
        if(x < L) x = L;
        if(y > R) y = R;
    }
    if (y < x) 
        cout << 0 << endl;
    else
        cout << y - x + 1 << endl;
}

Measured memory_bytes: 384
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 3000;
const int MOD = 998244353;

int dp[MAXN + 3];
int tab[MAXN + 3];

int main(){
    int n, s;
    scanf("%d %d", &n, &s);
    for(int i=1; i<=n; i++)
        scanf("%d", &tab[i]);
    int ans = 0;
    for(int i=1; i<=n; i++){
        dp[0] = i;
        for(int j=s; j>=tab[i]; j--){
            dp[j] += dp[j-tab[i]];
            if(dp[j] >= MOD) dp[j] -= MOD;
        }
        
        ans += dp[s];
        if(ans >= MOD) ans -= MOD;
    }
    
    printf("%d\n", ans);
    
return 0;
}

Measured memory_bytes: 256
n = input()
ans = 'YES'
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        ans = 'NO'
    if n[i] == 'K':
        if n[i+1] !='I':
            ans ='NO'
    if n[i] == 'I':
        if n[i+1] !='H':
            ans ='NO'

n = n.replace('A','')
if n != 'KIHBR':
    ans = 'NO'

print(ans)

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  cout << max(max(A + B, A - B), A * B) << endl;

  return 0;
}


Measured memory_bytes: 256
/*
	AOJ 0234 - Problem I: 会津の埋蔵金
	http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0234&lang=jp
*/
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)

struct NODE{
	int cost,x,y,l,r,o;
	NODE(int C,int a,int b,int c,int d,int e){cost = C,x=a,y=b,l=c,r=d,o=e;}
};
bool operator<(const NODE& a,const NODE& b){
	return a.cost > b.cost;
}

// 書き込み用変数O,Cと、酸素情報,マスのデータ,酸素制限(=m)を指定すると、添え字に使う酸素と加算するコストをそれぞれ代入してくれる。
int get(int &O,int &C,int s,int d,int lim){
	if(d<0){
		O = s;
		C = -d;
	}else{
		O = min(lim,s + d);
		C = 0;
	}
}

int solve(int W,int H,int m,int o,vector<vector<int> >data){
	if(o<2)return INF;
	int O,C;
	bool done[10][10][10][10][51] = {0}; // [x][y][l][r][o]
	priority_queue<NODE> Q;
	rep(i,W){
		get(O,C,o-1,data[0][i],m);
		Q.push(NODE(C,i,0,i,i,O));
	}
	while(Q.size()){
		NODE q = Q.top(); Q.pop();
		if(q.o == 0) continue;
		if(q.y == H-1) return q.cost;
		
		if(done[q.x][q.y][q.l][q.r][q.o])continue;
		else done[q.x][q.y][q.l][q.r][q.o] = true;
		
		// 残り酸素が1ならば移動できないのでcontinue
		if(q.o == 1) continue;
		
		//横移動
		static const int dx[] = {-1,1};
		rep(i,2){
			int tx = q.x+dx[i];
			int l = min(q.l,tx) , r = max(q.r,tx);
			if(tx < 0 || tx >= W) continue;
			
			if(l == q.l && r == q.r) C = 0 , O = q.o-1 ;
			else get(O,C,q.o-1,data[q.y][tx],m);
			
			Q.push(NODE(q.cost+C,tx,q.y,l,r,O));
		}
		
		//縦移動
		if(q.y < H-1){
			get(O,C,q.o-1,data[q.y+1][q.x],m);
			Q.push(NODE(q.cost+C,q.x,q.y+1,q.x,q.x,O));
		}
	}
	return INF;
}

int main(){
	int W,H,f,m,o;
	while(cin >> W >> H , W){
		cin >> f >> m >> o;
		vector< vector<int> > data(H,vector<int>(W));
		rep(i,H)rep(j,W)cin >> data[i][j];
		int ans = solve(W,H,m,o,data);
		if(ans <= f) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 1940
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

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

int main() {
    string S;
    cin >> S;
    map<char, int> dict;
    for (int i = 0; i < 4; i++) {
        dict[S[i]] += 1;
    }
    int flag = 0;
    for (auto key : dict) {
        if (key.second != 2) {
            flag = 1;
            break;
        }
    }
    if (flag == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int s=1252;
  for(int i=0;i<1251;i++){
    int c = i*0.08;
    int d = i*0.1;
    if(c==a && d==b){
      s=i;
      break;
    }
  }
  if(s==1252){
    cout << -1 << endl;
  }
  else{
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vll Zalgorithm(string s) {
    vll z(s.size(), 0);
    ll i=1, j=0;
    while (i < s.size()) {
        while (i+j<s.size() && s[j] == s[j+i]) j++;
        z[i] = j;
        if (j==0) {
            i++; continue;
        }
        ll k = 1;
        while (i+k<s.size() && k+z[k]<j) {
            z[i+k] = z[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return z;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    ll ans = 0;
    REP(i, n) {
        vll zarray = Zalgorithm(s.substr(i));
        REP(j, zarray.size()) chmax(ans, min(j, zarray[j]));
    }
    cout << ans << '\n';
    return 0;
}


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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int m;
    ll k;
    cin >> m >> k;

    if (k >= (1ll << m)) {
        cout << -1 << endl;
        ret();
    }

    if (m == 1) {
        if (k == 0) {
            printf("0 0 1 1\n");
            ret();
        } else {
            cout << -1 << endl;
            ret();
        }
    }

    vector<ll> v;
    rep(i, 1ll << m) {
        if (i != k)v.push_back(i);
    }
    vector<ll> u = v;
    reverse(u.begin(), u.end());

    vector<ll> a;
    rep(i, v.size()) {
        a.push_back(v[i]);
    }
    a.push_back(k);
    rep(i, u.size()) {
        a.push_back(u[i]);
    }
    a.push_back(k);

    for (ll l : a) cout << l << ' ';
    cout << endl;
}

Measured memory_bytes: 6000
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");
		double a = Double.parseDouble(array[0]);
		double b = Double.parseDouble(array[1]);
		double c = Double.parseDouble(array[2]);

		double x = (a + b + c) / 2;
		if (a == x || b == x || c == x) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)
#define M 100005
lli gcd(lli a,lli b)
{
    if(a%b==0) return b;
    return gcd(b,a%b);
}
int main()
{
   lli n,i;
   cin>>n;
   lli a[n];
   for(i=0;i<n;i++) cin>>a[i];
   lli g=a[0];
  // int mn=1000000000;
   for(i=1;i<n;i++)
   {

     g=__gcd(a[i],g);


   }
   cout<<g;

}






Measured memory_bytes: 4364
#include <stdio.h>
#define MOD (long long int) 1e9+7
long long int Find_ModPower(long long int base, long long int power, long long int mod){
	if(power == 1){
		return base % mod;
	}
	if(power % 2 == 0){
		long long int s = Find_ModPower(base, power/2, mod);
		return (s * s) % mod;
	}
	else{
		return (base * Find_ModPower(base, power-1, mod)) % mod;
	}
}
int main(){
	long long int N;
	scanf("%lld", &N);
	long long int ans = Find_ModPower(10, N, MOD) + Find_ModPower(8, N, MOD) - 2 * Find_ModPower(9, N, MOD);
	if(ans < 0){
		while(ans < 0){
			ans += MOD;
		}
	}
    else{
        ans %= MOD;
    }
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k, ans;
string s;

int main(){
  int n; cin >> n;
  vector<int>ans = {};
  vector<int> a(n); rep(i,n) cin >> a[i];
  while(n > 0){
    int ite = -1;
    rep(j,a.size()){
      if(a[j] == j+1) ite = j;
    }
    if(ite == -1){
      cout << "-1\n";
      return 0;
    }else{
      ans.push_back(ite+1); a.erase(a.begin()+ite);
    }
    n--;
  }
  rep(i,ans.size()){
    cout << ans[ans.size()-1-i] << "\n";
  }
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d); 
  $who = 0;
  $switch = true;
  while ($switch == true ) {
    // code...
    $c -= $b;
    if ($c <= 0) {
      // code...
      $who = 1;
      $switch = false;
      break;
    }
    $a -= $d;
    if ($a <= 0) {
      // code...
      $who = 2;
      $switch = false;
    }
  }
  if ($who == 1) {
    // code...
    echo "Yes";
  }else {
    // code...
    echo "No";
  }

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

int main() {
  long long R, C, Ans;
  cin >> R >> C;
  if(R==1 || C==1) Ans=1;
  else if(R%2!=0 && C%2!=0) Ans=R*C/2+1;
  else Ans=R*C/2;
  cout << Ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = list(map(int, input().split()))
c = {}
for i in range(a):
    if str(b[i]) in c:
        c[str(b[i])] += 1
    else:
        c[str(b[i])] = 1
c = sorted(c.items(), key=lambda x: x[1], reverse=True)
if len(c) <= 1:
    print(a // 2)
elif len(c) == 2:
    e = [int(c[0][0]), int(c[1][0])] + b
    f = [int(c[1][0]), int(c[0][0])] + b
    ec = 0
    fc = 0
    for i in range(2, len(e)):
        if e[i] != e[i-2]:
            e[i] = e[i-2]
            ec += 1
        if f[i] != f[i-2]:
            f[i] = f[i-2]
            fc += 1
    print(min(ec, fc))
elif len(c) >= 3:
    e = [int(c[0][0]), int(c[1][0])] + b
    f = [int(c[1][0]), int(c[0][0])] + b
    g = [int(c[0][0]), int(c[2][0])] + b
    h = [int(c[1][0]), int(c[2][0])] + b
    j = [int(c[2][0]), int(c[0][0])] + b
    k = [int(c[2][0]), int(c[1][0])] + b

    ec = 0
    fc = 0
    gc = 0
    hc = 0
    jc = 0
    kc = 0
    for i in range(2, len(e)):
        if e[i] != e[i-2]:
            e[i] = e[i-2]
            ec += 1
        if f[i] != f[i-2]:
            f[i] = f[i-2]
            fc += 1
        if g[i] != g[i-2]:
            g[i] = g[i-2]
            gc += 1
        if h[i] != h[i-2]:
            h[i] = h[i-2]
            hc += 1
        if j[i] != j[i-2]:
            j[i] = j[i-2]
            jc += 1
        if k[i] != k[i-2]:
            k[i] = k[i-2]
            kc += 1
    print(min(ec, fc, gc, hc, jc, kc))


Measured memory_bytes: 27284
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
bool used[8];
double dist_sum;
int N; 
vii coords;

// void dfs(int prev, int m) {
//   if (m==N) {
//    return ; 
//   }
//   rep(i, N) {
//     if (!used[i]) {
//       ii prevCity = coords[prev];
//       ii currCity = coords[i];
//       double dist = sqrt(pow(prevCity.first-currCity.first,2) + pow(prevCity.second-currCity.second, 2));
//       dist_sum+=dist;
//       used[i] = true;
//       dfs(i, m+1);
//       used[i] = false;
//     }
//   }
// }

int main() {
  cin>>N;
  coords.resize(N);
  rep(i,N) {
    int x, y; cin>>x>>y;
    coords[i]= ii(x,y);
  }

  // rep(i,N) {
  //   assert(used[i]==false);
  //   used[i]=true;
  //   dfs(i, 1);
  //   used[i]=false;
  // }
  ll x = 2;
  rep(i,N-1) x*=(i+1);

  auto dist = [](ii a, ii b) {
    double dx = a.first-b.first, dy = a.second - b.second;
    return sqrt(dx*dx + dy*dy);
  };
  double sum = 0; 
  rep(i,N) {
    for (int j=i+1; j<N; j++) {
      sum += dist(coords[i], coords[j]);
    }
  }
  ll denom = 1;
  rep(i,N) denom*=(i+1);
  double ans = sum*x / (double) denom; 
  printf("%.10f\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int jank(int a){
  char s[4]="spr";
  FOR(3)if(a==s[i])return i;
}

int main(void){
  int n,m,ans;
  scanf("%d %d",&n,&m);
  
  PRN(n/m+(n%m>0));
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  unsigned long long a[3];
  for (int i = 0; i < 3; i++) {
    scanf("%llu", &a[i]);
  }
    
  for (int i = 0; ; i++) {    
    for (int j = 0; j < 3; j++) {
      if (a[j] % 2) {
        printf("%i\n", i);
        return 0;
      }
    }
    
    if (a[0] == a[1] && a[1] == a[2]) {
      puts("-1");
      return 0;
    }
    
    long long b[] = {(a[1] + a[2])/2, (a[0] + a[2])/2, (a[0] + a[1])/2};
    for (int j = 0; j < 3; j++) {
      a[j] = b[j];
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
bool check(ll x, ll y) {
  ll sumx = 0, sumy = 0;
  ll xx = x, yy = y;
  while (xx > 0) {
    sumx += xx % 10;
    xx /= 10;
  }
  while (yy > 0) {
    sumy += yy % 10;
    yy /= 10;
  }
 
  return y * sumx - x * sumy >= 0;
}
 
ll f(ll x) {
  ll y = x + 1;
  vector<int> v;
  while (y > 0) {
    v.push_back(y % 10);
    y /= 10;
  }
  reverse(ALLOF(v));
 
  map<ll, bool> cand;
  for (int i = v.size(); i > 0; i--) {
    ll a = 0, b = 1, c;
    rep(j, i - 1) {
      a *= 10;
      a += v[j];
    }
    REP(j, i - 1, v.size()) {
      a *= 10;
      b *= 10;
    }
    b /= 10;
    c = b - 1;
    // cout << a << " " << b << " " << c << endl;
    REP(j, v[i - 1], 10) { cand[a + j * b + c] = 1; }
  }
 
  vector<ll> w;
  FOR(it, cand) w.push_back(it->first);
 
  rep(i, w.size()) {
    bool flg = true;
    REP(j, i + 1, w.size()) {
      if (!check(w[i], w[j])) flg = false;
    }
    if (flg) return w[i];
  }
  return -1;
}
 
int main() {
  //
  int K;
  cin >> K;
 
  ll x = 0;
  while (K > 0) {
    x = f(x);
    cout << x << endl;
    K--;
  }
 
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()
T = input()

def gcd(a, b):
    while b :
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

L = lcm(N, M)
s = L // M
t = L // N

if S[::s] != T[::t]:
    L = -1
print(L)


Measured memory_bytes: 39536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int d[4] = {1,0,-1,0};
ll H,W;
using Items1 = tuple<ll,ll,ll>;
using Items2 = tuple<ll,ll,ll,ll>;
map<Items1,ll> mpT;
ll solve(){
    ll res = LINF;
    cin >> H >> W;
    vector<vector<ll>> masu(H+2,vector<ll>(W+2,INF));
    for(int i = 1; i <= H;i++){
        for(int j = 1; j <= W;j++){
            cin >> masu[i][j];
        }
    }
    vector<vector<ll>> dist(H+2,vector<ll>(W+2,INF));
    mpT[Items1(1,1,0)] = 1;
    priority_queue<Items2> q; q.push(Items2(0,1,1,0));
    while(q.size()){
        ll x,y,D,T; tie(T,x,y,D) = q.top(); q.pop();
        if(D > H*W) continue;
        T = -T;
        for(int k = 0; k < 4;k++){
            ll nx = x + d[k],ny = y + d[k^1];
            if(masu[nx][ny] == INF) continue;
            ll Add = masu[nx][ny] + masu[nx][ny]*D*2 + 1;
            if(nx == H && ny == W){
                res = min(res,T + Add - D - 1);
            //    return res;
                continue;
            }
            if(mpT.count(Items1(nx,ny,D+1))){
                if(mpT[Items1(nx,ny,D+1)] <= T + Add){
                    continue;
                }
            }
            mpT[Items1(nx,ny,D+1)] = T + Add;
            q.push(Items2(-(T+Add),nx,ny,D+1));
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 36944
n, k = map(int, input().split())

cnt = 0
buf2_min = 0
buf2_max = 0
buf_max = 0
buf_min = 0

for j in range(k):
    buf2_max += n - j
    buf2_min += j

buf_max = n - k + 1
buf_min = k - 1

for i in range(n - k + 2):
    cnt += buf2_max - buf2_min + 1
    buf_max -= 1
    buf_min += 1
    buf2_max += buf_max
    buf2_min += buf_min
cnt  = cnt % (10**9 + 7)

print(cnt)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  string s;
  cin >> s;
  LOOP(i,4){
    s[i]-='0';
  }
  int a = s[0]*10 + s[1];
  int b = s[2]*10 + s[3];
  bool fa=0,fb=0;
  if(a!=0 && a<=12)fa=true;
  if(b!=0 && b<=12)fb=true;
  if(fa && fb){
    cout << "AMBIGUOUS" << endl;
  }else{
    if(fa)cout << "MMYY" << endl;
    else if(fb)cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
}


Measured memory_bytes: 256
targets = ['A', 'C', 'G', 'T']
 
S = str(input())
 
cnt = 0
ans = 0
for i in range(len(S)):
    if S[i] in targets:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
 
 
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin>>N;
    int x[110],y[110],h[110];
    int xx,yy,hh;
    for(int i=0;i<N;i++){
        cin>>xx>>yy>>hh;
        x[i]=xx;y[i]=yy;h[i]=hh;
    }
    int cx,cy,H;
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int hight;
            
            for(int k=0;k<N;k++){
                if(h[k]!=0){
                    hight=h[k]+abs(x[k]-i)+abs(y[k]-j);
                    break;
                }
            }

            for(int k=0;k<N;k++){
                if(h[k]!=max(hight-abs(x[k]-i)-abs(y[k]-j),0)){break;}
                if(k==N-1){cx=i;cy=j;H=hight;}
            }
        }
    }
    cout<<cx<<" "<<cy<<" "<<H<<endl;
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
     string a , b;
     cin >> a >> b;
     int c = 0;
     for (int i = 0; i < a.size(); i++)
     {
     	if (a[i] != b[i]){
     		c++;
		 }
	 }
	 cout << c ;
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int n, k, c;
int nxt[N], cnt[N];
bool ans[N];
string s;

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    cin >> n >> k >> c;
    cin >> s;
    nxt[n + 1] = n + 1;
    FORW(i, n, 1) {
        if(s[i - 1] == 'o') nxt[i] = i;
        else nxt[i] = nxt[i + 1];
    }
    FORW(i, n, 1) if(s[i - 1] == 'o') {
        cnt[i] = 1 + cnt[ nxt[min(n + 1, i + c + 1)] ];
    }
    int pos = nxt[1], ncnt = 0;
    while(pos <= n) {
        ncnt ++; //cout << pos << '\n';
        int tmp = ncnt - 1 + cnt[nxt[pos + 1]];
        if(tmp < k) ans[pos] = 1;
        pos = nxt[min(n + 1, pos + c + 1)];
    }
    FOR(i, 1, n) if(ans[i]) cout << i << '\n';
}


Measured memory_bytes: 5140
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n;
	cin>>n;
	vi a(n),t(n);
	rep(i,n) cin>>a[i];
	rep(i, n) cin>>t[i];
	vi m(n,0), M(n, 0);
	M[0] = m[0] = a[0];
	REP(i, 1, n){
		if(a[i] == a[i-1]) m[i] = 1, M[i] = a[i];
		else M[i] = m[i] = a[i];
	}
	if(M[n-1]<t[n-1] || m[n-1] > t[n-1]){
		cout<<0<<endl;
		return 0;
	}
	M[n-1] = m[n-1] = t[n-1];
	for(int i = n -2; i >= 0; i--){
		if(t[i]==t[i+1]) m[i] = max(m[i], 1), M[i] = min(M[i], t[i]);
		else M[i] = m[i] = t[i];
	}
	ll ans = 1LL;
	rep(i, n) {
		(ans *= (M[i]-m[i]+1))%=MOD;
		if(M[i]-m[i]<0) ans = 0LL;
	}
	// cout<<ans<<endl;
	// rep(i, n) cout<<m[i]<<" ";
	// cout<<endl;
	// rep(i, n) cout<<M[i]<<" ";
	// cout<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
from collections import deque


def main():
    h = int(input())
    count = 0
    # queue = deque([h])
    # while len(queue) > 0:
    #     mon = queue.popleft()
    #     count += 1
    #     if mon == 1:
    #         continue
    #     else:
    #         new_hp = mon // 2
    #         queue.append(new_hp)
    #         queue.append(new_hp)
    factor = 1
    while h > 1:
        h //= 2
        count += factor
        factor *= 2
    count += factor
    print(count)


if __name__ == '__main__':
    main()


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

int main(void)
{
  ll x,k,d,q,r;
  scanf("%lld %lld %lld",&x,&k,&d);
  
  if(x < 0)
    x = -x;
  
  q = x/d;
  r = x%d;
  
  if(q >= k)
    printf("%lld\n",x-k*d);
  else if((k-q)%2 == 1)
    printf("%lld\n",d-r);
  else
    printf("%lld\n",r);
  
  return 0;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)-form-)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };


template <class N, class E>
struct Rerooting {
	int n;
	const vector<vector<E>>& G;
	vector<N> subtreesum;
	vector<vector<N>> dp; // L
	void dfs1(int v, int p) {
		subtreesum[v] = N();
		for (auto e : G[v]) {
			int nx = e.to;
			if (nx == p) continue;
			dfs1(nx, v);
			subtreesum[v] = subtreesum[v] + subtreesum[nx].include_e(v, e);
		}
		subtreesum[v] = subtreesum[v].include_v(v);
	}
	void dfs2(int v, int p, N top) {
		int deg = int(G[v].size());
		dp[v] = vector<N>(deg + 1);
		dp[v][0] = N();
		for (int i = 0; i < deg; i++) {
			int nx = G[v][i].to;
			dp[v][i + 1] =
				dp[v][i] + (nx == p ? top : subtreesum[nx]).include_e(v, G[v][i]);
		}
		N rnode = N();
		dp[v].back() = dp[v].back().include_v(v);
		for (int i = deg - 1; i >= 0; i--) {
			dp[v][i] = (dp[v][i] + rnode).include_v(v);
			int nx = G[v][i].to;
			if (nx != p) dfs2(nx, v, dp[v][i]);
			rnode = rnode + (nx == p ? top : subtreesum[nx]).include_e(v, G[v][i]);
		}
	}
	Rerooting(const vector<vector<E>>& _g) : n(int(_g.size())), G(_g), subtreesum(n), dp(n) {
		dfs1(0, -1);
		dfs2(0, -1, N());
	}
};

void solve_EDPC_V() {
	struct Edge {
		int to;
		Edge(int t = 0) :to(t) {}
	};


	int N; cin >> N;
	static LL M; cin >> M;
	vector<vector<Edge>>G(N);
	FOR(i, 0, N - 1) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(Edge(b));
		G[b].push_back(Edge(a));
	}
	struct Node {
		LL black = LL(1);
		Node include_e(int, const Edge& e) const {
			return { (black + 1) % M };
		}
		Node operator + (const Node& r) const {
			return { (black * r.black) % M };
		}
		Node include_v(int v) const {
			return *this;
		}
	};
	Rerooting<Node, Edge>all_tree(G);
	auto tree_res = all_tree.dp;
	FOR(i, 0, N) {
		cout << tree_res[i].back().black << endl;
	}

}

int main() {
	solve_EDPC_V();

}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

string s,t,u;
int main(){
  cin>>s>>t>>u;
  char a='A'+s[0]-'a';
  char b='A'+t[0]-'a';
  char c='A'+u[0]-'a';
  cout<<a<<b<<c<<endl;
}


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

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

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n-1] - a[0] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define mod 1000000007ll
typedef long long ll;


int main(void) {
  ll i, j, k, n, num[26], ans = 1;
  scanf("%lld", &n);
  char s[n + 10];
  scanf("%s", s);
  for(i = 0; i < 26; ++i) num[i] = 1;
  for(i = 0; i < n; ++i) num[s[i] - 'a']++;
  for(i = 0; i < 26; ++i) ans *= num[i], ans %= mod;
  ans = (ans - 1) % mod;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())


if A + B <= C * 2:
    print(A * X + B * Y)
else:
    ans = C * max(X, Y) * 2

    cost = A if X > Y else B
    piece = max(X, Y) - min(X, Y)

    for i in range(piece):
        ans = min(ans, ans - 2 * C + cost)
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  ll res = 0;
  for (int i = 1; i <= n; i++){
    if (i % 3 != 0 && i % 5 != 0)
      res += i;
  }

  cout << res << endl;
  

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> a_sum(n + 1);
    a_sum[0] = 0;
    _rep(i, 1, n + 1) a_sum[i] = a_sum[i - 1] + a[i - 1];
    ll ans_min = INFINITY;
    rep(i, n + 1){
        ans_min = min(ans_min, abs(a_sum[i] - (a_sum[n] - a_sum[i])));
    }
    cout << ans_min << endl;
}

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

int main() {
    int64_t N, K;
    std::cin >> N >> K;

    char D[K];
    int64_t d;
    for (int64_t i = 0; i < K; ++i) {
        std::cin >> d;
        D[i] = (char)(d + '0');
    }

    for (int64_t i = N; i <= N * 10; ++i) {
        const std::string s = std::to_string(i);
        bool ok = true;
        for (int64_t j = 0; j < K; ++j) {
            if (s.find(D[j]) != std::string::npos) {
                ok = false;
                break;
            }
        }

        if (ok) {
            std::cout << s << std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }

int main(){
    int n; cin >> n;
    map<string,int> m;
    string pre; cin >> pre;
    m[pre]++;
    bool ans = true;
    for(int i = 1; i < n; i++){
        string cur; cin >> cur;
        if(cur[0] != pre[pre.size()-1] || m[cur] != 0) ans = false;
        else m[cur]++;
        pre = cur;
    }
    if(ans) yes();
    else no();
    return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;
    if(s == u) a--;
    if(t == u) b--;
    printf("%d %d\n", a, b);
    return 0;
}


Measured memory_bytes: 256
import sys
import os


S=list(map(int,list(input())))

A=[i%2 for i in range(len(S))]
B=[(i+1)%2 for i in range(len(S))]

C=[(x+y)%2 for (x,y) in zip(A,S)]
D=[(x+y)%2 for (x,y) in zip(B,S)]

print(min(sum(C),sum(D)))

Measured memory_bytes: 6940
# https://atcoder.jp/contests/abc157/tasks/abc157_c


N, M = gets.split.map(&:to_i)
ss = Array.new(M)
cs = Array.new(M)
M.times do |i|
  ss[i], cs[i] = gets.split.map(&:to_i)
end

MAX_NUM = 1000

def makeCheckStr(ss, cs)
  checkStr = Array.new(N, nil)

  M.times do |i|
    if checkStr[ss[i] - 1] == nil
      checkStr[ss[i] - 1] = cs[i].to_s
    elsif checkStr[ss[i] - 1] != cs[i].to_s
      return false
    end
  end
  return checkStr
end

def checkNum(i, checkStr)
  check = true
  str = i.to_s
  if str.length == checkStr.length then
    roop = checkStr.length
    roop.times do |j|
      unless checkStr[j].nil? then
        if str[j] == checkStr[j] then
          check &&= true
        else
          check &&= false
        end
      end
    end
  else
    check = false
  end
  return check
end

ans = -1
if checkStr = makeCheckStr(ss, cs) then
  MAX_NUM.times do |i|
    if checkNum(i, checkStr) then
      ans = i
      break
    end
  end
  puts ans
else
  puts ans
end


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long ll;

int SURP = 1000000007;

int main(){
	string s;
	cin >> s;

	int g = 0;
	int p = 0;

	int ret = 0;
	REP(i,(int)s.length()){
		if(s[i] == 'g'){
			if(g > p){
				ret++;
				p++;
			}else{
				g++;
			}
		}else{
			if(g > p){
				p++;
			}else{
				ret--;
				g++;
			}
		}
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 512
from heapq import heappop,heappush
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
inf = float("INF")
A.append(-inf)
B.append(-inf)
C.append(-inf)
s = []
Q = []
heappush(Q,[-(A[0]+B[0]+C[0]),0,0,0])
for _ in range(K):
    tmp = heappop(Q)
    print(-tmp[0])
    i = tmp[1]
    j = tmp[2]
    k = tmp[3]
    if [i+1,j,k] not in s:
        heappush(Q,[-(A[i+1]+B[j]+C[k]),i+1,j,k])
        s.append([i+1,j,k])
    if [i,j+1,k] not in s:
        heappush(Q,[-(A[i]+B[j+1]+C[k]),i,j+1,k])
        s.append([i,j+1,k])
    if [i,j,k+1] not in s:
        heappush(Q,[-(A[i]+B[j]+C[k+1]),i,j,k+1])
        s.append([i,j,k+1])


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

struct UnionFind
{
    vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }

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

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int, int>> AB(M);
    for (int i = 0; i < M; i++) {
        cin >> AB[i].first >> AB[i].second;
    }
    UnionFind uf = UnionFind(N+1);
    stack<int64_t> inconv;
    for (int i = M-1; 0 <= i; i--) {
        int a, b; tie(a, b) = AB[i];
        if (uf.same(a, b)) {
            inconv.push(0LL);
        } else {
            inconv.push(uf.size(a) * uf.size(b));
            uf.unite(a, b);
        }
    }
    int64_t ans = 0;
    for (int i = 0; i < M; i++) {
        int64_t t = inconv.top(); inconv.pop();
        ans += t;
        cout << ans << endl;
    }
}


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


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

    int M, K;
    cin >> M >> K;

    int num = 1 << M;
    if (K >= (num) || (M == 1 && K == 1)) {
        printf("%d\n", -1);
        return 0;
    } else if (M == 1 && K == 0) {
        printf("%d %d %d %d\n", 0, 0, 1, 1);
        return 0;
    }
    
    printf("%d ", K);
    for (int i = 0; i < num; ++i) {
        if (i != K) {
            printf("%d ", i);
        }
    }
    printf("%d ", K);
    for (int i = num - 1; i >= 0; --i) {
        if (i != K) {
            printf("%d ", i);
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <climits>
#define MAX 1000000000000000000

bool is_product_overflow(long long a, long long b) {
	return (LLONG_MAX / b < a);
}

int main() {

	int  N;
	std::cin >> N;

	long long* A;
	A = new long long[N];
	long long mul = 1;

	for (int i = 0;i < N;i++) {
		std::cin >> A[i];
		if (A[i] == 0) {
			std::cout << "0" << std::endl;
			return 0;
		}
	}

	for (int i = 0;i < N;i++) {
		if (is_product_overflow(mul, A[i])) {
			std::cout << "-1" << std::endl;
			return 0;
		}
		else {
			mul *= A[i];
		}
	}

	if (mul <= MAX) {
		std::cout << mul << std::endl;
	}
	else {
		std::cout << "-1" << std::endl;
	}
	

	return 0;
}

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

const int maxn = 2005;
const long long p = 1e9 + 7;
long long n, k;
long long val[maxn];
long long a[maxn], b[maxn];
long long ans = 0;



int main(){
	scanf("%lld%lld",&n,&k);
	for(long long i=1;i<=n;i++) scanf("%lld",&val[i]);
	for(long long i=1;i<=n;i++){
		for(long long j=1;j<=n;j++) if(val[j] < val[i]) a[i] ++;
		for(long long j=i+1;j<=n;j++) if(val[j] < val[i]) b[i] ++;
	}
	//for(int i=1;i<=n;i++) printf("%lld %lld\n",a[i],b[i]);
	for(long long i=1;i<=n;i++){
		long long x = k, y = k-1;
		if(x % 2 == 0) x = x / 2;
		if(y % 2 == 0) y = y / 2;
		ans = (ans + (a[i] * x) % p * y) % p;
		ans = (ans + b[i] * k) % p;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256