akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  map<string,ll> ma;
  rep(i,0,n){
    string s;
    cin>>s;
    ma[s]++;
  }
  ll mx = 0;
  map<string,ll>::iterator itr = ma.begin();
  while(itr!=ma.end()){
    string a = (*itr).fi;
    ll b = (*itr).se;
    mx = max(mx,b);
    itr++;
  }
  vector<string> vs;
  map<string,ll>::iterator itr1 = ma.begin();
  while(itr1!=ma.end()){
    string a = (*itr1).fi;
    ll b = (*itr1).se;
    if(b==mx){
      vs.pb(a);
    }
    itr1++;
  }
  sort(all(vs));
  rep(i,0,vs.sz){
    cout << vs[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 26868
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int n;
    vector<int> a, b, c;
    cin >> n;

    REP(i, n){
        int x;
        cin >> x;
        a.pb(x); b.pb(x+1); c.pb(x-1);
    }

    map<int, int> ans;
    REP(i, n){
        ans[a[i]] += 1; ans[b[i]] += 1; ans[c[i]] += 1;
    }
    int maxnum = 0;
    for(auto itr = ans.begin(); itr != ans.end(); ++itr){
        maxnum = max(maxnum, itr->second); 
    }
    cout << maxnum << endl;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i];
    }

    bool ans = true;
    for (int64_t i = 0; i < N; i++) {
        if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
using System;

namespace abc080A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int A = int.Parse(str[1]);
            int B = int.Parse(str[2]);
            Console.WriteLine(Math.Min(N * A, B));
        }
    }
}


Measured memory_bytes: 11092
import sys

while True:
  n = sys.stdin.readline()
  if not n: break
  n = int(n)
  b = bin(n)
  s = str(b)
  is_first = True
  sm=1
  l = len(s)
  while True:
    l-=1
    if s[l] == "1":
      if not is_first: sys.stdout.write(" ")
      sys.stdout.write(str(sm))
      is_first = False
    sm*=2
    if l == 0: break
  print ""

Measured memory_bytes: 6404
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, K;
    cin >> N >> K;
    int sum = 0;
    int x;
    rep(i, N) {
        cin >> x;
        sum += min(K - x, x) * 2;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [[] for i in range(n-1)]
for i in range(m):
  s, t = map(int, input().split())
  a[s-1].append(t-1)
dp = [0]*n
sum_d = [0]*(n-1)
max_d = [0]*(n-1)
b = [0]*n
for i in range(n-2,-1,-1):
  for j in a[i]:
    sum_d[i] += dp[j] + 1
    b[i] += 1
    if max_d[i] < dp[j]+1 and len(a[i]) > 1:
      max_d[i] = dp[j]+1  
  dp[i] = sum_d[i] / b[i]
min_dp = dp[0]
for k in range(n-2):
  if b[k]==1:
    continue
  ddp = [0]*k + [dp[k] - (sum_d[k]-max_d[k])/(b[k]-1)]
  for i in range(k-1,-1,-1):
    ddp[i] = sum([ddp[j] for j in a[i] if j <= k]) / b[i]
  min_dp = min(min_dp,dp[0] - ddp[0])
print(min_dp)

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

namespace ConsoleApp28 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int X = st[0];
            int t = st[1];

            Console.WriteLine(Math.Max(X - t, 0));
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
using namespace std;
int main(){
  int n,m,a[100],b[100][100],f[100],i,j;
  fill(f,f+100,0);


    //Imput

    cin>>n>>m;
  for(i=0;i<m;i++){
    cin>>a[i];
    a[i]--;
  }
  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      cin>>b[i][j];
      b[i][j]--;

    }
  }

  //Reading

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      if(b[i][j]==a[i]){
	f[j]++;
      }else{
	f[a[i]]++;
      }
    }
  }

  //Output

  for(i=0;i<n;i++){
    cout<<f[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

LL k;

int main()
{
	while(~scanf("%lld", &k)) {
		printf("%lld\n", 50LL);
		LL p = k / 50LL; int t = k % 50;
		for(int i = 1; i <= 50 - t; i++) {
			printf("%lld ", 49LL + 51LL * p - k);
		}
		for(int i = 50 - t + 1; i <= 50; i++) printf("%lld\n", 49LL + 51LL * (p + 1LL) - k);
	}
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int x[110000];
signed main() {
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        if (a > 0) { x[a - 1]++; }
        x[a]++;
        x[a + 1]++;
    }
    int ans = 0;
    rep(i, 110000) { chmax(ans, x[i]); }
    cout << ans << endl;
}


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

int main() {
  int n, x, b, y;
  vector<int> l(n);
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  b = 1, y = 0;
  for(int i = 0; i < n; i++){
    y += l[i];
    if(y <= x){
      b++;
    }
    else{
      break;
    }
  }
  cout << b << endl;
}


Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

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

int main() {
    string s, t;
    int a,b;
    int ans = 0;

    cin >> a >> b;

    ((b-1) % (a-1) == 0) ? (ans = (b-1) / (a-1)) : (ans = (b-1) / (a-1) + 1); 

    

    cout << ans << endl;
}



Measured memory_bytes: 256
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = (1 << 10) + (1 << 9);

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < (vw[0].1 as usize) { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1 as usize;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1 as usize;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 612084
#include<stdio.h>
#include<iostream>
using namespace std;
long long a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(a%2==0||b%2==0||c%2==0) printf("0\n");
	else printf("%lld\n",min(min(a*b,a*c),b*c));
	return 0;
}

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

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

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

int main() {
  ll n, m; cin >> n >> m;
  vll a(m), b(m), c(m);
  REP(i, m) cin >> a[i] >> b[i] >> c[i];
  vvll d(n, vll(n, HIGHINF));
  REP(i, n) d[i][i] = 0;
  REP(i, m) {d[a[i]-1][b[i]-1] = c[i]; d[b[i]-1][a[i]-1] = c[i];}
  REP(k, n) REP(i, n) REP(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
  ll ans=m;
  REP(i, m) {
    REP(j, n) if (d[j][a[i]-1] + c[i] == d[j][b[i]-1]) {ans--; break;}
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
    public static final PrintStream err = System.err;

    public static void main(String[] args) {
        int Ai = in.nextInt();
        int Bi = in.nextInt();

        int K2 = Math.abs(Ai) + Math.abs(Bi);

        if (K2 % 2 == 0) {
            out.println(K2 / 2);
        } else {
            out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

class UnionFind {
public:
	vector<int>par;
	void init(int size_) {
		par.resize(size_, -1);
	}
	int root(int pos) {
		if (par[pos] == -1) return pos;
		par[pos] = root(par[pos]);
		return par[pos];
	}
	bool same(int u, int v) {
		if (root(u) == root(v)) return true;
		return false;
	}
	void unite(int u, int v) {
		u = root(u); v = root(v);
		if (u == v) return;
		par[u] = v;
	}
};

long long n, m, a, b, c, dp[200009], ans; vector<tuple<long long, long long, long long>>X;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) dp[i] = (1LL << 40);
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		X.push_back(make_tuple(c, a, b));
		dp[a] = min(dp[a], c + 1);
		dp[b] = min(dp[b], c + 2);
	}
	for (int i = 0; i < n * 2; i++) dp[(i + 1) % n] = min(dp[(i + 1) % n], dp[i % n] + 2);
	for (int i = 0; i < n; i++) X.push_back(make_tuple(dp[i], i, (i + 1) % n));
	sort(X.begin(), X.end());
	UnionFind UF; UF.init(n + 2);
	for (int i = 0; i < X.size(); i++) {
		if (UF.same(get<1>(X[i]), get<2>(X[i])) == false) {
			UF.unite(get<1>(X[i]), get<2>(X[i]));
			ans += get<0>(X[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 17512
#include <bits/stdc++.h>
	 
using namespace std;
	
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,t;
	vector <int> b;

	cin >> n;

	for(int i=0;i<n-1;i++)
	{
		cin >> t;
		b.push_back(t);
	}

	int res = 0;

	if(n==2)
	{
		cout << 2*b[0] << '\n';
	}
	else
	{
		for(int i=0;i<n-2;i++)
		{
			res += min(b[i],b[i+1]);
		}
		res += b[0];
		res += b[n-2];
		cout << res << '\n';
	}
	return 0;	
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  tmp = input[1].split(" ");
  a = new Array(Math.pow(10,5)+1).fill(0);
  for(i=0;i<n;i++){
    var t = parseInt(tmp[i]);
    a[t-1]++;
    a[t]++;
    a[t+1]++;
  }
  var ans = Math.max.apply(null,a);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto B = N.iota.map!(i => tuple(A[i], i)).array;
    B.sort();
    int k = N / 2;

    auto ans = new long[](N);

    foreach (i; 0..N) {
        if (i < k) {
            ans[B[i][1]] = B[k][0];
        } else {
            ans[B[i][1]] = B[k-1][0];
        }
    }

    ans.each!writeln;
}


Measured memory_bytes: 13552
N = int(input())
T = [int(input()) for _ in range(N)]

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))


Measured memory_bytes: 64108
#include <iostream>

using namespace std;

int main(void)
{
  int A,B,K;
  cin >> K >> A >> B;
  bool flag = false;
  int gain = 1;
  while(1)
  {
    if(gain*K > B)break;
    if(gain*K >= A)
    {
      flag = true;
      break;
    }
    gain++;
  }
  if(flag)cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
n = gets.chomp.to_i
 
#nの平方根を求める
rt_n = Math.sqrt(n).to_i
 
ary = []
(1..rt_n).each do |a|
  if n % a == 0
    b =  n / a
    ary << a + b - 2
  end
end
 
puts ary.min

Measured memory_bytes: 1788
#include<stdio.h>

int main(){
	int n[100],k,m,i,j,a[100][11][11],b;
	for(k=0;k<100;k++){
		scanf("%d",&n[k]);
		if(n[k]==0) break;
		for(i=0;i<n[k];i++){
			for(j=0;j<n[k];j++){
				scanf("%d",&a[k][i][j]);
			}
		}
	}
	for(m=0;m<k;m++){
		for(i=0;i<n[m];i++){
			b=0;
			for(j=0;j<n[m];j++){
				b+=a[m][i][j];
			}
			a[m][i][n[m]]=b;
		}
	}
	for(m=0;m<k;m++){
		for(j=0;j<=n[m];j++){
			b=0;
			for(i=0;i<n[m];i++){
				b+=a[m][i][j];
			}
			a[m][n[m]][j]=b;
		}
	}
	for(m=0;m<k;m++){
		for(i=0;i<=n[m];i++){
			for(j=0;j<=n[m];j++){
				printf("%5d",a[m][i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 632
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 100
using namespace std;
int main(){
  int n,w,v[N],cnt[N];
  bool used[N];
  while(1){
    cin>>n>>w;
    if(!n&&!w) break;
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v,v+n);
    for(int i=0;i<N;i++) cnt[i]=0,used[i]=false;
    int m=0;
    for(int i=w-1,l=0;i<300;i+=w,l++){
      int flag=0;
      for(int j=0;j<n;j++){
    if(v[j]<=i&&used[j]==false){
      used[j]=true;
      cnt[l]++;
      if(j==n-1){
        flag=1;
        m=l;
        break;
      }
    }
      }
      if(flag) break;
    }
    int maxv=0;
    for(int i=0;i<=m;i++) maxv=max(maxv,cnt[i]);
    double k=1,ans=0;
    for(int i=0;i<=m;i++){
      ans+=k*cnt[i]/maxv;
      k-=1.0*1/m;
    }
    printf("%.10f\n",ans+0.01);
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <iomanip>
#include <complex>

using namespace std;

complex<double> points[300];

constexpr double epsilon = 1.0e-6;

int count_points(const complex<double> &center,int N){
  int num=0;
  for(int i=0;i<N;++i){
    double dist = abs(points[i]-center);
    if(dist-1.0<=epsilon){
      num++;
    }
  }
  return num;
}

int main(){
  int n;
  while(cin >> n&&n>0){
    for(int i=0;i<n;++i){
      double x,y;
      cin >> x >> y;
      points[i] = complex<double>(x,y);
    }
    
    int maxnum = 1;
    for(int i=0;i<n-1;++i){
      for(int j=i+1;j<n;++j){
        complex<double> v = points[j]-points[i];
        double dist = abs(v);
        int circnum=0;
        complex<double> center[2];
        if(abs(dist-2.0)<=epsilon){
          circnum = 1;
          center[0] = (points[i]+points[j])/2.0;
        }else if(dist-2.0<-epsilon){
          circnum = 2;
          complex<double> w = v/dist;
          w *= complex<double>(0,1);
          w *= sqrt(1.0-dist*dist/4.0);
          center[0] = (points[i]+points[j])/2.0 + w;
          center[1] = (points[i]+points[j])/2.0 - w;
        }
        for(int c=0;c<circnum;++c){
          maxnum = max(maxnum,count_points(center[c],n));
        }
      }
    }
    cout << maxnum << endl;
  }
  return 0;
}

Measured memory_bytes: 3212
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=1;
    ll strr[200005];
    cin>>n;
    vector<int> a(n);
    rep(i,n)   cin >> a[i];
    rep(i,100001) strr[i]=0;
    rep(i,n){
        if(a[i]==0){
            if(strr[0]==0){ 
                sum=sum*3;
            }else if(strr[0]==1){
             sum=sum*2;
            }
        }else{
            sum=sum*(strr[a[i]-1]-strr[a[i]]);
        }
        if(strr[a[i]-1]==0&&a[i]!=0) sum=0;
        if(strr[a[i]]==3) sum=0;
        strr[a[i]]++;
        //cout<<sum<<endl;
        if(sum>1000000007) sum=sum%(long long)1000000007;
    }
    cout<<sum<<endl;


    return 0;
}

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

int main(){
    int W, a, b;
    cin >> W >> a >> b;
    
    if (a < b) cout << max(0, b-(a+W)) << endl;
    else cout << max(0, a-(b+W)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt() * n;
                sum += a[i];
            }

            int avg = sum / n;

            int idx = 0;
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                if (min > Math.abs(a[i] - avg)) {
                    idx = i;
                    min = Math.abs(a[i] - avg);
                }
            }

            out.println(idx);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 H, W, K;
  cin >> H >> W >> K;
  i64 x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;
  vector<string> c(H);
  for (i64 i = 0; i < H; i++)
    cin >> c[i];
  vector<vector<i64>> far(H, vector<i64>(W, 1e9));
  priority_queue<pair<i64, pair<i64, i64>>> que;
  far[x1][y1] = 0;
  que.push({0, {x1, y1}});
  while (que.size())
  {
    pair<i64, pair<i64, i64>> p = que.top();
    i64 f = -p.first, x = p.second.first, y = p.second.second;
    que.pop();
    if (far[x][y] < f)
      continue;
    for (i64 i = 1; i <= K; i++)
      if (x - i < 0 || c[x - i][y] == '@' || far[x - i][y] <= far[x][y])
        break;
      else if (f + 1 < far[x - i][y])
      {
        far[x - i][y] = f + 1;
        que.push({-far[x - i][y], {x - i, y}});
      }
    for (i64 i = 1; i <= K; i++)
      if (H <= x + i || c[x + i][y] == '@' || far[x + i][y] <= far[x][y])
        break;
      else if (f + 1 < far[x + i][y])
      {
        far[x + i][y] = f + 1;
        que.push({-far[x + i][y], {x + i, y}});
      }

    for (i64 i = 1; i <= K; i++)
      if (y - i < 0 || c[x][y - i] == '@' || far[x][y - i] <= far[x][y])
        break;
      else if (f + 1 < far[x][y - i])
      {
        far[x][y - i] = f + 1;
        que.push({-far[x][y - i], {x, y - i}});
      }
    for (i64 i = 1; i <= K; i++)
      if (W <= y + i || c[x][y + i] == '@' || far[x][y + i] <= far[x][y])
        break;
      else if (f + 1 < far[x][y + i])
      {
        far[x][y + i] = f + 1;
        que.push({-far[x][y + i], {x, y + i}});
      }
  }
  if (far[x2][y2] == 1e9)
    cout << -1 << endl;
  else
    cout << far[x2][y2] << endl;
  return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s;
    cin >> s;
    int counter = 0;
    int ans = 0;
    rep(i,3)
    {
        if(s[i]=='R')
        {
            counter++;
        }else
        {
            counter = 0;
        }
        ans = max(ans, counter);
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dp[10000007];

int main(){
  ll x, y;
  cin >> x >> y;
  if(x%y==0){
    print(-1);
  }
  else{
    print(x);
  }
}

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

int main() {
		int N, X;
		int m[1000];
		int counter = 0;
		int sum = 0;
		cin >> N >> X;
		for (int k = 0; k < N; k++) {
			cin >> m[k];
			sum += m[k];
			counter++;
		}
		sort(m, m + N);
		int sa = X - sum;
		counter += (sa / m[0]);
		cout << counter << endl;
		
	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
d = gets.split

n.upto(10*n) do |num|
	check = 0

	num.to_s.each_char do |digit|
		if d.include?(digit) then
			check = 1
			break
		end
	end

	if check == 0 then
		print num
		exit
	end
end


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c = sc.nextInt();
		long sum=0;
		long sum1=0;
		for(int i=1;i<=c;i++) {
			sum+=i;
			if(i%3==0||i%5==0) {
				sum1+=i;
			}
		}
		System.out.println(sum-sum1);


	}

}


Measured memory_bytes: 35604
#include<iostream>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<cstdlib>

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) > abs(b - x)) {
		cout << "B" << endl;
	}
	if (abs(b - x) > abs(a - x)) {
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// {{{ Template for Competitive Programming
// -std=c++14 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

using vint = vector<int>;
using pint = pair<int, int>;

#define int long long
#define FOR(i, a, b)  for (int(i) = (a); (i) < (b); ++(i))
#define CFOR(i, a, b) for (int(i) = (a); (i) <= (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) >= (b); --(i))
#define rep(i, n) FOR((i), 0, (n))
#define crep(i, n) CFOR((i), 0, (n))
#define rrep(i, n) RFOR((i), (n), 0)
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x), 0)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline void debug(T a) { cout << "[ "; for (const auto e : a) { cout << e << ", "; } cout << "]" << endl; }

int ceil(int a, int b) { return (a + (b - 1)) / b; }

const int INF = 1'010'000'000'000'000'017LL;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// }}}

signed main() {
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n + 1), c(n);
	CFOR (i, 1, n) cin >> a[i];
	CFOR (i, 1, n) cin >> b[i];
	CFOR (i, 1, n - 1) cin >> c[i];

	int ans = SUM(b);
	
	CFOR (i, 1, n - 1) {
		if (a[i] == a[i + 1] - 1) {
			ans += c[a[i]];
		}
	}

	cout << ans << endl;
}



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

int main(){
  int n, m, b[100], a[100][100], c[100] = {};
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      c[i] += a[i][j] * b[j];
    }
  }
  for(int i = 0; i < n; i++){
    cout << c[i] << endl;
  }
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String v = scan.next();
        char[] S = v.toCharArray();
        long rr = 0;
        long gg = 0;
        long bb = 0;

        for (int i = 0; i < S.length; i++) {
            if(S[i] == 'R'){
                rr++;
            }else if(S[i] == 'G'){
                gg++;
            }else{
                bb++;
            }
        }

        long cnt = rr*gg*bb;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                int k = i + (i-j);
                if(k < n && S[k] != S[i] && S[i] != S[j] && S[j] != S[k]) cnt--;
            }
        }

        System.out.println(cnt <= 0 ? 0 : cnt);
    }
}


Measured memory_bytes: 36112
#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long N; cin >> N;
    vector<long long> S(N + 1);

    S[0] = 0LL;

    for (long long i = 1; i <= N; ++i) {
        cin >> S[i];
        S[i] += S[i - 1];
    }

    long long ians = (1LL << 60);

    for (long long j = -1LL; j <= 1LL; j += 2LL) {
        vector<long long> S_(S);
        long long ans = 0LL;
        long long add = 0LL;
        long long sign = j;
        for (long long i = 1LL; i <= N; ++i) {
            S_[i] += add;

            if (S_[i] == 0) {
                ans += 1;
                add += -sign;
                S_[i] += -sign;
            }
            else {
                long long sign_i = S_[i] / abs(S_[i]);
                if (sign_i == sign) {
                    ans += abs(-sign_i - S_[i]);
                    add += -sign_i - S_[i];
                    S_[i] = -sign_i;
                }
            }

            sign = -sign;
        }

        ians = min(ans, ians);
    }

    cout << ians << endl;
}


Measured memory_bytes: 1804
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, b, c;
	while(cin >> a >> b >> c) {
		if(a == b and b == c and c == a) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a_img = n.times.map { gets.chomp }
b_img = m.times.map { gets.chomp }

ret = 0.upto(n - m).any? { |i| 0.upto(n - m).any? { |j| a_img[i, m].map { |s| s[j, m] } == b_img } }

if ret == true
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 2044
def solve():
     siki = input().split()
     que = []
     for i in siki:
          if i =="+" or i =="-" or i =="*" or i =="/":
               a = que.pop()
               b = que.pop()
               if i == "+":
                    que.append(a+b)
               if i == "-":
                    que.append(b-a)
               if i == "*":
                    que.append(a*b)
               if i == "/":
                    que.append(b/a)
          else:
               que.append(int(i))
     print(que[-1])
solve()


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ALL(T) (T).begin(), (T).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
ll intmax = (1LL<<32)-1;
const int INF = 1e9 + 5;


class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x < 0) return -x;
	else return x;
}

template <typename T>
void swap(T &a, T &b){
	T temp;
	temp = a;
	a = b;
	b = temp;
}

vector<bool> prime(1000000, true);

void sieve() {
	for(int i=2; i<1000000; i++) {
		if(prime[i] == true) {
			for(int j=i+i; j<1000000; j+=i) {
				prime[j] = false;
			}
		}
	}
}

int main() {
	sieve();
	int x;
	cin >> x;
	for(int i=x; ; i++) {
		if(prime[i] == true) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n,k,q;
    cin >> n >> k >> q;
    int a[n];
    for(int i = 0; i < n; i++){
        a[i] = q;
    }
    for(int i = 0; i < q; i++){
        int b;
        cin >> b;
        a[b-1]--;
    }
    for(int i = 0; i < n; i++){
        if(a[i] >= k){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll a=0, b=0;
  rep(i,s.size()){
    if(s[i]=='0') a++;
    else b++;
  }
  cout<<min(a,b)*2<<endl;
}


Measured memory_bytes: 512
def solve(n, b):
    a = []
    while b:
        m = len(b)
        tj = -1
        for j in range(m, 0, -1):
            if b[j-1] == j:
                tj = j
                break
        if tj == -1:
            return -1
        else:
            a.append(tj)
            b = b[:tj-1] + b[tj:]
    return "\n".join(map(str, a[::-1]))

n = int(input())
b = list(map(int, input().split()))
print(solve(n, b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}


int main()
{

ll test,n,k,i,j,a,b,m,c;
cin>>k>>n;
ll arr[n+5];
rep(i,0,n)
    cin>>arr[i];
vector <ll> d;
rep(i,0,n-1)
    d.pb(arr[i+1]-arr[i]);
d.pb(k-arr[n-1]+arr[0]);
sort(d.begin(),d.end());
ll sum=0;
for(i=0;i<d.size()-1;i++)
    sum+=d[i];
cout<<sum<<endl;

return 0;
}


Measured memory_bytes: 3956
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e17-10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int main(void){
	int n,x,i;cin>>n>>x;
	if(x==1||x==2*n-1){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	int j=3;
	for(i=0;i<2*n-1;i++){
		if(i==n){cout<<2*n-1<<endl;continue;}
		if(i==n-1){cout<<x<<endl;continue;}
		if(i==n-2){cout<<1<<endl;continue;}
		if(i==n-3&&x!=2*n-2){cout<<2*n-2<<endl;continue;}
		if(i==n+1&&x!=2){cout<<2<<endl;continue;}
		if(j==x){j++;}
		cout<<j<<endl;
		j++;
	}
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  ll H,N;
  cin>>H>>N;
  REP(i,N){
    ll a;
    cin>>a;
    H-=a;
  }
  if(H<=0ll) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x,  k;
string s, t;

// <------------- Implement Functions Here ----------> //

queue<ll> q[2000];
ll m[2000][2000] = {};
queue<ll> q1,q2;

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n ;
	ll cnt = 0,day = 0;

	for(ll i=1;i<=n;i++) {
		for(ll j=1;j<n;j++) {
			cin>>x;
			q[i].push(x);
		}
	}

	for(ll i=1;i<=n;i++) q1.push(i);

	while(!q1.empty()) {
		++ day;
		
		while(!q1.empty()) {
			ll x = q1.front();q1.pop();
			ll y = q[x].front();

			m[x][y] = 1;

		
			if(m[x][y] == m[y][x]) {
				q[x].pop();
				q[y].pop();
				
				cnt+=2;

				if(!q[x].empty()) q2.push(x);
				if(!q[y].empty()) q2.push(y);
			}
		}

		while(!q2.empty()) {
			q1.push(q2.front());
			q2.pop();
		}
	}

	if(cnt == n*(n-1))  cout<<day;
	else 				cout<<-1;
	newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 24612
#include<iostream>

using namespace std;
int main()
{
	int n,sum,ans = 0;
	cin >> n >> sum;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=n; j++){
			int tmp = sum - i - j;
			if(tmp >= 0 && tmp <= n)
				ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#print 'input strings >>>> '
str = gets.chomp
str = str.split
freq = Hash.new
mlw = [""],mfw = [""]
=begin
mlw = most longest word
mfw = most frequency word
=end

str.each do |i|
  if mlw.length < i.length
    mlw = i
  end

  if freq.key?(i)
    freq[i] = freq[i] + 1
  else
    freq[i] = 1
  end

end

cnt = 0
freq.each do |w,f|
  if cnt < f
    cnt = f
    mfw = w
  end
end

#puts "inputed grammer >>>  #{str}"

puts "#{mfw} #{mlw}"



Measured memory_bytes: 6852
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;


int a[200010], b[200010];
int n, bs;


int mn[800010], tag[800010];
void build(int p, int l, int r) {
	if(l == r) {
		mn[p] = b[l]; tag[p] = 0;
		return ;
	}
	int mid = (l + r)>>1;
	build(p<<1, l, mid); build(p<<1|1, mid + 1, r);
	mn[p] = min(mn[p<<1], mn[p<<1|1]);
}
inline void pd(int p) {
	tag[p<<1]+= tag[p]; mn[p<<1]+= tag[p];
	tag[p<<1|1]+= tag[p]; mn[p<<1|1]+= tag[p];
	tag[p] = 0;
}
void add(int p, int l, int r, int x, int y) {
	if(x > y) return ;
	if(x <= l && r <= y) {
		++tag[p];
		++mn[p];
		return ;
	}
	int mid = (l + r)>>1;
	pd(p); 
	if(x <= mid) add(p<<1, l, mid, x, y);
	if(mid + 1 <= y) add(p<<1|1, mid + 1, r, x, y);
	mn[p] = min(mn[p<<1], mn[p<<1|1]);
}
int query(int p, int l, int r, int x, int y) {
	if(x <= l && r <= y) return mn[p];
	int mid = (l + r)>>1;
	int s1 = 0x7fffffff, s2 = 0x7fffffff;
	pd(p);
	if(x <= mid) s1 = query(p<<1, l, mid, x, y);
	if(mid + 1 <= y) s2 = query(p<<1|1, mid + 1, r, x, y);
	return min(s1, s2);
}
int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	memcpy(b, a, sizeof(b)); sort(b+1, b+n+1); bs = unique(b+1, b+n+1) - b - 1;
	build(1, 1, bs);
	long long ans = 0;
	for(int i = 1; i <= n; ++i) {
		int p = lower_bound(b+1, b+bs+1, a[i]) - b;
		ans+= query(1, 1, bs, p, bs) - a[i];
		add(1, 1, bs, 1, p - 1);
	}
	cout << ans << endl;
	return 0;
}

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

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

    int count;
    bool is_find =false;
    for(int i=s.size()-1; i>=0; i--){
        if(is_find==true) break;
        count = 0;
        for(int j=i; j>=0; j--){
            if(s[j] == '?' || s[j] == t[t.size()-1-count]) count++;
            else break;
            if(count==t.size()){
                is_find = true;
                for(unsigned int k=0; k<t.size(); k++){
                    s[j+k] = t[k];
                }
                break;
            }
        }
    }

    if(!is_find){
        cout << "UNRESTORABLE" << endl;
    } else {
        for(unsigned int i=0; i<s.size(); i++){
            if(s[i] == '?') s[i] = 'a';
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
string s;
int main(){
	cin>>s;
	if(s.size()<26){
		for(char c='a';c<='z';++c){
			bool ok=1;
			for(int i=0;i<s.size();++i)if(s[i]==c)ok=0;
			if(ok==1){
				s+=c;
				break;
			}
		}
		cout<<s<<endl;
		return 0;
	}
	int k=25;
	while(k&&s[k]<s[k-1])--k;
	if(!k)puts("-1");
	else{
		int I=0;
		for(int i=k;i<=25;++i)if(s[i]>s[k-1]&&(I==0||s[i]<s[I]))I=i;
		swap(s[k-1],s[I]);
		for(int i=0;i<k;++i)cout<<s[i];
		cout<<endl;
	}
    return 0;
}


Measured memory_bytes: 3608