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

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

  ll mn = (n - 1) * a + b;
  ll mx = a + (n - 1) * b;

  cout << mx - mn + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

using ll = long long;
using ull = unsigned long long;
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 = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int main()
{
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl; 
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>

#define MAX_N 200000

int n;
int max_v, min_v;

int R[200000];


int main() {
    std::cin >> n;
    for (int i=0; i<n; i++) std::cin >> R[i];

    max_v = R[1]-R[0];
    min_v = R[0];

    for (int j=1; j<n; j++) {
        max_v = std::max(max_v, R[j] - min_v);
        min_v = std::min(min_v, R[j]);
    }

    std::cout << max_v << std::endl;

    return 0;
}



Measured memory_bytes: 3888
#include "bits/stdc++.h"
using namespace std;

int main() {
        vector<string> a(2);
        for (int i = 0; i < 2; i ++) cin >> a[i];
        puts(a[0][0] == a[1][2] && a[1][0] == a[0][2] && a[0][1] == a[1][1] ? "YES" : "NO");
        return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
list_height = list(map(int, input().split()))
list_way = []
list_goodpoint = [1]*n
for i in range(m):
  list_way.append(list(map(int, input().split())))

for way in list_way:
  if list_height[way[0]-1] == list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] > list_height[way[1]-1]:
    list_goodpoint[way[1]-1] = 0
  if list_height[way[0]-1] < list_height[way[1]-1]:
    list_goodpoint[way[0]-1] = 0
print(sum(list_goodpoint))

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int num[32]={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 k;
    cin>>k;
    cout<<num[k-1]<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline
from collections import deque

def main():
    N,M,K=map(int,input().split())
    ABadj=[[] for i in range(N)]
    CDadj=[set() for i in range(N)]
    for i in range(M):
        a,b=map(int,input().split())
        ABadj[a-1].append(b-1)
        ABadj[b-1].append(a-1)
    for i in range(K):
        c,d=map(int,input().split())
        CDadj[c-1].add(d-1)
        CDadj[d-1].add(c-1)
    
    w=[-1]*N
    sets=[]
    j=-1
    done=[-1]*N
    for i in range(N):
        if done[i]==-1:
            sets.append(set())
            j+=1
            qu=deque([i])
            done[i]=1
            sets[j].add(i)
            w[i]=j
            while(len(qu)>0):
                v=qu.popleft()
                for nv in ABadj[v]:
                    if done[nv]==-1:
                        done[nv]=1
                        qu.append(nv)
                        sets[j].add(nv)
                        w[nv]=j
    
    for i in range(N):
        ans=len(sets[w[i]])-1-len(ABadj[i])
        for bl in CDadj[i]:
            if bl in sets[w[i]]:
                ans-=1
        print(ans,end=" ")
            
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 136112
#include<bits/stdc++.h>
using namespace std;
 
int main(){
        int y[2], m[2], d[2];
        int nowd, nowm;
         
        cin >> y[0] >> m[0] >> d[0];
        cin >> y[1] >> m[1] >> d[1];
         
        if(d[0] == d[1] && m[0] == m[1]){ // 誕生日が一緒
                cout << abs(y[0] - y[1]) << endl;
        }else{
                int ans = abs(y[0] - y[1]);
                if(y[0] > y[1]){
                        if(m[0] > m[1]) ++ans;
                        else if(m[0] == m[1] && d[0] > d[1]) ++ans;
                }else if(y[0] < y[1]){
                        if(m[1] > m[0]) ++ans;
                        else if(m[0] == m[1] && d[1] > d[0]) ++ans;
                }else{
                        ++ans;
                }
                cout << ans << endl;
        }
         
        return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn][3];
int main(){
  IOS();
  string s;
  cin>>s;
  ll n=SZ(s);
  s=' '+s;
  ll cnt=1;
  REP1(i,n){
    dp[i][0] = (dp[i-1][0]*(s[i]=='?' ?3:1))%MOD;
    if( s[i]=='C' || s[i]=='?' ) dp[i][0]=(dp[i][0]+dp[i-1][1])%MOD;
    dp[i][1] = (dp[i-1][1]*(s[i]=='?' ?3:1))%MOD;
    if( s[i]=='B' || s[i]=='?' ) dp[i][1]=(dp[i][1]+dp[i-1][2])%MOD;
    dp[i][2] = (dp[i-1][2]*(s[i]=='?' ?3:1))%MOD;
    if( s[i]=='A' || s[i]=='?' ) dp[i][2]=(dp[i][2]+cnt)%MOD;
    cnt = (cnt*(s[i]=='?' ?3:1))%MOD;
  }
  cout<<dp[n][0]<<endl;
}


Measured memory_bytes: 2796
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		BigDecimal molecule = new BigDecimal(1);
		BigDecimal denominator = new BigDecimal(0);
		for (int ai : a) {
			denominator = denominator.add(new BigDecimal((double) 1 / ai));
		}

		out.println(molecule.divide(denominator, 10, BigDecimal.ROUND_HALF_UP));
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main(){
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> work(n,-1);
  int cnt = 0;
  for(int i=0; i<n; ++i){
    if(s[i] == 'o'){
      ++cnt;
      work[i] = cnt;
      if(cnt == k) break;
      i += c;
    }
  }
  vector<int> ans(0);
  for(int i=n-1; i>=0; --i){
    if(s[i] == 'o'){
      if(work[i] == cnt) ans.push_back(i+1);
      --cnt;
      if(cnt == 0) break;
      i -= c;
    }
  }
  reverse(ans.begin(),ans.end());
  for(int a: ans){
    printf("%d\n",a);
  }
}

Measured memory_bytes: 5296
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())
cnt = 0
if k <= a:
    cnt += k
elif (a < k <= a+b):
    cnt += a
elif (a+b < k < a+b+c):
    cnt += a - (k-(a+b))
else:
    cnt += a - c
print(cnt)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ok = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] != i + 1) ok++;
    }
    if (ok > 2) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AGC032B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<Edge> Edges = new List<Edge>();

            for (int i = 1; i <= N; i++)
            {
                for (int j = N; j > i; j--)
                {
                    Edge edge = new Edge(i, j);
                    Edges.Add(edge);
                }
            }

            if (N % 2 == 0)
            {
                for (int i = 1; i <= N / 2; i++)
                {
                    Edge removeEdge = new Edge(i, N - i + 1);
                    Edges.Remove(removeEdge);
                }
            }
            else
            {
                for (int i = 1; i <= N / 2; i++)
                {
                    Edge removeEdge = new Edge(i, N - i);
                    Edges.Remove(removeEdge);
                }
            }

            Console.WriteLine(Edges.Count);
            for (int i = 0; i < Edges.Count; i++)
            {
                Console.WriteLine("" + Edges[i].a + " " + Edges[i].b);
            }
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public Edge(int a, int b)
        {
            this.a = a;
            this.b = b;
        }

        public override bool Equals(object obj)
        {
            //objがnullか、型が違うときは、等価でない
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }
            //この型が継承できないクラスや構造体であれば、次のようにできる
            //if (!(obj is TestClass))

            //Numberで比較する
            Edge c = (Edge)obj;
            return a == c.a & b == c.b;
        }
    }
}

Measured memory_bytes: 13280
#include<stdio.h>

int calc_gcd (int a,int b);


int main (void){

    int a, b;
    int gcd;
    int lcm;

    while(scanf("%d %d",&a ,&b) != EOF){

        if(a > b){
            gcd = calc_gcd(a, b);
        }else if(b > a){
            gcd = calc_gcd(b, a);
        }else if(a == b){
            gcd = a;
        }

        lcm = a / gcd * b;

        printf("%d %d\n",gcd ,lcm);
    }
    return 0;
}


int calc_gcd (a, b){

    int x, y, z;

    while(1){
            x = a;
            y = b;
            z = x % y;

            if(z != 0){
                a = y;
                b = z;
            }else if(z == 0){
                return y;
            }
    }

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    string s;
    cin >> s;

    string ans = s;
    if(s == "zyxwvutsrqponmlkjihgfedcba") ans = "-1";
    else if(s.size() != 26){
        vector<bool> alf(26, true);
        for(auto i : s){
            alf[i-'a'] = false;
        }
        REP(i, 26){
            if(alf[i]){
                ans.insert(ans.end(), 'a'+i);
                break;
            }
        }
    }else{
        int idx = -1;
        REP(i, 25){
            if(s[i] < s[i+1]) idx = i;
        }
        vector<bool> alf(26, false);
        FOR(i, idx+1, 26){
            alf[s[i]-'a'] = true;
        }
        REP(i, 26){
            if(alf[i] && s[idx] < 'a'+i){
                ans[idx] = 'a'+i;
                ans = ans.substr(0, idx+1);
                break;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;


struct uf{
  static const int MAXN=200005;
  int par[MAXN];
  int size[MAXN];

  int cnt;
  lint sum[MAXN];
  void init(int n){
    memset(par,-1,sizeof(par));
    REP(i,n) size[i]=1;
    CLR(sum);
    cnt=n;
  }
  pair<int,lint> doit(int a){
    if(par[a]==-1) return {a,sum[a]};
    pair<int,lint> p=doit(par[a]);
    sum[a]+=p.sc;
    par[a]=p.fr;
    return {par[a],sum[a]};
  }
  void shrink(int a){
    doit(a);
  }
  int root(int a){
    shrink(a);
    if(par[a]==-1) return a;
    return par[a];
  }
  void unite(int a,int b,int w){
    a=root(a);b=root(b);
    if(a==b) return;
    if(size[a]<size[b]) swap(a,b);

    int A=size[a],B=size[b];

    par[a]=par[b]=cnt;
    sum[b]+=A*(lint)w;
    sum[a]+=B*(lint)w;
    size[cnt]=size[a]+size[b];
    ++cnt;
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }

  lint take(int a){
    shrink(a);
    return sum[a];
  }
};

uf u;

int n;
pair<int,pi> es[100005];
int main(){
  cin>>n;
  REP(i,n-1){
    int a,b,c;scanf("%d%d%d",&a,&b,&c);--a;--b;
    es[i]={c,{a,b}};
  }
  sort(es,es+n-1);

  u.init(n);
  for(int i=n-2;i>=0;--i){
    u.unite(es[i].sc.fr,es[i].sc.sc,es[i].fr);
  }
  REP(i,n){
    printf("%lld\n",u.take(i));
  }
  return 0;
}





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

int main()
{
    ll n, m, k;
    cin >> n >> m;
    n++;
    rep(i, n)
    {
        rep(j, n - i)
        {
            k = n - i - j-1;
            if (m == i * 10000 + j * 5000 + k * 1000)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, tree[400005], sz;
void update(int p, int val) {
	for (; p <= sz; p += (p&-p))
		tree[p] += val;
}
int sum(int p) {
	int ret = 0;
	for (; p; p -= (p&-p))
		ret += tree[p];
	return ret;
}
int a[100005], b[100005], c[100005];
vector<int> val;
void in(int arr[]) {
	for (int i = 1; i <= n; i++) {
		scanf("%d", &arr[i]);
		val.push_back(arr[i]);
	}
}
int cnt[100005];
int main() {
	scanf("%d", &n); in(a); in(b); in(c);
	for (int i = 1; i <= n; i++)val.push_back(b[i] - 1);

	sort(val.begin(), val.end());
	val.erase(unique(val.begin(), val.end()), val.end());
	sz = (int)val.size() + 1;

	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(val.begin(), val.end(), a[i]) - val.begin() + 1;
		update(a[i], 1);
	}
	for (int i = 1; i <= n; i++) {
		int id = lower_bound(val.begin(), val.end(), b[i] - 1) - val.begin() + 1;
		cnt[i] = sum(id);
	}
	for (int i = 1; i <= n; i++) {
		update(a[i], -1);
		c[i] = lower_bound(val.begin(), val.end(), c[i]) - val.begin() + 1;
		update(c[i], 1);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		int id = lower_bound(val.begin(), val.end(), b[i] ) - val.begin() + 1;
		int num = n - sum(id);
		ans += (ll)cnt[i] * num;
	}
	cout << ans;
}

Measured memory_bytes: 5104
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
string s1,s2;
signed main()
{
	cin>>s1>>s2;int l1(s1.length()),l2(s2.length());
	sort(s1.begin(),s1.end()),sort(s2.begin(),s2.end()),l1=(l1>l2?l1:l2);
	for(register int i(0);i<l1;i++)
		if(s1[i]-s2[l2-i-1])
			return puts(s1[i]<s2[l2-i-1]?"Yes":"No"),0;
	return puts("No"),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long 
#include <set>
#include <map>


#define x first
#define y second
#define all(p) p.begin(),p.end()
#define pb push_back
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif 
 
 
 



int n,q;


signed main() {	
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);	
	
	cin >> n >> q;
	vector<pair<int, pair<int,int>>> v(n);
	
	for(int i =0 ; i < n ; i++){
		cin >> v[i].y.x >> v[i].y.y >> v[i].x;
	}
	 
	set<int> s;
	
	vector<int> ans(q, -1);
	
	map<int,int> m;
	
	
	for(int i =0 ; i < q; i++){
		int temp;
		cin >> temp;
		s.insert(temp);
		m[temp] = i;
	}
	 
	 sort(all(v));
	 
	 
	 for(int i =0 ; i < n;i++){
		 int left = v[i].y.x - v[i].x;
		 int right = v[i].y.y - 1 - v[i].x;
		 
		 //debug(left , right , v[i].x);
		 
		 while(true){
			 auto it = s.lower_bound(left);
			 
			 if(it == s.end()){
				 break;
			 }
			 
			 int val = *it;
			 if(val > right){
				break;
			 }
			s.erase(val);
			int pos = m[val];
			ans[pos] = v[i].x;
			 
		 }
	 }
	
	for(int i =0; i < q; i++){
		cout<<ans[i]<<"\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 31424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    if(s == "keyence"){
        cout << "YES" << endl;
        return 0;
    }
    for(int left = 0; left < s.size(); left++){
        for(int right = left; right < s.size(); right++){
            string t;
            REP(i,s.size()){
                if(left <= i  && i <= right){
                    continue;
                }
                t += s[i];
            }
            if(t == "keyence"){
                    cout << "YES" << endl;
                    return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Thursday, April 30, 2020
3:50 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	map<pi,int> mapi;
	for(int i = 1; i <= n; i++){
		string curr = to_string(i);
		int len = curr.size();
		int first = curr[0] - '0';
		int last = curr[len - 1] - '0';
		if(!first || !last) continue;
		mapi[{first,last}]++;
	}


	int ans = 0;
	for(int i = 1; i <= 9; i++){
		for(int j = i; j <= 9; j++){
			if(i == j) ans += mapi[{i,j}] * mapi[{i,j}];
			else{
				ans += (mapi[{i,j}] * mapi[{j,i}]) * 2;
			}
 		}
	}

	

	cout << ans << endl;


	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

int arr[107];
int main(){
	Lancer();
	ll n, dis = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	for (int i = 0; i < n - 1; i++)
		dis += (arr[i + 1] - arr[i]);
	cout << dis;
	cout << endl;
	return 0;
}


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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)


// #define printf(a,...) if(0){}
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);

int main () {
  ios::sync_with_stdio(0); cin.tie(0);
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    // ll n;
    // cin >> n;
    // vector<ll> A(n);
    // for (auto& x : A) cin >> x;
    ll x,y;
    cin >> x >> y;
    bool found = false;
    for (int n_crane = 0; n_crane <= x; ++n_crane) {
      int n_turtle = x - n_crane;
      int n_legs = n_crane*2 + n_turtle*4;
      if (n_legs == y) {
        found = true;
        break;
      }
    }
    if (found) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
typedef pair<P,P>PP;
int dp[1<<16];
int n,a1,a2;
vector<P>v;
vector<PP>G;
string s[4],t[4],tmp[4];
string ccol="RGB";
int main(){
  memset(dp,-1,sizeof(dp));
  int a[4][4];
  r(i,4)r(j,4)a[i][j]=(i*4+j);
  cin>>n;
  r(i,n){
    cin>>a1>>a2;
    v.push_back(P(a1,a2));
  }
  r(i,4)cin>>s[i],t[i]=s[i];
  dp[0]=0;
  queue<int>q;
  q.push(0);
  r(i,4)r(j,4)r(k,n){
    P m1=P(4,4),m2=P(0,0);
    for(int y=i,c1=0;c1<v[k].first;c1++,y++){
      for(int x=j,c2=0;c2<v[k].second;c2++,x++){
        if(0<=y&&y<4&&0<=x&&x<4){
          m1=min(m1,P(y,x));
          m2=max(m2,P(y,x));
        }
      }
    }
    G.push_back(PP(m1,m2));
  }
  r(i,4)r(j,4)r(k,n){
    P m1=P(4,4),m2=P(0,0);
    for(int y=i,c1=0;c1<v[k].first;c1++,y--){
      for(int x=j,c2=0;c2<v[k].second;c2++,x--){
        if(0<=y&&y<4&&0<=x&&x<4){
          m1=min(m1,P(y,x));
          m2=max(m2,P(y,x));
        }
      }
    }
    G.push_back(PP(m1,m2));
  }
  q.push(0);
  r(i,4)for(int j=3;j>=0;j--)r(k,n){
    P m1=P(4,4),m2=P(0,0);
    for(int y=i,c1=0;c1<v[k].first;c1++,y++){
      for(int x=j,c2=0;c2<v[k].second;c2++,x--){
        if(0<=y&&y<4&&0<=x&&x<4){
          m1=min(m1,P(y,x));
          m2=max(m2,P(y,x));
        }
      }
    }
    G.push_back(PP(m1,m2));
  }
  for(int i=3;i>=0;i--)r(j,4)r(k,n){
    P m1=P(4,4),m2=P(0,0);
    for(int y=i,c1=0;c1<v[k].first;c1++,y--){
      for(int x=j,c2=0;c2<v[k].second;c2++,x++){
        if(0<=y&&y<4&&0<=x&&x<4){
          m1=min(m1,P(y,x));
          m2=max(m2,P(y,x));
        }
      }
    }
    G.push_back(PP(m1,m2));
  }
  sort(G.begin(),G.end());int rs=0;
  G.erase(unique(G.begin(),G.end()),G.end());
  while(!q.empty()){
    int p=q.front();q.pop();
    int xx=p;//if(p.second==15)return 0;
    if(xx==(1<<16)-1){
      cout<<dp[p]<<endl;
      return 0;
    }
    int xp=0;
    r(i,4)r(j,4){
      if((xx>>(i*4+j))&1)xp|=(1<<a[i][j]);
      else t[i][j]='W';
    }
    r(k,G.size()){
      int sy=G[k].first.first;
      int sx=G[k].first.second;
      int gy=G[k].second.first;
      int gx=G[k].second.second;
      for(int col=0;col<3;col++){
        int tp=xp;
        for(int i=sy;i<=gy;i++){
          for(int j=sx;j<=gx;j++){
            if(ccol[col]==s[i][j])tp|=(1<<a[i][j]);
            else if((tp>>a[i][j])&1)tp-=(1<<a[i][j]);
          }
        }
        if(dp[tp]==-1){rs++;
          dp[tp]=dp[xx]+1;
          q.push(tp);
        }
      }
    }
  }
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#define M_PI 3.14159265358979323846
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  if(s == t.substr(0,t.size()-1)){
    cout << "Yes";
  }else{
    cout << "No";
  }

}

Measured memory_bytes: 3096
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  inputs <- takeWhile (/= "-") . lines <$> getContents
  putStr $ unlines $ sovle inputs
  where
    sovle []               = []
    sovle (cards:num:opts) = [foldl shuffle cards (map read (take (read num) opts))] ++ sovle (drop (read num) opts)
    shuffle card pos = (drop pos card) ++ (take pos card)



Measured memory_bytes: 4228
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def main():
    N = int(input())
    T = []
    for _ in range(N):
        T.append(int(input()))

    ans = 1
    for t in T:
        ans = lcm(ans, t)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
import java.util.*;
public class Main{

	public static void main(String[]agrs){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;
			Xist a = new Xist(n);
			for(int i = 0; i < m; i++) {
				String in = sc.next();
				if(in.equals("A")) a.A();
				if(in.equals("B")) a.B();
				if(in.equals("C")) a.C();
				if(in.equals("D")) a.D();
			}
			a.show();
		}
	}
	
	static class Xist {
		int[] list;
		Xist(int a) {
			list = new int[a];
		}
		
		void A() {
			for(int i = 0; i < list.length; i++) {
				if(list[i] == 0) {
					list[i] = 1;
					break;
				}
			}
		}
		void B() {
			for(int i = list.length-1; i >= 0; i--) {
				if(i+1 < list.length && i - 1 >= 0 && list[i+1] != 1 && list[i-1] != 1 && list[i] == 0) {
					list[i] = 2;
					return;
				}
				if(i+1 >= list.length && i - 1 >= 0 && list[i-1] != 1 && list[i] == 0) {
					list[i] = 2;
					return;
				}
				if(i+1 < list.length && i - 1 < 0 && list[i+1] != 1 && list[i] == 0) {
					list[i] = 2;
					return;
				}
			}
			for(int i = 0; i < list.length; i++) {
				if(list[i] == 0) {
					list[i] = 2;
					return;
				}
			}
		}
		void C() {
			for(int i = 0; i < list.length; i++) {
				if(list[i] != 0 && i+1 < list.length && list[i+1] == 0) {
					list[i+1] = 3;
					return ;
				}
				if(list[i] != 0 && i-1 >= 0 && list[i-1] == 0) {
					list[i-1] = 3;
					return ;
				}
			}
			
			if(list.length % 2 == 0) {
				list[((list.length/2)+1) -1] = 3;
				return;
			}
			if(list.length % 2 == 1) {
				list[((list.length+1)/2) -1] = 3;
				return;
			}
		}
		void D() {
			int[] d = new int[list.length];
			Arrays.fill(d, 2 << 25);
			for(int i = 0; i < list.length; i++) {
				if(list[i] != 0) {
					d[i] = 0;
					for(int j = i+1; j < list.length; j++) {
						if(d[j] <= Math.abs(i - j)) break;
						d[j] = Math.abs(i - j);
					}
					for(int j = i-1; j >= 0; j--) {
						if(d[j] <= Math.abs(i - j)) break;
						d[j] = Math.abs(i - j);
					}
				}
			}
			
			if(d[0] == 2 << 25) {
				list[0] = 4;
				return;
			}
			int max = 0;
			int sel = 0;
			for(int i = 0; i < list.length; i++) {
				if(max < d[i]) {
					max = d[i];
					sel = i;
				}
			}
			list[sel] = 4;
			
		}
		void show() {
			for(int i = 0; i < list.length; i++) {
				if(list[i] == 0) { 
					System.out.print("#");
				}
				if(list[i] == 1) {
					System.out.print("A");
				}
				if(list[i] == 2) {
					System.out.print("B");
				}
				if(list[i] == 3) {
					System.out.print("C");
				}
				if(list[i] == 4) {
					System.out.print("D");
				}
			}
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 24324
#  --*-coding:utf-8-*--

import heapq

INF = float('inf')

def dijkstra(graph, st):
    n  = len(graph)
    ds = [INF]*n
    ds[st] = 0
    prevs = [None]*n
    
    qs = [(0, st)]

    while len(qs) > 0:
        d, nodeId = heapq.heappop(qs)
        
        if d > ds[nodeId]:
            continue
        
        for destId, length in graph[nodeId]:
            d2 = d + length
            if ds[destId] > d2:
                ds[destId] = d2
                prevs[destId] = nodeId
                heapq.heappush(qs, (d2, destId))
                
    return (ds, prevs)


N, M = map(int, input().split())
G = [[] for _ in range(N*3)]

for _ in range(M):
    u, v = map(int, input().split())
    
    for i in range(3):
        G[u*3 - 3 + i].append((v*3-3 + (i+1)%3, 1))


S, T = map(int, input().split())
ds, prevs = dijkstra(G, S*3-3)

ans = ds[T*3-3]
print(ans//3 if ans != INF else -1)


Measured memory_bytes: 81416
function main(input){
  input = input.split("\n");
  const n = parseInt(input[0]);
  const p = input[1].split(" ").map(x => parseInt(x))
  var cnt = 0;
//  console.log(p);
//  console.log(n);

  for (var i = 0; i < p.length; i++) {
    if(i != p[i]-1){
      cnt++;
    }
 //   console.log(cnt);
  }

  if(cnt==0){
    cnt =2;
  }

console.log(cnt==2 ? 'YES' : 'NO');
  

}
  
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

const int ms = 6;
int arr[ms];
char symb[ms];

int sum()
{
    int answer = arr[1];

    for(int i = 2; i <= 4; ++i)
    {
        if(symb[i] == '+')
            answer += arr[i];
        else
            answer -= arr[i];
    }
    return answer;
}

void f(int pos)
{
    if(pos == 4)
    {
        if(sum() == 7)
        {
            cout << arr[1] ;
            for(int i = 2; i <= 4; ++i)
            {
                cout << symb[i] << arr[i];
            }
            cout << "=7\n";
            exit(0);
        }
        else
            return;
    }

    symb[pos + 1] = '+';
    f(pos + 1);
    symb[pos + 1] = '-';
    f(pos + 1);
}


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

    for(int i = 1; i <= 4; ++i)
    {
        arr[i] = n[i - 1] - '0';
    }

    f(1);




}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	string s;
	get(s);
	int end = s.size() -1;
	int ans = 0;
	for(int i=0;i<=end;){
		char c = s.at(i);
		if(c=='x'){
			if(s.at(end)=='x')end--;
			else ans++;
			i++;
		}
		else{
			char d = s.at(end);
			if(d==c){
				end--;
				i++;
			}
			else if(d =='x'){
				ans++;
				end--;
			}
			else{
				cout << "-1"<<endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o D.exe D.cpp 
Execute: ./D
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, a[200000]; 
	bool dp[1000001] = {false}; 
	int a_max = 1000000; 
	int result = 0; 
	int dummy; 
	
	// Input
	cin >> n; 
	for(int i = 0; i < n; i++) {
		cin >> a[i]; 
	}
	
	// Sort array
	sort(a, a+n); 
	
	// Edge cases related to 1
	if(n == 1 && a[0] == 1) {
		cout << 1 << endl; 
		return 0; 
	}
	if(n > 1 && a[0] == 1 && a[1] == 1) {
		cout << 0 << endl; 
		return 0; 
	}
	if(n > 1 && a[0] == 1 && a[1] != 1) {
		cout << 1 << endl; 
		return 0; 
	}
	
	// Sieve for elements in list 
	for(int i = 0; i < n; i++) {
		for(int dummy = a[i]*2; dummy <= a_max; dummy+=a[i]) {
			if(!dp[dummy])
				dp[dummy] = true;
		}
		if(i > 0) 
			if(a[i] == a[i-1])
				dp[a[i]] = true; 
		if(i < n-1)
			if(a[i] == a[i+1])
				dp[a[i]] = true; 
	}
	
	// Search through list to see if elements are safe
	for(int i = 0; i < n; i++) {
		// cout << "testing: " << a[i] << " " << dp[a[i]] << endl; 
		if(!dp[a[i]]) {
			result++; 
		} 
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 5268
# python3

def tap_easy_detector(tap_list):
	kisuu={"R", "U", "D"}
	gusu={"L", "U", "D"}

	tap_gusu_set= set(tap_list[0::2])
	tap_kisuu_set= set(tap_list[1::2])

	if tap_kisuu_set <= gusu and tap_gusu_set<= kisuu:
		return "Yes"
	else:
		return "No"

if __name__ == '__main__':
    Sequence = input()
    input_list = list(Sequence)
    print(tap_easy_detector(input_list))

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a: Int = sc.nextInt()
    val b: Int = sc.nextInt()
    val c: Int = sc.nextInt()
    val d: Int = sc.nextInt()
    if (a * b >= c * d) {
        print(a * b)
    } else if (a * b < c * d) {
        print(c * d)
    }
}

Measured memory_bytes: 29476
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
#define MAXM 200010
#define INF 1000000000
int Adj[MAXN],V[MAXM],nxt[MAXM],c;
void AddEdge(int u,int v)
{
    c++;V[c]=v,nxt[c]=Adj[u];
    Adj[u]=c;
}
int L[MAXN],R[MAXN],root,odd[MAXN];
void dfs1(int u,int p)
{
    for(int i=Adj[u];i;i=nxt[i])
    {
        int v=V[i];
        if(v==p) continue;
        dfs1(v,u);
        R[u]=min(R[v]+1,R[u]);
        L[u]=max(L[v]-1,L[u]);
        if(odd[v]!=-1)
        {
            if(odd[u]==-1) odd[u]=!odd[v];
            else if(odd[v]==odd[u])
            {
                printf("No\n");
                exit(0);
            }
        }
    }
}
void dfs2(int u,int p)
{
    if(p)
    {
        R[u]=min(R[u],R[p]+1);
        L[u]=max(L[u],L[p]-1);
        if(odd[u]==-1) odd[u]=!odd[p];
    }
    if(L[u]>R[u]||(L[u]==R[u]&&odd[u]!=(L[u]&1)))
    {
        printf("No\n");
        exit(0);
    }
    for(int i=Adj[u];i;i=nxt[i])
        if(V[i]!=p)
        {
            dfs2(V[i],u);
        }
}
int ans[MAXN];
void GetAns(int u,int p)
{
    if(!p) ans[u]=L[u];
    else
    {
        ans[u]=ans[p]-1;
        if(ans[u]<L[u]) ans[u]+=2;
    }
    for(int i=Adj[u];i;i=nxt[i])
        if(V[i]!=p)
            GetAns(V[i],u);
}
int main()
{
    int n,m,u,v;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&u,&v);
        AddEdge(u,v);
        AddEdge(v,u);
    }
    for(int i=1;i<=n;i++)
        L[i]=-INF,R[i]=INF,odd[i]=-1;
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&u,&v);
        root=u;
        odd[u]=(v&1);
        L[u]=R[u]=v;
    }
    dfs1(root,0);
    dfs2(root,0);
    GetAns(root,0);
    printf("Yes\n");
    for(int i=1;i<=n;i++)
        printf("%d\n",ans[i]);
    return 0;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i <= N-3; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b) swap(a,b);
    for(int i=0;i<b;i++){
        cout << a;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 16 - 11 - 19  |
// ABC #145      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

ll fact[1000007];

void pre(){
	fact[0] = 1;
	for(int i = 1;i <= 1000007;i++){
		fact[i] = (fact[i - 1] * i)%mod;
	}
}

ll mpower(ll a, ll b){
	ll res = 1;
	while(b){
		if(b&1)
			res *= a,res %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return res;
}

ll comb(int a,int b){
	ll deno = (fact[a] * fact[b - a])%mod;
	deno = mpower(deno,mod - 2);
	deno = (fact[b] * deno)%mod;
	return deno;
}

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	pre();
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int x,y;
		cin >> x >> y;
		int on = x,tw = 0;
		int cur = 2 * x;
		if(cur == y){
			cout << "1";
			return 0;
		}
		for(int i = x;i > 0;i -= 2){
			cur -= 3;
			on -= 2;
			tw++;
			if(cur == y)
				break;
		}
		if(cur == y){
			int tot = on + tw;
			cout << comb(tw,tot) << "\n";
		}
		else{
			cout << "0";
		}
	}
	return 0;
}

Measured memory_bytes: 8064
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
edge=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int1,input().split())
    edge[a].append(b)
    edge[b].append(a)
stack=[0]
for _ in range(2):
    d=[INF]*N
    d[stack[0]]=0
    MAX=(0,-1)
    while stack:
        v=stack.pop()
        for nv in edge[v]:
            if d[nv]==INF:
                d[nv]=d[v]+1
                MAX=max(MAX,(d[nv],nv))
                stack.append(nv)
    stack.append(MAX[1])
if MAX[0]%3==1:
    print('Second')
else:
    print('First')

Measured memory_bytes: 96456
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

ans = []
for i in range(len(A)):
    for j in range(len(B)):
        if (i+1) * (j+1) > K:
            continue
        for k in range(len(C)):
            if (i + 1) *(j + 1)*(k + 1) > K:
                continue
            ans.append(A[i]+B[j]+C[k])

for a in sorted(ans,reverse=True)[:K]:
    print(a)

Measured memory_bytes: 52060
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y)) return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1) return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

set<int> prime_num_factor(int n) {
	if (n < 2) return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0) break;
		}
	}
	return prime;
}
vector<int> makeDivisors(int n) {
	vector<int> re;
	REP(i, 1, sqrt(n) + 1) {
		if (n % i == 0) {
			re.push_back(i);
			if (i != n / i) re.push_back(n / i);
		}
	}
	return re;
}
int modPow(int a, int n, int mod) {
	int ret = 1;
	while (n) {
		if (n & 1) ret = ret * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ret;
}
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<P> p(n);
	rep(i,n)cin>>p[i].first>>p[i].second;
	sort(p.begin(),p.end());
	double sum=0;
	double cnt=0;
	do{
	    double memo=0;
	    REP(i,1,n){
	        memo+=sqrt((p[i-1].first-p[i].first)*(p[i-1].first-p[i].first)+(p[i-1].second-p[i].second)*(p[i-1].second-p[i].second));
	    }
	    sum+=memo;
	    cnt++;
	}while(next_permutation(p.begin(),p.end()));
	printf("%.12lf\n",sum/cnt);
}


Measured memory_bytes: 256