akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#include <fstream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int V,E;
vector<PA> G[100000];
int D[100000];
bool visited[100000];
bool bfs(int S){
  queue<PA> que;
  D[S]=0;
  visited[S]=true;
  que.push(MA(0,S));
  while(!que.empty()){
    PA P=que.front();que.pop();
    int v=P.SE;
    FOR(i,0,(int)G[v].size()){
      PA E=G[v][i];
      if(visited[E.FI]&&D[E.FI]!=D[v]+E.SE){
        return false;
      }
      if(!visited[E.FI]){
        visited[E.FI]=true;
        D[E.FI]=D[v]+E.SE;
        que.push(MA(D[E.FI],E.FI));
      }
    }
  }
  return true;
}
int main(){
  cin>>V>>E;
  FOR(i,0,E){
    int L,R,D;
    cin>>L>>R>>D;
    L--;R--;
    G[L].PB(MA(R,D));
    G[R].PB(MA(L,-D));
  }
  FOR(i,0,V){
    if(!visited[i]){
      if(!bfs(i)){
        Yes(0);
        return 0;
      }
    }
  }
  Yes(1);
  return 0;
}


Measured memory_bytes: 9716
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] aa = new int[n];
		int[] ff = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		for (int i = 0; i < n; i++)
			ff[i] = sc.nextInt();
		aa = Arrays.stream(aa).boxed().sorted().mapToInt($->$).toArray();
		ff = Arrays.stream(ff).boxed().sorted().mapToInt($->$).toArray();
		long lower = -1, upper = (long) aa[n - 1] * ff[n - 1];
		while (upper - lower > 1) {
			long x = (lower + upper) / 2;
			long sum = 0;
			for (int i = 0; i < n; i++) {
				int a = aa[i], f = ff[n - 1 - i];
				sum += Math.max(a - x / f, 0);
			}
			if (sum <= k)
				upper = x;
			else
				lower = x;
		}
		println(upper);
	}
}


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

int card_value[7];
int card_num[7];
int sum1[1001];
int sum2[1001];
int sum3[1001];

void get_sum(int a, int b, int sum[], int count){
	if(a >= b){
		if(count <= 1000){
			sum[count]++;
		}
		
	}else{
		for(int i = 0; i <= card_num[a]; i++){
			get_sum(a+1, b, sum, count + card_value[a] * i);
		}
	}
}
	

int main(){
	int g;
	int m;
	while(cin >> m){
		if(m == 0) break;
		for(int i = 0;i < m; i++){
			cin >> card_value[i] >> card_num[i];
		}
		for(int i = 0; i < 1001; i++){
			sum1[i] = 0;
			sum2[i] = 0;
			sum3[i] = 0;
		}
		get_sum(0, m / 2, sum1, 0);
		get_sum(m / 2, m, sum2, 0);
		for(int i = 0; i < 1001; i++){
			for(int j = 0; j < 1001 - i; j++){
				sum3[i+j] += sum1[i]*sum2[j];
			}
		}
		cin >> g;
		for(int i = 0; i < g; i++){
			int q;
			cin >> q;
			cout << sum3[q] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class B
{
	public static void Main()	
	{
		int N = GetInt();
		int L = GetInt();
		List<string> S = new List<string>(N);
		for(int i = 0; i < N; i++)
			S.Add(GetString());
		S.Sort();

		StringBuilder ans = new StringBuilder();
		for(int i = 0; i < N; i++)
			ans.Append(S[i]);
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13408
using System;
using System.Collections.Generic;
using System.Linq;
using static Common;

public static class Common
{
    public static void CountAdd<T>(this Dictionary<T, long> dict, T key, long v)
    {
        if (dict.ContainsKey(key))
        {
            dict[key] += v;
        }
        else
        {
            dict[key] = v;
        }
        if (dict[key] == 0)
        {
            dict.Remove(key);
        }
    }

    public static void Increment<T>(this Dictionary<T, long> dict, T key)
    {
        dict.CountAdd(key, 1);
    }

    public static void Decrement<T>(this Dictionary<T, long> dict, T key)
    {
        dict.CountAdd(key, -1);
    }

    public static long Get<T>(this Dictionary<T, long> dict, T key)
    {
        long count = 0;
        dict.TryGetValue(key, out count);
        return count;
    }

    public static List<int> GetDivisors(int n)
    {
        var divisors = new List<int>();
        for (int i = 1; i <= Math.Sqrt(n) + 1; i++)
        {
            if (n % i == 0)
            {
                divisors.Add(i);
                if (i != n / i)
                {
                    divisors.Add(n / i);
                }
            }
        }
        return divisors;
    }
}

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var counter = new Dictionary<int, long>();
        foreach (var a in A)
        {
            counter.Increment(a);
        }

        var count = 0;
        for (int i = 0; i < N; i++)
        {
            var a = A[i];
            counter.Decrement(a);
            if (GetDivisors(a).All(d => !counter.ContainsKey(d)))
            {
                count++;
            }
            counter.Increment(a);
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 68772
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	vll a(3);
	forn(i,3) cin>>a[i];
	ll k; cin>>k;
	while(k)
	{
		if(a[1]>a[0]) break;
		a[1]*=2;
		k--;
	}
	while(k)
	{
		if(a[2]>a[1]) break;
		a[2]*=2;
		k--;
	}
	if( a[0] < a[1] && a[1] < a[2] ) cout<<"Yes";
	else cout<<"No";

	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

void solve() {
    ll m;
    cin >> m;
    if(!m) exit(0);
    vector<ll> t(m);
    REP(i, m) cin >> t[i];
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i], a[i]--;

    vector<ll> x(100, 24);
    REP(i, n) chmin(x[a[i]], b[i]);
    dump(t);
    dump(x);

    vector<vector<ll>> dp(101, vector<ll>(m, INF));
    dp[0][0] = 0;
    REP(i, 100) REP(j, m) {
        if(t[j] <= x[i]) chmin(dp[i+1][(j+1)%m], dp[i][j]);
        chmin(dp[i+1][1%m], dp[i][j]+1);
    }

    ll ret = INF;
    REP(i, m) chmin(ret, dp[100][i]);
    cout << ret << endl;
}

int main(void) {
    while(1) solve();

    return 0;
}


Measured memory_bytes: 3132
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        val X = sc.next().toInt()
        pw.println(if (X in A..A + B) "YES" else "NO")
    }
}


Measured memory_bytes: 31136
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
       
        private IEnumerable<long> Add(long current, int digit, int N)
        {
            yield return current;
            if (digit < N)
            {
                var c = current % 10;
                if (c + 1 <= 9)
                {
                    foreach (var item in this.Add((current * 10) + (c + 1), digit + 1, N))
                    {
                        yield return item;
                    }
                }

                foreach (var item in this.Add((current * 10) + c, digit + 1, N))
                {
                    yield return item;
                }

                if (c - 1 >= 0)
                {
                    foreach (var item in this.Add((current * 10) + (c - 1), digit + 1, N))
                    {
                        yield return item;
                    }
                }
            }
        }

        public void Solve()
        {
            var lunlunHashSet = new SortedSet<long>();
            foreach (var i in Enumerable.Range(1, 9))
            {
                foreach (var item in Add(i, 1, 10))
                {
                    lunlunHashSet.Add(item);
                }
            }

            var K = int.Parse(Console.ReadLine());
            Console.WriteLine(lunlunHashSet.Where((elem, index) => index + 1 == K).FirstOrDefault());
        }
    }
}


Measured memory_bytes: 39236
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;

    vector<int> v(n), c(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(v[i] - c[i] >= 0){
            sum += (v[i] - c[i]);
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<utility>
using namespace std;

typedef pair<int, int> P;

int main(){
    int H, W;
    cin >> H >> W;

    int sx = 0;
    int sy = 0;

    int gx = H - 1;
    int gy = W - 1;

    char c[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
        }
    }

    int INF = 3000;

    int d[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            d[i][j] = INF;
        }
    }

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

    
    queue<P> que;

    que.push(P(sx,sy));
    d[sx][sy] = 0;

    /*for(int i = 0; i < R; i++){
                for(int j = 0; j < C; j++){
                    cout << d[i][j] << " ";
                }
                cout << endl;
            }
            cout << endl;*/

    while(que.size()){
        P p = que.front();
        que.pop();

        if(p.first == gx && p.second == gy){
            break;
        }

        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(nx >= 0 && nx < H && ny >= 0 && ny < W && d[nx][ny] == INF && c[nx][ny] != '#'){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
            /*cout << nx << " " << ny << " " << c[nx][ny] << endl;;
            for(int i = 0; i < R; i++){
                for(int j = 0; j < C; j++){
                    cout << d[i][j] << " ";
                }
                //cout << endl;
            }
            //cout << endl;*/
        }
    }

    if(d[gx][gy] == 3000){
        cout << -1 << endl;
    }else{
        int ans = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(c[i][j] == '.'){
                    ans++;
                }
            }
        }

        ans -= d[gx][gy];
        ans--;

        cout << ans << endl;
    }
}

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

int main(){
    vector<vector<int>> a(3, vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }

    int n;
    cin >> n;

    vector<vector<int>> bingo(3, vector<int>(3));
    for(int k=0; k<n; k++){
        int b;
        cin >> b;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i][j] == b){
                    bingo[i][j] = 1;
                }
            }
        }
    }
    for(int i=0; i<3; i++){
        bool flag = true;
        for(int j=0; j<3; j++){
            if(bingo[i][j] != 1) flag = false;
        }
        if(flag == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for(int j=0; j<3; j++){
        bool flag = true;
        for(int i=0; i<3; i++){
            if(bingo[i][j] != 1) flag = false;
        }
        if(flag == true){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(bingo[0][0] == 1 
    && bingo[1][1] == 1
    && bingo[2][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(bingo[2][0] == 1 
    && bingo[1][1] == 1
    && bingo[0][2] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;
int a[100005];
int main()
{
    ios::sync_with_stdio(false);
    int w,h,n;cin>>w>>h>>n;
    int a,b,c;
    int x1=0,y1=0,x2=w,y2=h;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        if(c==1)
            x1=max(x1,a);
        if(c==2)
            x2=min(x2,a);
        if(c==3)
            y1=max(y1,b);
        if(c==4)
            y2=min(y2,b);
    }
    if(x2>x1&&y2>y1)
        cout<<(x2-x1)*(y2-y1)<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define sf scanf
#define pf printf
using namespace std;
int main()
{
    int ar[11];
    for(int i = 0; i<=9; i++)
    {
        sf("%d", &ar[i]);
    }

    sort (ar, ar+10);
    for(int i = 9; i>=7; i--)
    {
        pf("%d\n", ar[i]);
    }

    return 0;
}

Measured memory_bytes: 3240
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

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

	if(a == b || b == c || a == c){
		if(a == b && b == c) puts("No");
		else puts("Yes");
	}else puts("No");

	return 0;
}


Measured memory_bytes: 256
/* ８クイーン問題 */

#include <stdio.h>


#define TRUE 1
#define FALSE 0
#define NOT_FREE 1
#define FREE 0
#define N 8      /* N x N のチェス盤 */


void putQueen(int);
void printBoard(void);


int x[N][N];
int col[N],row[N], dpos[ N*2-1 ], dneg[ N*2-1 ];
  /* dpos: /向きの対角線についてクイーンからFREEかNOT_FREEか記憶 
     dneg: \向きの対角線についてクイーンからFREEかNOT_FREEか記憶 
     col[i]: i行目の何列目にクイーンが置かれているか記憶 
     row[j]: j列目が他のクイーンから襲撃を受けているか記憶 */


int main()
{
  int i, j, k, r, c;

  /* 初期化パート */
  for( i = 0; i<N; i++ )
    row[i] = col[i] = FREE;
  for( i = 0; i<N*2-1; i++ )
    dpos[i] = dneg[i] = FREE;
  for( i = 0; i<N; i++ )
    {
      for( j = 0; j<N; j++ )
	x[i][j] = FALSE;
    }

  /* k個のクイーンの位置情報を読込み、それらのクイーンから襲撃を受ける行、列、対角線を記録 */
  scanf("%d", &k);
  for( i = 0; i<k; i++ )
    {
      scanf("%d%d", &r, &c);
      x[r][c] = TRUE;
    }

  /* N個のクイーンを配置 */
  putQueen(0);

  return 0;
}


/* N x N のマスから成るチェス盤に他のクイーンから襲撃を受けないようにN個のクイーンを配置する関数 */
void putQueen(int i)
{
  int j;

  /* 配置し終った場合 その盤を表示 */
  if( i == N )
    {
      printBoard();
      return;
    }

  for( j = 0; j<N; j++ )
    {
      /* i行j列目のマスが他のクイーンから襲撃を受けている場合 */
      if( col[j] == NOT_FREE || dpos[ i+j ] == NOT_FREE || dneg[ i-j + N-1 ] == NOT_FREE )
	  continue;

      /* i行j列目にクイーンを配置 */
      row[i] = j;
      col[j] = dpos[ i+j ] = dneg[ i-j + N-1 ] = NOT_FREE;
      /*次の行を試す */
      putQueen( i+1 );

      /* back-trackingのためにi行j列のクイーンを消す */
      row[i] = col[j] = dpos[ i+j ] = dneg[ i-j + N-1 ] = FREE;
    }
}


/* N x N のマスから成るチェス盤を表示 */
void printBoard(void)
{
  int i, j;

  for( i = 0; i<N; i++ )
    {
      for( j = 0; j<N; j++ )
	{
	  if( x[i][j] )
	    {
	      if( row[i] != j )
		return;
	    }
	}
    }

  for( i = 0; i<N; i++ )
    {
      for( j = 0; j<N; j++ )
	printf("%c", row[i] == j ? 'Q' : '.' );
      printf("\n");
    }
}



Measured memory_bytes: 2112
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  string s;
cin>>s;
ll l=sz(s),c=0;
ll i=0;
while(i<l-1)
{
    if(s.at(i)==s.at(i+1))
    {
        c=2;
        break;
    }
    i++;
}
if(c==0)
    cout<<"Good\n";
else
    cout<<"Bad\n";
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 256
N = int(input())
F = [int(input().replace(' ', ''), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

print(max(sum([p[bin(f&i).count('1')] for f, p in zip(F, P)]) for i in range(1, 2**10)))

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int N, M;
	cin >> N >> M;
	int32_t K;
	cin >> K;
	vector<ll> A(N+1), B(M+1);
	int tmp;
	cin >> tmp;
	A.at(1) = tmp;
	for (int i = 2; i <= N; i++) {
		cin >> tmp;
		A.at(i) = A.at(i - 1) + tmp;
	}
	cin >> tmp;
	B.at(1) = tmp;
	for (int i = 2; i <= M; i++) {
		cin >> tmp;
		B.at(i) = B.at(i - 1) + tmp;
	}
	int ans = 0,x=M;
	for (int i = 0; i <= N; i++) {
		if (A.at(i) > K) continue;
		while (A.at(i) + B.at(x) > K) {
			x--;
		}
		ans = max(ans, i + x);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++)
    cin >> A.at(i);
  
  sort(A.begin(), A.end(), std::greater<int>());
  
  int score1 = 0;
  int score2 = 0;
  for(int i = 0; i < N; i+=2) 
  	score1 += A.at(i);
  for(int i = 1; i < N; i+=2) 
  	score2 += A.at(i);
  cout << score1 - score2 << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define writeln printf("\n")
using namespace std;
typedef long long LL;
typedef double DB;
const int MAXN = 20;
const DB eps = 1e-7;
int len;
LL n, m;
int a[1000][1000];
bool val[1000][2];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++)
    {
        bool row = true;
        for (int j = 1; j <= m; j ++)
        {
            char ch;
            cin >> ch;
            if (ch == '#') a[i][j] = 1;
            else if (ch == '.') a[i][j] = 2;
            if (a[i][j] == 1) row = false;
        }
        val[i][0] = row;
//        printf("val[%d][0]=%d\n", i, val[i][0]);
    }
    for (int i = 1; i <= m; i ++)
    {
        bool col = true;
        for (int j = 1; j <= n; j ++) if (a[j][i] == 1) col = false;
        val[i][1] = col;
    }
    for (int i = 1; i <= n; i ++)
    {
        if (val[i][0]) continue;
        for (int j = 1; j <= m; j ++)
        {
            if (val[j][1]) continue;
            if (a[i][j] == 1) printf("#");
            else printf(".");
        }
        printf("\n");
    }
}
/*
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
 
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator
 
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 

int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    int sum=0;
    sum+=arr[0];
    for(int i=1;i<n;i++)
    {
        if(i&1)
            sum-=arr[i];
        else
            sum+=arr[i];
    }

    int *ans=new int[n];
    ans[0]=sum/2;
    for(int i=0;i<n-1;i++)
        ans[i+1]=arr[i]-ans[i];

    for(int i=0;i<n;i++)
        cout<<2*ans[i]<<" ";
}

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

int main() {
    int n, T;
    int c[110], t[110];
    cin >> n >> T;
    for(int i = 0; i < n; i++) cin >> c[i] >> t[i];

    int ans = 9999;
    for(int i = 0; i < n; i++) {
        if (t[i] <= T) ans = min(ans, c[i]);
    }
    
    if (ans == 9999) cout << "TLE" << endl;
    else cout << ans << endl;
    
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	vector<long long> a(n);
	long long mod=1000000007;
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]++;
	}
	long long res=1;
	vector<long long> ta(n+1);
	ta[0]=3;
	for(int i=0;i<n;i++){
		res=(res*ta[a[i]-1])%mod;
		ta[a[i]]++;
		if(a[i]>0) ta[a[i]-1]--;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long sx,sy,tx,ty;
    cin >> sx>>sy>>tx>>ty;

    cout << 'D';
    for(int i=0; i<(tx-sx)+1; i++){
        cout << 'R';
    }
    for(int i=0; i<(ty-sy)+1; i++){
        cout << 'U';
    }
    cout << 'L';

    for(int i=0; i<(tx-sx); i++){
        cout << 'L';
    }
    for(int i=0; i<(ty-sy); i++){
        cout << 'D';
    }


    cout << 'L';
    for(int i=0; i<(ty-sy)+1; i++){
        cout << 'U';
    }
    for(int i=0; i<(tx-sx)+1; i++){
        cout << 'R';
    }
    cout << 'D';

    for(int i=0; i<(ty-sy); i++){
        cout << 'D';
    }
    for(int i=0; i<(tx-sx); i++){
        cout << 'L';
    }

    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;



int main(){
    int N;
    cin >> N;
    vector<LL> A;
    for(int i=0;i<N;i++){
        LL a;
        cin >> a;
        A.pb(a-(i+1));
    }
    sort(All(A));
    LL ans=0;
    for(int i=0;i<N;i++) ans+=abs(A[i]-A[N/2]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
def main():
  A, B, Q = list(map(int, input().split()))
  D = []
  q = []
  for i in range(A):
    D.append([int(input()), 1])
  for i in range(B):
    D.append([int(input()), 2])
  for i in range(Q):
    t = int(input())
    D.append([t, 0, i])
    q.append(t)
  
  D.sort()

  x  = [[0, 0, 0, 0] for i in range(Q)] 
  a = 0
  b = 0
  for i in D:
    if i[1] == 1:
      a = i[0]
    elif i[1] == 2:
      b = i[0]
    else:
      x[i[2]][0] = a
      x[i[2]][2] = b
  a = 0
  b = 0
  for i in D[::-1]:
    if i[1] == 1:
      a = i[0]
    elif i[1] == 2:
      b = i[0]
    else:
      x[i[2]][1] = a
      x[i[2]][3] = b
  
  for i in range(Q):
    mi = 1e11
    for j in range(2):
      if x[i][j] == 0:
        continue
      t = abs(q[i] - x[i][j])
      for k in range(2, 4):
        if x[i][k] == 0:
          continue
        tt = t + abs(x[i][j] - x[i][k])
        if tt < mi:
          mi = tt
    for j in range(2, 4):
      if x[i][j] == 0:
        continue
      t = abs(q[i] - x[i][j])
      for k in range(2):
        if x[i][k] == 0:
          continue
        tt = t + abs(x[i][j] - x[i][k])
        if tt < mi:
          mi = tt
    print(mi)
      
main()

Measured memory_bytes: 125068
#include<stdio.h>
#include<map>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
typedef pair<string, int> P;
typedef pair<P, int> Q;
 
Q q[100];
 
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        string s;
        int p;
        cin >> s >> p;
        q[i] =Q(P(s, -p), i);
    }
    sort(q, q + n);
    for(int i = 0; i < n; i++) printf("%d\n", q[i].second + 1);
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define in(x, data) (data).find(x) != (data).end()

typedef long long ll;

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

    int D, G; cin >> D >> G;
    int p[11], c[11]; REP(i,1,D+1) cin >> p[i] >> c[i];

    int ans = INT_MAX;
    REP(k,1,pow(2,D)) {
        int c_ans = 0, score = 0;
        bool closed[11] = {false};
        REP(i,1,D+1) {
            bool ok = false;
            if((k>>(i-1))&1) {
                rep(j,p[i]) {
                    score += 100*i;
                    c_ans++;
                    if(j == p[i]-1) score += c[i];
                    if(score >= G) { ok = true; break;}
                }
                closed[i] = true;
            }
            if(ok) break;
        }
        if(score >= G) {
            ans = min(ans, c_ans); continue;
        }

        RREP(i,D,0) {
            if(!closed[i]) {
                rep(j,p[i]) {
                    score += 100*i;
                    c_ans++;
                    if(j == p[i]-1) score += c[i];
                    if(score >= G) break;
                }
                break;
            }
        }
        if(score >= G) ans = min(ans, c_ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
N, K = gets.split.map(&:to_i)
if K == 0
    puts N**2
    exit
end

ans = 0
((K+1)..N).each do |b|
    set = N / b
    ans += set * (b - K)
    rem = N % b
    ans += rem - K + 1 if rem >= K
end

puts ans

Measured memory_bytes: 3836
s = input()
t = input()
f = ""
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = t[i]
    f += d[s[i]]
if f == t and len(d.values()) == len(set(d.values())):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3692
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  ll x, y;
  ll count = 0;
  cin >> x >> y;
  while (x <= y) {
    count++;
    x = x * 2;
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;


int main()
{
  int r, d, x_2k;
  cin >> r >> d >> x_2k;

  int x = x_2k;
  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;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, K;
int H[100];

ll dfs(int l, int r, int h) {
	bool ok = true;
	int mh = H[l];
	FOR(i, l + 1, r) {
		if (H[i - 1] != H[i]) ok = false;
		chmin(mh, H[i]);
	}
	if (ok) {
		return mh - h;
	}
	
	ll res = mh - h;
	FOR(i, l, r) {
		if (H[i] == mh) continue;
		int cr = i;
		while (cr < r && H[cr] > mh) cr++;
		
		res += dfs(i, cr, mh);
		i = cr - 1;
	}
	return res;
}



int main() {
	cin >> N;
	REP(i, N) scanf("%d", H + i);
	cout << dfs(0, N, 0) << endl;
	
	return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 11348
Asum = 0
Bsum = 0
for i in range(int(input())):
    a,b = input().split()
    if a > b:
        Asum += 3
    elif a < b:
        Bsum += 3
    else:
        Asum += 1
        Bsum += 1

print(Asum,Bsum)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

int main()
{
    int n;
    cin>>n;
    double a;
    if(n%2==0)
        a=n/2;
    else
        a=(n+1)/2;
    printf("%f",a/n);
    return 0;
}


Measured memory_bytes: 256
//import java.io.File;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main{
  public static void main(String[] args) throws Exception {
    //Scanner scan = new Scanner(new File("in.txt"));
    Scanner scan = new Scanner(System.in);

    int input1 = scan.nextInt();
    int input2 = scan.nextInt();

    while(!(input1==0&&input2==0)) {
      HashMap<Integer,Integer> map = new HashMap<>();
      for(int members = 0; members < input1; members++) {
        int input3 = scan.nextInt();
        for(int dates = 0; dates < input3; dates++) {
          int input4 = scan.nextInt();
          if(map.containsKey(input4)) {
            int number = map.get(input4);
            map.remove(input4);
            map.put(input4,number+1);
          }else {
            map.put(input4,1);
          }
        }
      }

      int answerDate = -1;
      int count = -1;
      for(Map.Entry entry : map.entrySet()) {
        int dummyKey = (int)entry.getKey();
        int dummyCount = (int)entry.getValue();

        //System.out.println(entry.toString());

        if(dummyCount > count) {
          answerDate = dummyKey;
          count = dummyCount;
        }else if(dummyCount == count) {
          if(answerDate > dummyKey) {
            answerDate = dummyKey;
          }
        }
      }
      //System.out.println(answerDate+":"+count+","+input2);

      if(count < input2) answerDate = 0;

      System.out.println(answerDate);

      input1 = scan.nextInt();
      input2 = scan.nextInt();
    }
  }
}

Measured memory_bytes: 67456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n;
  cin >> n;
  if (n % 1000 == 0)
    cout << 0 << endl;
  else
    cout << (1000 - n % 1000) << endl;
  return 0;
}


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

using namespace std;

int d[1111][1111];
int main() {
	int h, w, m = 0;
	cin >> h >> w;
	string a[1111];
	for (int i = 0; i < h; i++)
		cin >> a[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#')
				continue;
			d[i][j] = 1e9;
			if (i) d[i][j] = min(d[i][j], d[i - 1][j] + 1);
			if (j) d[i][j] = min(d[i][j], d[i][j - 1] + 1);
		}
		for (int j = w; j--;) {
			if (a[i][j] == '#')
				continue;
			if (i) d[i][j] = min(d[i][j], d[i - 1][j] + 1);
			if (j < w - 1) d[i][j] = min(d[i][j], d[i][j + 1] + 1);
		}
	}
	for (int i = h; i--;) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#')
				continue;
			if (i < h - 1) d[i][j] = min(d[i][j], d[i + 1][j] + 1);
			if (j) d[i][j] = min(d[i][j], d[i][j - 1] + 1);
		}
		for (int j = w; j--;) {
			if (a[i][j] == '#')
				continue;
			if (i < h - 1) d[i][j] = min(d[i][j], d[i + 1][j] + 1);
			if (j < w - 1) d[i][j] = min(d[i][j], d[i][j + 1] + 1);
			m = max(m, d[i][j]);
		}
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 5632
#include<stdio.h>
int main(){
  int x[8]={0}, i, j;
  double a, b;

  while ( scanf ( "%lf %lf" ,&a ,&b ) != EOF ){
    if ( a >= 1.1 ){
      x[0]++;
    }

    else if ( 0.6 <= a){
      x[2]++;
    }

    else if ( 0.2 <= a){
      x[4]++;
    }

    else if ( a < 0.2 ){
      x[6]++;
    }

    if ( b >= 1.1 ){
      x[1]++;
    }

    else if ( 0.6 <= b){
      x[3]++;
    }

    else if ( 0.2 <= b){
      x[5]++;
    }

    else if ( b < 0.2 ){
      x[7]++;
    }
  }
  for ( i=0 ; i<=6 ; i=i+2 ){
    printf ( "%d %d\n" ,x[i] ,x[i+1]);
  }

  return 0;
}

Measured memory_bytes: 628
A = []
for i in range(0,3):
    A.extend(list(map(int,input().split())))
N = int(input())
B = []
for j in range(0,N):
    B.append(int(input()))
for b in B:
    if b in A:
        A[A.index(b)] = 0
for i in range(0, 3):
    if A[i] + A[i+3] + A[i+6] == 0:
        print("Yes")
        exit()
    if A[i*3] + A[i*3+1] + A[i*3+2] == 0:
        print("Yes")
        exit()
if A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] ==0:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

for i in range(x, y):
    z = i+1
    if max(X) < z and min(Y) >= z:
        print('No War')
        exit()

print('War')

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

#define ll long long

const int MaxN(100003);

int n, tot;
ll a[MaxN], F[MaxN], Ans[MaxN], Tag[MaxN];

int main()
{
	int n, Q;
	scanf("%d%d", &n, &Q);
	a[++tot] = n;
	for(ll x; Q--; )
	{
		scanf("%lld", &x);
		while(tot && a[tot] >= x) --tot;
		a[++tot] = x;
	}
	F[tot] = 1;
	for(int i = tot; i > 1; i--)
	{
		while(a[i] >= a[1])
		{
			int j = upper_bound(a + 1, a + i, a[i]) - a - 1;
			F[j] += F[i] * (a[i] / a[j]), a[i] %= a[j];
		}
		if(a[i]) Ans[a[i]] += F[i];
	}
	if(a[1]) Ans[a[1]] += F[1];
	for(int i = n; i; i--)
		Ans[i] += Ans[i + 1];
	for(int i = 1; i <= n; i++)
		printf("%lld\n", Ans[i]);
	return 0;
}


Measured memory_bytes: 4096
n,m = map(int,input().split())
H = list(map(int,input().split()))
x = [[0]for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  x[a-1].append(H[b-1])
  x[b-1].append(H[a-1])
count=0
for i in range(n):
  if H[i] > max(x[i]):
    count+=1
print(count)

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;

vector<pair<ll, ll>> pf(ll n){
    vector<pair<ll, ll>> res;
    for (ll i = 2; i*i <= n; i++){
        if (n%i != 0){
            continue;
        }
        else{
            ll ex = 0;
            while (n%i == 0){
                ex++;
                n /= i;
            }
            res.push_back({i, ex});
        }
    }
    if (n != 1){
        res.push_back({n, 1});
    }
    return res;

    //素因数分解
    //入力:ll
    //出力:vector<pair<ll, ll>>
    //res[i].first == i番目に小さい素因数
    //res[i].second == res[i].firstの指数
}

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

    ll a,b;
    cin >> a >> b;

    ll g = gcd(a,b);

    vector<pair<ll, ll>> x = pf(g);

    cout << x.size()+1 << endl;


}

Measured memory_bytes: 3560
import java.lang.IllegalArgumentException
import java.util.*

fun main() {
    val scanner = Scanner(System.`in`)
    scanner.use { scan ->
        val n = scan.nextInt()
        val classifier = classifier(n % 10)
        println(classifier)
    }
}

fun classifier(number: Int): String = when (number) {
    2, 4, 5, 7, 9 -> "hon"
    0, 1, 6, 8 -> "pon"
    3 -> "bon"
    else -> throw IllegalArgumentException("out of range[0-9] number: $number")
}

Measured memory_bytes: 36260
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	signed main() {
		int n, ans;
		cin >> n;
		for (int i = 1; i <= 10000000000; i++) {
			if (i > sqrt(n)) {
				ans = i;
				break;
			}
		}
		cout << (ans - 1)*(ans - 1) << endl;
		ll
	}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
# print(l)
x=[]
for i in range(n):
    x.append(l[i])
x.sort()
for i in range(n):
    if(l[i]!=x[n-1]):
     
        print(x[n-1])
    else:

        print(x[n-2])


Measured memory_bytes: 73048
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        if (x % 2 == 0) {
            if ((x % 3) && (x % 5)) {
                cout << "DENIED\n";
                rr;
            }
        }
    }
    cout << "APPROVED\n";
}


Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

using namespace std;

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

int n;
int ainv[200000];

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

  cin >> n;
  REP (i, n) {
    int a;
    cin >> a;
    ainv[--a] = i;
  }

  long long sum = 0;
  set<int> s;
  s.insert(-1);
  s.insert(n);
  REP (i, n) {
    auto l = s.lower_bound(ainv[i]);
    auto r = l;
    --l;
    sum += (long long)(i+1) * (ainv[i] - *l) * (*r - ainv[i]);
    s.insert(ainv[i]);
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 10368
# coding: utf-8
# Your code here!

def counting_sort(A, MAX=10010):
    count = [0] * MAX
    for a in A:
        count[a] += 1
    
    for i in range(1, len(count)):
        count[i] = count[i-1] + count[i]
    
    b = [None]*len(A)
    for i in range(len(A)-1, -1, -1):
        
        ai = A[i]
        ci = count[ai]
        b[ci-1] = ai
        #b[count[A[i]]] = A[i]
        count[ai] -= 1
    
    return b

n = int(input())
a = [int(i) for i in input().split()]

b = counting_sort(a)

print(*b)



Measured memory_bytes: 224152