akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
ll n,dis,d[MAXN],siz[MAXN];
map <ll,int> mp;
pair <int,int> v[MAXN];
int main () {
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&d[i]);
		mp[d[i]]=i,siz[i]=1;
	}
	sort(d+1,d+n+1);
	for (int i=n;i>1;i--) {
		int p=mp[d[i]];
		ll d2=d[i]-(n-siz[p])+siz[p];
		if (mp.find(d2)==mp.end()) {printf("-1\n");return 0;}
		int q=mp[d2];
		siz[q]+=siz[p];
		dis+=siz[p];
		v[n-i+1]=make_pair(p,q);
	}
	if (d[1]!=dis) {printf("-1\n");return 0;}
	for (int i=1;i<n;i++) {
		printf("%d %d\n",v[i].first,v[i].second);
	}
	return 0;
}

Measured memory_bytes: 9984
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = a[-1] / 2
i = bisect.bisect(a, b)
if a[i] - b < b - a[i - 1]:
    print(a[-1], a[i])
else:
    print(a[-1], a[i - 1])

Measured memory_bytes: 14428
N = int(input())
a = list(map(int, input().split()))

ans = []
if N % 2 == 0:
    order = 0
    reverse = N-1
    for i in range(N//2):
        ans.append(a[reverse])
        reverse -= 2
    for i in range(N//2):
        ans.append(a[order])
        order += 2
else:
    order = 1
    reverse = N-1
    for i in range(N//2+1):
        ans.append(a[reverse])
        reverse -= 2
    for i in range(N//2):
        ans.append(a[order])
        order += 2

print(*ans)


Measured memory_bytes: 26180
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
using namespace std;

int main() {
	string  a, b, c;
	cin >> a >> b >> c;
	if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0))
		cout << "YES";
	else
		cout << "NO";
}

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

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class CDigitsInMultiplication {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    int ans = INF;
    REP(i, 1, bpm(10, 5) + 1) {
      if (N % i == 0) {
        ans = min(ans, (int)max(log10(i) / 1 + 1, log10(N / i) / 1 + 1));
      }
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  CDigitsInMultiplication solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int x[100];
    for(int i=0;i<n;i++)cin>>x[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int tmp;
            if(x[i]>x[j]){
                tmp=x[i];
                x[i]=x[j];
                x[j]=tmp;
            }
        }
    }
    int min=x[0],max=x[n-1];
    long long ans=1000000000,tmp=0;
    for(int i=min;i<=max;i++){
        for(int j=0;j<n;j++){
            tmp+=(x[j]-i)*(x[j]-i);
        }
        if(tmp<ans)ans=tmp;
        tmp=0;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,i,v,temp,max=0,yakusuu=1,flag=0;
  scanf("%d%d",&x,&y);
  if(x<=y){temp=y; y=x; x=temp;}
   v=x%y;
   if(x==y){max=x;flag=1;}
   if(flag==0){
  for(i=1;i<=v;i++){
    if(v%i==0){
      yakusuu=i;
      if(y%yakusuu==0){ if(yakusuu>max)max=yakusuu; }
    }
  }
   }
    printf("%d\n",max);
    return 0;
}
     
  



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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb emplace_back
#define scantype int
#define lli long long int
#define N 100003

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

int main(void)
{
  int n;
  string s1,s2;
  cin>>n>>s1>>s2;

  for(int i=0;i<s1.length();i++)
  {
         int flag=1;
         for(int j=0,p=i;p<n;j++,p++)
         {
                if(s1[p]!=s2[j])
                {
                       flag=0;
                       break;
                }
         }
         if(flag)
         {
                cout<<n+i;
                return 0;
         }
         else if(i==s1.length()-1)
         {
                 cout<<2*n;
                 return 0;
         }
  }
  return 0;
}









void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


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

void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for (ll i = 0; i < n; ++i)
	{
		/* code */
		cin>>a[i];
	}
	vector<ll> s;
	
	ll t = n+1;
	ll i = 1;
	ll l = 0;
	bool flag = true;
	set<ll> r;

	while(t--)
	{
		if(r.find(i)!=r.end())
		{
			auto it = find(s.begin(),s.end(),i);
			// cout<<it-s.begin()<<endl;
			if(k<(ll)(it-s.begin()))
			{
				cout<<s[k]<<endl;
				break;
			}
			k -= (ll)(it-s.begin());
			ll temp = s.end()-it;
			flag = false;
			ll y = (k%temp+temp)%temp;
			cout<<*(it+y)<<endl;
			break;
		}
		else
		{
			r.insert(i);
			s.push_back(i);
			i = a[i-1];
		}
	}
	
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 15284
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    if(A+B>=A-B && A+B>A*B){
        cout << A+B << endl;
    }else if(A-B>=A+B && A-B>A*B){
        cout << A-B << endl;
    }else{
        cout << A*B << endl;
    }
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 998244353;


void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto A = s[1];
    auto B = s[2];
    auto K = s[3];
    
    auto Comb = new Combination();
    long ans = 0;
    
    foreach (a; 0..N+1) {
        long b = (K- a * A) / B;
        if ((K - a * A) % B != 0) continue;
        if (b < 0 || b > N) continue;
        ans += Comb.comb(N, a.to!int) * Comb.comb(N, b.to!int) % MOD;
        ans %= MOD;
    }

    ans.writeln;
}


class Combination {
    immutable int MAX = 2*10^^6+1;
    long[] modinv;
    long[] f_mod;
    long[] f_modinv;
    
    this() {
        modinv = new long[](MAX);
        modinv[0] = modinv[1] = 1;
        foreach(i; 2..MAX) {
            modinv[i] = modinv[MOD.to!int % i] * (MOD - MOD / i) % MOD;
        }

        f_mod = new long[](MAX);
        f_modinv = new long[](MAX);
        f_mod[0] = f_mod[1] = 1;
        f_modinv[0] = f_modinv[1] = 1;

        foreach(i; 2..MAX.to!int) {
            f_mod[i] = (i * f_mod[i-1]) % MOD;
            f_modinv[i] = (modinv[i] * f_modinv[i-1]) % MOD;
        }
    }

    long comb(int n, int k) {
        if (n < k) return 0;
        return f_mod[n] * f_modinv[n-k] % MOD * f_modinv[k] % MOD;
    }
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}



Measured memory_bytes: 51580
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  map<char,char>exs,ext;
  int i;
  char ss,tt;
  int chk = 1;
  for(i=0;i<s.length();i++){
    ss=s[i];
    tt=t[i];
    if(exs.count(ss)==1)if(exs[ss]!=tt)chk=0;
    if(ext.count(tt)==1)if(ext[tt]!=ss)chk=0;
    exs[ss]=tt;
    ext[tt]=ss;
  }
  if(chk==1)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 776
#include<cstdio>
#include<queue>

using namespace std;

#define FOR(i, a, b) for(int i = a; i <= b; i++)

const int MAX = 20;

struct Point
{
	char name[MAX];
	int timeneeded;
};

queue<Point> q;

int main()
{
	int n, per;
	scanf("%d%d", &n, &per);
	{
		FOR(i, 1, n)
		{
			Point tmp;
			scanf("%s%d", tmp.name, &tmp.timeneeded);
			q.push(tmp);
		}

		int sum = 0;
		while(!q.empty())
		{
			Point cur = q.front();
			q.pop();
			if(cur.timeneeded <= per)
			{
				sum += cur.timeneeded;
				printf("%s %d\n", cur.name, sum);
			}
			else
			{
				sum += per;
				cur.timeneeded -= per;
				q.push(cur);
			}
		}
	}
	return 0;
}



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

int main() {
  int a,b;
  char op;
  while(1){
    cin >> a >> op >> b;
    if(op=='?')
      break;
    if(op=='+'){
      cout<<a+b<<endl;
    }
    else if(op=='-'){
      cout<<a-b<<endl;
    }
    else if(op=='*'){
      cout<<a*b<<endl;
    }
    else{
      cout<<a/b<<endl;
    }
      
  }
  
  
}

 


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=-1000000000000000009;
    ans=max(ans,b*c);
    ans=max(ans,a*c);
    ans=max(ans,a*d);
    ans=max(ans,b*d);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	n %= 1000;
	cout << (n ? 1000 - n : 0) << '\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,r,d,x;
    cin >>r>>d>>x;
    for(int i=0;i<10;i++){
        x=r*x-d;
        cout <<x<<endl;
    }

    return 0;

}

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

int main()
{
  i64 N, M;
  cin >> N >> M;
  vector<i64> s(M), c(M);
  for (i64 i = 0; i < M; i++)
    cin >> s[i] >> c[i];
  for (i64 i = (N == 1 ? 0 : pow(10, N - 1)); i < pow(10, N); i++)
  {
    string num = to_string(i);
    bool ok = true;
    for (i64 i = 0; i < M; i++)
      if (num[s[i] - 1] - '0' != c[i])
        ok = false;
    if (ok)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int answer = 1;
    for(int i = 0; i < s.size(); i++)
    {
        if( ((i%2 == 0) && s[i] == 'L') || ((i%2 == 1) && s[i] == 'R') )
        {
            answer = 0;
        }
    }

    cout << (answer ? "Yes\n" : "No\n");
    return 0;
}


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


int main(){

    
    string s;

    vector<string> vs;

    int i, j, h;

    int k = 0;


    cin >> s;


    for( i = 0 ; i < s.size() ; i = i + 1 ){

         h = 0;

         for( j = i ; j < s.size() ; j = j + 1 ){

              if( s.at(j) == 'A' ) h += 1;

              else if( s.at(j) == 'T' ) h += 1;

              else if( s.at(j) == 'C' ) h += 1;

              else if( s.at(j) == 'G' ) h += 1;

              else break;

              }

         if( h > k ) k = h;

         }


    cout << k << endl;


    return 0;

    }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct RangeMinimumQuery {
	// 1-indexed??§??¨????§????
	int n;
	vector<int>d;
	RangeMinimumQuery(int m) {
		// m is the number of data
		// ?°??????????????????????????´???°?????????????????????
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 2147483647);
	}
	void update(int i, int x) {
		// update ith (0-indexed) number
		i += n - 1;
		d[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			d[i] = min(d[i * 2 + 1], d[i * 2 + 2]);
		}
	}
	int query(int l, int r) {
		// query [l,r)
		return query(l, r, 0, 0, n);// n??§????????¨?????¨????????¨???????????????
	}
	int query(int a, int b, int k, int l, int r) {
		// query for min of [a,b)
		// ????????????????????°???????¨????????°????????????????????????°
		// k?????????????????????l,r ??????????????????[l,r)?????????????????????????????¨?????¨???
		// ???????????£??????????????????query(a,b,0,0,n)??¨???????????¶

		// [a,b) ??¨ [l,r)???????????????????????°INF
		if (r <= a || b <= l)return 2147483647;

		// [a,b)???[l,r)????????¨???????????§????????°?????????????????????
		if (a <= l&&r <= b)return d[k];
		else {
			//????????§???????????°???2????????????????°????
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeMinimumQuery rmq(n);
	rep(i, 0, q) {
		int com; cin >> com;
		int x, y; cin >> x >> y;
		if (com)cout << rmq.query(x, y + 1) << endl;
		else rmq.update(x, y);
	}
	dump(rmq.d);
	return 0;
}

Measured memory_bytes: 3900
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		for(int i=0; i<n; i++){
			d[i] = sc.nextInt();
		}
      	Arrays.sort(d);
      	int count = 0;
      	for(int i=1; i<n; i++){
          if(d[i]==d[i-1]) count++;
        }
      	System.out.println(n-count);
	}
}


Measured memory_bytes: 35948
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<map>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
#define N 200005
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}
int n,a[N]; LL sum[N],ans;
map<LL,int>mp;
int main()
{
    n=gi();
    for(int i=1;i<=n;++i) a[i]=gi(),sum[i]=sum[i-1]+a[i];
    mp[0]=1;
    for(int i=1;i<=n;++i) {
	ans+=mp[sum[i]];
	mp[sum[i]]++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  int N,cnt=0;
  cin >> N;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(i*j==N){
        cnt++;
      }
    }
  }
  if(cnt){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

x_list = list(map(int, input().split())) 

p = round( sum(x_list) / N )
ans = 0

for i in range(N):
    # ans += round( (x_list[i] - p) ** 2 )
    ans +=  (x_list[i] - p) ** 2 

print(ans)




Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n; cin>>n;
  int maxdiff;
  for(int i=1;i<10000;i++){
    if(i*(i+1)>=2*n){
      maxdiff=i;
      break;
    }
  }
  int tokanu=maxdiff*(maxdiff+1)/2-n;
  for(int i=1;i<=maxdiff;i++){
    if(i!=tokanu){
      cout<<i<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

bool compare(PII a, PII b)
{
    if(a.FF == b.FF) return a.SS < b.SS;
    else return a.FF < b.FF;
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int h,w,n;
    cin>>h>>w>>n;
    int r[h+1] = {0}, c[w+1] = {0};

    PII p[n];
    loop(i,0,n)
    {
        cin>>p[i].FF>>p[i].SS;
        ++r[p[i].FF]; ++c[p[i].SS];
    }
    sort(p,p+n,compare);

    set<int> st;
    int mx = 0;
    loop(i,1,w+1) mx = max(mx,c[i]);

    loop(i,1,w+1)
    {
        if(c[i] == mx) st.insert(st.end(),i);
    }

    int l = st.size(),it = 0, cnt, ans = 0;
    loop(i,1,h+1)
    {
        cnt = 0;
        while(it < n && p[it].FF == i)
        {
            if(st.find(p[it].SS) != st.end()) ++cnt;
            ++it;
        }

        if(cnt == l) ans = max(ans,r[i] + mx - 1);
        else ans = max(ans,r[i] + mx);
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 22372
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

l, r, d = map(int, input().split())
ans = 0
for i in range(l, r+1):
    if i%d == 0: ans += 1
print(ans)

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

int mod = 1000000007;

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    int distance = 0;
    list.push_back(list[0] + K);
    for (int i = 0; i < N; i++)
    {
        distance = max(distance, list[i + 1] - list[i]);
    }
    cout << K - distance;
}

Measured memory_bytes: 1792
// 解説前
#include <iostream>
#include <vector>

// ある頂点に対して行われる操作はそれ自身とその親に対するもののみである。
// => 深さ優先探索を用いて、頂点のカウンターの値を親から順に累積的に計算すれば良い。
int solve_D() {
  size_t N;  // 頂点の数
  size_t Q;  // 操作の回数
  std::cin >> N >> Q;

  // 辺で接続する頂点のリストを作る
  std::vector<std::vector<size_t>> graph(N);
  for (size_t i = 0; i < N - 1; ++i) {
    size_t a, b;
    std::cin >> a >> b;

    // 親子関係が降順である場合にも対応するため、a->bとb->aの両方を登録しておく。
    // 親子関係が逆順であった方は探索アルゴリズムにより無視される。
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }

  // カウンターに足す点数のリストを作る
  std::vector<uint64_t> scores(N);
  for (size_t i = 0; i < Q; ++i) {
    size_t p;
    uint64_t x;
    std::cin >> p >> x;
    scores[p - 1] += x;  // 同じ頂点に対する操作を合算しておく
  }

  // 頂点のカウンターの値を深さ優先で累積的に計算する
  std::vector<size_t> stack;
  stack.reserve(N);
  std::vector<bool> visited(N);
  std::vector<uint64_t> total_scores(N);

  stack.push_back(0);
  visited[0] = true;
  total_scores[0] = scores[0];

  while (true) {
    const auto v = stack.back();

    // 未訪問の子供に訪問する
    auto& children = graph[v];
    bool all_visited = true;
    while (!children.empty()) {
      const auto child = children.back();

      // 訪問済みの子供を再度チェックしないようにリストから除外する
      children.pop_back();

      // 子供が訪問済みでない場合
      if (!visited[child]) {
        // その子供にも訪問するためにスタックに積む
        stack.push_back(child);
        visited[child] = true;

        // その頂点のカウンターの値を累積的に計算する
        total_scores[child] = total_scores[v] + scores[child];

        all_visited = false;
        break;
      }
    }

    // すべての子供が訪問済みである場合
    if (all_visited) {
      // ひとつ前に戻る
      stack.pop_back();

      // すべてに訪問すれば終了
      if (stack.empty()) break;
    }
  }

  // 結果発表
  for (const auto score : total_scores) {
    std::cout << score << ' ';
  }

  return 0;
}

int main() {
  return solve_D();
}


Measured memory_bytes: 18432
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = s1()

r = 0
for c in N:
    r += int(c)
    r %= 9

if r == 0:
    print("Yes")
else:
    print("No")


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

int   par1[200010];
int  rank1[200010];

int   par2[200010];
int  rank2[200010];

void init (int n){
  for(int t=1;t<=n;t++){
    par1[t]=t;
    rank1[t]=0;
  }
}
int  find (int x){
  if(par1[x]==x){
    return x;
  }else{
    return par1[x]=find(par1[x]);
  }
}
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rank1[x]<rank1[y]){
    par1[x]=y;
  }else{
    par1[y]=x;
    if(rank1[x]==rank1[y])rank1[x]++;
  }
}
bool same(int x, int y){
  return find(x)==find(y);
}

void init2(int n){
  for(int t=1;t<=n;t++){
    par2[t]=t;
    rank2[t]=0;
  }
}
int  find2(int x){
  if(par2[x]==x){
    return x;
  }else{
    return par2[x]=find2(par2[x]);
  }
}
void unite2(int x, int y){
  x=find2(x);
  y=find2(y);
  if(x==y)return;

  if(rank2[x]<rank2[y]){
    par2[x]=y;
  }else{
    par2[y]=x;
    if(rank2[x]==rank2[y])rank2[x]++;
  }
}
bool same2 (int x, int y){
  return find2(x)==find2(y);
}

int main(){
  int N,K,L;
  scanf("%d%d%d",&N,&K,&L);

  init (N);
  init2(N);

  for(int t=1;t<=K;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    unite(a,b);

  }
  for(int t=1;t<=L;t++){
    int a,b;
    scanf("%d%d",&a,&b);
    unite2(a,b);
  }

  map<P,int>m;
  P p[200010];

  for(int t=1;t<=N;t++){
    p[t]=P(find(t),find2(t));
    m[p[t]]=0;
  }


  for(int t=1;t<=N;t++){
    m[p[t]]++;
  }
  for(int t=1;t<=N;t++){
    cout<<m[p[t]]<<" ";
  }
  printf("\n");
  return 0;
}


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

void solve(int A, int B)
{
    cout << ((A < 10 && B < 10) ? A * B : -1) << endl;
}

int main()
{
    int A;
    cin >> A;
    int B;
    cin >> B;
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define bye return 0
#define Yes cout << "Yes" << "\n"
#define No  cout << "No" << "\n"
#define YES cout << "YES" << "\n"
#define NO cout << "NO" << "\n"
//#define endl cout << "\n"
typedef long long ll;
int main(){ 
    ll a, b;
    cin >> a >> b;
    cout << a*b << endl;
    bye;
}




Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct Q {
public:
  int no;
  int cost;
  int visited;
};

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

int table[20][20];
int min_cost(int start) {
  queue<Q> qs;
  qs.push({start, 0, (1 << start)});

  int mc = table[start][1];

  while(!qs.empty()) {
    auto q = qs.front();
    qs.pop();
    if(q.no == 1) {
      chmin(mc, q.cost);
    }
    for(int i = 0; i < 10; ++i) {
      if(q.no == i) {
        continue;
      }
      if(q.visited & (1 << i)) {
        continue;
      }
      auto next_cost = q.cost + table[q.no][i];
      if(next_cost > mc) {
        continue;
      }
      qs.push({i, next_cost, q.visited | (1 << i)});
    }
  }
  return mc;
}

int main() {
  int H, W;
  cin >> H >> W;
  for(int i = 0; i < 10; ++i) {
    for(int j = 0; j < 10; ++j) {
      cin >> table[i][j];
    }
  }
  vector<int> as;
  int a;
  for(int i = 0; i < H * W; ++i) {
    cin >> a;
    if(a >= 0) {
      as.push_back(a);
    }
  }
  int costs[20] = {0};
  for(int i = 0; i < 10; ++i) {
    costs[i] = min_cost(i);
  }
  int ans = 0;
  for(auto a : as) {
    ans += costs[a];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};} 
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(modint a);
  modint operator/(modint a) {return {*this*inv(a)};}
  modint& operator+=(modint a) {
    *this = *this+a;
    return *this;
  }
  modint& operator*=(modint a) {
    *this = *this*a;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

struct mono{
  modint a;
  int sz;
  mono(modint m1=0,int s=1){ a=m1; sz=s; }
};
std::istream& operator>>(std::istream& os,mono& m){
  // ここでストリームに obj を書き込みます。
  modint a; cin >>a;
  m=a;
  return os;
}
std::ostream& operator<<(std::ostream& os, const mono& m){
  // ここでストリームに obj を書き込みます。
  cout << m.a;
  return os;
}

mono op(mono m1,mono m2){ return {m1.a+m2.a, m1.sz+m2.sz}; }
mono e(){return mono();}

struct T{
  modint b,c;
  T(modint b1=1,modint c1=0){b=b1,c=c1;};
};
mono ope(T g,mono m){ return {g.b*m.a+g.c*m.sz, m.sz}; }
T comp(T g1,T g2){ return {g1.b*g2.b,g1.b*g2.c+g1.c}; }
T id(){return T();}

modint gcksolve(vector<modint>& v,int t,int l,int r,modint b=0,modint c=0){
  if(t==0){
    for(int i=l;i<r;i++){
      v[i]*=b;
      v[i]+=c;
    }
    print(v);
    return 0;
  }else{
    modint s=0;
    for(int i=l;i<r;i++) s+=v[i];
    return s;
  }
}

int main(){
  int n,q; cin >>n >>q;
  vector<mono> a(n); for(auto& x:a) cin >>x;
  atcoder::lazy_segtree<mono,op,e,T,ope,comp,id> lz(a);
  
  vector<modint> gck(n);
  rep(i,n) gck[i]=a[i].a;
  
  
  rep(_,q){
    int t; cin >>t;
    if(t==0){
      int l,r; modint b,c; cin >>l >>r >>b >>c;
      lz.apply(l,r,{b,c});
      if(df) gcksolve(gck,0,l,r,b,c);
    }else{
      int l,r; cin >>l >>r;
      print(lz.prod(l,r));
      if(df) print(gcksolve(gck,1,l,r));
    }
  }
}


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

int main()
{
	int D;
	cin >> D;
	if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
	else if (D == 23) cout << "Christmas Eve Eve" << endl;
	else if (D == 24) cout << "Christmas Eve" << endl;
	else cout << "Christmas" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(3*n);
  vll h(0);
  vll d(0);
  ll cu=0;
  ll ccu=0;
  PQR M;
  PQ B;
  rep(i,3*n){
    cin>>a[i];
    if(i<n) {
      cu+=a[i];
      M.pu(a[i]);
    }
    else if(i>=2*n){
      ccu+=a[i];
      B.pu(a[i]);
    }
  }
  h.pb(cu);
  d.pb(ccu);
  for(int i=n;i<2*n;i++){
    cu+=a[i];
    M.pu(a[i]);
    cu-=M.top();
    M.pop();
    h.pb(cu);
  }
  for(int i=2*n-1;i>=n;i--){
    ccu+=a[i];
    B.pu(a[i]);
    ccu-=B.top();
    B.pop();
    d.pb(ccu);
  }
  ll ans=0;
  ans-=INF;
  rep(i,n+1){
    ans=max(ans,h[i]-d[n-i]);
  }
  COUT(ans);
}

Measured memory_bytes: 6516
#include <stdio.h>

int main(void)
{
    int n, k;
    scanf("%d%d", &n, &k);
    char s[50];
    scanf("%s", s);

   



    if(s[k - 1] == 'A'){
        s[k - 1] = 'a';
    }else if(s[k - 1] == 'B'){
        s[k - 1] = 'b';
    }else if(s[k - 1] == 'C'){
        s[k - 1] = 'c';
    }

    printf("%s\n", s);

    return 0;
}

Measured memory_bytes: 128
N=int(input())
bin_a="".join(["{:060b}".format(a) for a in map(int, input().split())])
mod=10**9+7
xor=0
for d in range(60):
  ones=bin_a[59-d::60].count('1')
  xor+=2**d*ones*(N-ones)    
print(xor%mod)

Measured memory_bytes: 65752
//abc052_a.cpp
//Fri Oct 19 23:04:55 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	if (a*b > c*d){
		cout << a*b << endl;
	}else {
		cout << c*d << 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<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define INF (INT_MAX)

void solve(ll H, ll W, vector<string> s){
  vector<vector<int>> level(H, vector<int>(W, INF));
  queue<pair<int, int>> q;

  q.push(make_pair(0,0));
  level[0][0]=1;
  // BFS
  while(!q.empty()){
    pair<int, int> curr=q.front();
    int y = curr.first, x = curr.second;
    q.pop();
    for(int dy=-1;dy<2;dy++){
      for(int dx=-1;dx<2;dx++){
        if(dy+dx!=1 && dy+dx!=-1)continue;
        // printf("(%d %d)\n", dy, dx);
        if(y+dy<0 || y+dy>=H || x+dx <0 || x+dx>=W)continue;
        if(s[y+dy][x+dx]=='.'){
          if(level[y+dy][x+dx] > level[y][x]+1){
            level[y+dy][x+dx] = level[y][x]+1;
            q.push(make_pair(y+dy, x+dx));
          }

        }
      }
    }
  }
  // REP(i, H){
  //   REP(j, W){
  //     cout << level[i][j] << " ";
  //   }
  //   cout<<endl;
  // }


  if(level[H-1][W-1]==INF){
    cout << -1 << endl;
    return;
  }else{
    ll counter=0;
    REP(i, H)REP(j,W)if(s[i][j]=='.')counter++;
    cout << counter-level[H-1][W-1] << endl;
    // printf("num of white: %lld\n", counter);
  }


}

int main(){
  ll W, H;
  scanf("%lld", &H);
  scanf("%lld", &W);
  vector<string> s(H);
  REP(i, H){
    cin>>s[i];
  }
  solve(H, W, move(s));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?'){
			break;
		}
		if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
		}else if(op=='*'){
			printf("%d\n",a*b);
		}else{
			printf("%d\n",a/b);
		}
	}
}
		


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, X;
  	cin >> N >> X;
  	vector<int> m(N);
  	for(int i = 0; i < N; i++){
    	cin >> m.at(i);
      	X -= m.at(i);
    }
  	sort(m.begin(), m.end());
  	cout << N + X / m.front();
  	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

ans = S[1:].count('E')
left = 0
right = ans

for i in range(1, N):
    if S[i-1] == 'W':
        left += 1
    if S[i] == 'E':
        right -= 1
    ans = min(ans, left + right)
print(ans)


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

int main() {
	string S, T;
	cin >> S >> T;
	int N = S.size(); // 要素数(文字数)
				  // S.size() == T.size() は前提となっている
	vector<int> num_s(N);
	vector<int> num_t(N);
	for (int i = 0; i < N; i++) {
		num_s[i] = 0; // 0で初期化
		num_t[i] = 0;
	}


	for (int i = 0; i < N; i++) {
		if (num_s[i] == 0) { // すでに値が入っていたらスルー
			num_s[i] = i;
			for (int j = i+1; j < N; j++) { // 自分より後の要素のみを探索
				if (S[i] == S[j]) { // i番目とj番目の文字が同じならnum_s[j]の値をnum_s[i]と同じにする
					num_s[j] = i;
				}
			}
		}

	}

	for (int i = 0; i < N; i++) {
		if (num_t[i] == 0) {
			num_t[i] = i;
			for (int j = i + 1; j < N; j++) {
				if (T[i] == T[j]) { 
					num_t[j] = i;
				}
			}
		}

	}

	if (num_s == num_t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 2312
n,a,b=map(int,input().split())
MOD  = 1000000007

def comb(N,x):
    numerator = 1
    for i in range(N-x+1,N+1):
        numerator = numerator *i%MOD
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator *j%MOD
    d = pow(denominator,MOD-2,MOD)
    return (numerator*d)%MOD


#実際に使うときは、MOD=10000007 などの剰余計算を組み込んで使うこと！
def repeated_square(x,n):
    #nを2進数で表して順序反転
    bit_n=bin(n)[2:][::-1]

    ans=1
    ni=x

    if(bit_n[0]=="1"):
        ans*=ni

    for i in range(1,len(bit_n)):
        ni=((ni%MOD)*(ni%MOD))%MOD

        #i桁目が1なら、x^(2^i)を加える
        if(bit_n[i]=="1"):
            ans=((ans%MOD)*(ni%MOD))%MOD

    return ans

alln=(repeated_square(2, n)-1)%MOD
print((alln-comb(n, a)-comb(n, b))%MOD)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    auto finish = []() {
        cout << -1 << endl;
        exit(0);
    };
    auto add = [](int a, int b) {
        cout << a << " " << b << endl;
    };

    string s;
    cin >> s;
    int n = s.length();
    if (s[0] == '0' || *s.rbegin() == '1') finish();
    for (int l = 0, r = n - 2; l < n - 1; l++, r--) {
        if (s[l] != s[r]) finish();
    }
    int now_top = 1;

    rep(i, n - 1) {
        int now_num = i + 2;
        add(now_top, now_num);
        if (s[i] == '1') now_top = now_num;
    }
    return 0;
}



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


#define INF 1000000000000


signed main(){
int x;
cin>>x;

for(int a=0;a<=10000000;a++){
  int t=0;
  if(a*a*a*a*a-x>0){t=pow(a*a*a*a*a-x,1.0/5.0);}
  else t=-1*pow(x-a*a*a*a*a,1.0/5.0);
  int b=t;
  if(a*a*a*a*a-b*b*b*b*b==x){cout<<a<<' '<<b<<endl; exit(0);}
  b++;
  if(a*a*a*a*a-b*b*b*b*b==x){cout<<a<<' '<<b<<endl; exit(0);}

}

}


Measured memory_bytes: 4100
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
   int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   int x;
   cin >> x;

   cout << arr[x-1] << endl;

   return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;
	
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for(int i = 0; i < n; ++i)
			a[i] = Integer.parseInt(sc.next());
		sc.close();
		int cnt = selectionSort(a);
		printArray(a);
		System.out.println(cnt);
	}
	
	public static void printArray(int[] a){
		int n = a.length;
		for(int i = 0; i < n; ++i){
			if(i != 0) System.out.print(" ");
			System.out.print(a[i]);
		}
		System.out.println();
	}
	
	public static int selectionSort(int[] a){
		int n = a.length, ret = 0;
		for(int i = 0; i < n; ++i){
			int minidx = i;
			for(int j = i; j < n; ++j){
				if(a[j] < a[minidx]) minidx = j;
			}
			if(i != minidx){
				++ret;
				{//swap(a[i], a[minidx])
					a[i] ^= a[minidx];
					a[minidx] ^= a[i];
					a[i] ^= a[minidx];
				}
			}
		}
		return ret;
	}
}



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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VVVVI vector<vector<vector<vector<int>>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VVVVL vector<vector<vector<vector<LL>>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }
inline bool inside(int y, int x, int H, int W) { return 0 <= y and y < H and 0 <= x and x < W; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, 1, 0, -1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

class CumulativeSum {

public:
    vector<int> memo1;          // 1次元用の累積和表
    vector<vector<int>> memo2;  // 2次元用の累積和表

    CumulativeSum(const vector<int> &line) {
        this->memo1.resize(line.size() + 1, 0);

        for (int i = 0; i < line.size(); ++i) {
            this->memo1[i + 1] = this->memo1[i] + line[i];
        }
    }

    // 2次元の累積和表を作成
    CumulativeSum(const vector<vector<int>> &board) {
        int height = board.size();
        int width = board[0].size();
        this->memo2 = vector<vector<int>>(height + 1, vector<int>(width + 1, 0));

        for (int y = 0; y < height; ++y) {
            for (int x = 0; x < width; ++x) {
                memo2[y + 1][x + 1] = board[y][x] + memo2[y + 1][x];
            }
            for (int x = 0; x < width; ++x) {
                memo2[y + 1][x + 1] += memo2[y][x + 1];
            }
        }
    }

    int sum(int left, int right) {
        return this->memo1[right] - this->memo1[left];
    }

    /*
    (y1, x1)から(y2, x2)の合計を返す．(y2, x2)は含まない
    座標はmemoを作成したboard準拠
    (ex, sum(0, 0, 2, 2)なら(0, 0), (0, 1), (1, 0), (1, 1)の合計を返す)
    */
    int sum(int y1, int x1, int y2, int x2) {
        return this->memo2[y2][x2] - this->memo2[y2][x1] - this->memo2[y1][x2] + this->memo2[y1][x1];
    }

};

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

    int n, m;
    cin >> n >> m;
    VI A(n - 1), B(m);
    FOR(i, 0, n - 1) {
        cin >> A[i];
    }

    FOR(i, 0, m) {
        cin >> B[i];
    }

    CumulativeSum cs(A);
    LL ans = 0;
    int now = 0;
    FOR(i, 0, B.size()) {
        int next = now + B[i];
        next = min(max(0, next), n);
        (ans += cs.sum(min(now, next), max(now, next))) %= 100000;

        now = next;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 4152
#include <iostream>
#include <deque>
#include <limits>

constexpr int N = 1000;
constexpr int M = 1000;
char map[N + 2][M + 2];
int dist[N + 2][M + 2];

struct point_t
{
    int x, y;
};
int main()
{
    int H, W;
    std::cin >> H >> W;
    point_t maze, target;
    std::cin >> maze.y >> maze.x;
    std::cin >> target.y >> target.x;

    for (int y = 1; y <= H; y++)
    {
        for (int x = 1; x <= W; x++)
        {
            std::cin >> map[y][x];
            dist[y][x] = -1;
        }
    }

    std::deque<point_t> que;
    que.push_back(maze);
    dist[maze.y][maze.x] = 0;
    while (!que.empty())
    {
        auto p = que.front();
        que.pop_front();
        for (int dy = -2; dy <= 2; dy++)
        {
            for (int dx = -2; dx <= 2; dx++)
            {
                auto tp = point_t{p.x + dx, p.y + dy};
                if (dx == 0 && dy == 0)
                    continue;
                if (tp.x < 0 || W < tp.x || tp.y < 0 || H < tp.y)
                    continue;
                if (map[tp.y][tp.x] != '.')
                    continue;
                if ((-1 <= dx && dx <= 1 && dy == 0) || (-1 <= dy && dy <= 1 && dx == 0))
                {
                    if (dist[tp.y][tp.x] == -1 || dist[tp.y][tp.x] > dist[p.y][p.x])
                    {
                        dist[tp.y][tp.x] = dist[p.y][p.x];
                        que.push_front(tp);
                    }
                }
                else
                {
                    if (dist[tp.y][tp.x] == -1 || dist[tp.y][tp.x] > dist[p.y][p.x] + 1)
                    {
                        dist[tp.y][tp.x] = dist[p.y][p.x] + 1;
                        que.push_back(tp);
                    }
                }
            }
        }
    }
    std::cout << dist[target.y][target.x] << std::endl;
}

Measured memory_bytes: 8500
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

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


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

struct Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
  if(u==NIL)return;
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if (T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
  return T[T[u].parent].right;
return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }
  else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root =0;
  scanf("%d",&n);

  for (int i = 0;i<n;i++) T[i].parent = NIL;

  for(int i = 0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }
  for(int i = 0;i < n;i++) if(T[i].parent == NIL)root = i;

  setDepth(root,0);
  setHeight(root);

  for(int i=0;i < n;i++)print(i);

  return 0;
}



Measured memory_bytes: 2100