akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools

sys.setrecursionlimit(10**6)

def main():
    N = list(input())
    intN = int(''.join(N))
    lenN = len(N)
    set753 = ['7', '5', '3']
    ans = 0
    for n in range(3, lenN+1):
        tmp = itertools.product(set753, repeat=n)
        product = [x for x in tmp if len(set(x)) == 3]
        for s in product:
            if int(''.join(s)) <= intN:
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()


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

int a[200010];
bool flag[1000010];
vector<int> pr;

int main(){
	int n,i,j;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
		
	sort(a,a+n);
	
	for(i=0;i<n;i++){
		if(i && a[i]==a[i-1] && pr.size() && pr[pr.size()-1]==a[i])
			pr.pop_back();
		if(!flag[a[i]]){
			pr.push_back(a[i]);
			for(j=a[i];j<=1000000;j+=a[i])
				flag[j]=true;
		}
	}
	
	cout<<pr.size();
	return 0;
}

Measured memory_bytes: 5388
#include <stdio.h>

int main(void) {
  int a, b, c, i, N;
  for (i = 0, scanf("%d%d",&N,&a); i < N && scanf("%d",&b); i++) {
    while (b) {
      c = b;
      b = a%b;
      a = c;
    }
  }
  printf("%d",a);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<int > edge[100004];
  int a, b;
  for (int i=0; i<N-1; i++){
    scanf("%d", &a);
    scanf("%d", &b);
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int start;
  for (int i=0; i<N; i++){
    if (edge[i].size()==1){
      start=i;
      break;
    }
  }

  long long ans = K;
  long long mod = 1e9+7;
  std::queue<int > queue;
  std::vector<bool > used(N+4, false);
  queue.push(start);
  used[start]=true;
  bool initial = true;
  while(queue.size()>0){
    int v = queue.front();
    queue.pop();
    int childnum = (initial)?(edge[v].size()):(edge[v].size()-1);
    int multiple = (initial)?(K-1):(K-2);
    for (int i=0; i<childnum; i++){
      ans *= multiple;
      ans %= mod;
      multiple--;
    }
    initial=false;
    for (int vv : edge[v]){
      if (!used[vv]){
	queue.push(vv);
	used[vv] = true;
      }
    }
  };
  std::cout << ans << std::endl;
  return 0;
}
 

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, M;
int p[100010];
int par[100010];

int root(int x) {
  return par[x] == x ? x : par[x] = root(par[x]);
}

void merge(int x, int y) {
  x = root(x); y = root(y);
  if (x == y) return;
  par[y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
    par[i] = i;
  }
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    merge(x, y);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += root(i) == root(p[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        FastScanner in = new FastScanner(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, FastScanner in, PrintWriter out) {
            int ans = in.nextInt();
            if (ans % 2 == 1)
                ans *= 2;
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufLength == -1)
                throw new InputMismatchException();
            if (bufPointer >= bufLength) {
                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,a,b;
	string s;
	cin >> n >>a >>b >>s;
	int ca=0, cb=0;
	rep(i,sz(s)){
		//printf("%d:%d :: ",ca,cb);
		if( ca+cb < a+b  && s[i]=='a') puts("Yes"), ca++;
		else if(ca+cb < a+b  && s[i]=='b' && cb <b) puts("Yes"), cb++;
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
#define M 10000
int N,K;
int dp[101][3][2];
int  t[101];

int main(){
  for(int i=0;i<=100;i++)t[i]=-1;
  for(int i=0;i<=100;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
	dp[i][j][k]=0;
  cin>>N>>K;
  for(int i=0;i<K;i++){
    int a,b;
    cin>>a>>b;
    t[a]=b-1;
  }
  
  for(int i=1;i<=N;i++){
    for(int j=0;j<3;j++){
      if(t[i]!=-1&&t[i]!=j)continue;
      if(i==1){
	dp[i][j][0]=1;
	continue;
      }
      dp[i][j][0]=
	(
	 dp[i-1][(j+1)%3][0]
	 +dp[i-1][(j+2)%3][0]
	 +dp[i-1][(j+1)%3][1]
	 +dp[i-1][(j+2)%3][1]
	 ) % M;
      dp[i][j][1]=dp[i-1][j][0];
	
    }
  }
  int ans=0;
  for(int i=0;i<3;i++)
    for(int j=0;j<2;j++)
      ans=(ans+dp[N][i][j])%M;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main() {
	
	int a,b,c,x;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2712
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

const INF: u32 = std::u32::MAX;

fn main() {
    input! {
       n: usize,
       v: [(u32,u32);n]
    }
    let mut v = v;
    v.insert(0, (0,0));
    let mut dp = vec![vec![0;n+1];n+1];
    for l in 2..n+1 {
        for i in 1..n-l+2 {
            let j = i+l-1;
            dp[i][j] = INF;
            for k in i..j {
                dp[i][j] = std::cmp::min(
                    dp[i][j],
                    dp[i][k] + dp[k+1][j] + v[i].0 * v[k].1 * v[j].1);
            }
        }
    }
    println!("{}", dp[1][n]);
}
/* vim:set foldmethod=marker: */



Measured memory_bytes: 5056
#include<bits/stdc++.h>
#define ll long long 
#define vi vector<int>
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;

const int N=5e5+1;
#define u64 uint64_t
#define u128 __uint128_t

const u64 mod=1e9+7;
u128 fastexpo(u64 a, u64 b){
    u64 res=1;
    while(b){
        if(b&1) res=(u128)res*a%mod;
        a=(u128)a*a%mod;
        b>>=1;
    }
    return res;
}

void EE(int aa, int bb, int& xx, int& yy){if(aa%bb == 0){xx=0,yy=1;return;}
EE(bb,aa%bb,xx,yy);int t = xx;xx = yy;yy = t - yy*(aa/bb);}
int mmi(int aa){int xx,yy;EE(aa,mod,xx,yy);xx = (xx+mod)%mod;return xx;}


ll n,a,b;
ll ncr(ll k){
    if(k==1) return n;
    ll res=n;
    for(int i=2;i<=k;i++){
        res= (res*(n-i+1))%mod;
        res= (res*mmi(i))%mod;
    }
    return res;
}

int main(){
    cin>>n>>a>>b;
    ll res= fastexpo(2,n)%mod;
    res=(res-1+mod)%mod;
    res=(res-ncr(a)+mod)%mod;
    res=(res-ncr(b)+mod)%mod;
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d", 6 - a - b);
}




Measured memory_bytes: 128
while True:
    (H, W) = [int(i) for i in input().split()]
    if H == W == 0:
        break
    for a in range(H):
        for b in range(W):
            if (a + b) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')

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


using namespace std;

int main() {
	long n,a,b;
	cin>>n>>a>>b;
	if (n%(a+b)<a){
		cout<<n/(a+b)*a+n%(a+b)<<endl;
	}else {
		cout<<n/(a+b)*a+a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  type pair
    integer(8) :: b, c
  end type pair
  integer(8) :: n, m, i, j, k
  integer(8), allocatable :: a(:), sub(:)
  type(pair), allocatable :: pairs(:)
  read (*, *) n, m
  allocate (a(n), pairs(m), sub(n))
  read (*, *) a(:)
  do i = 1, m
    read *, pairs(i)%b, pairs(i)%c
  end do

  call quicksort(a)
  call quicksort2(pairs)
  j = 1
  outer: do i = m, 1, -1
    do k = 1, pairs(i)%b
      sub(j) = pairs(i)%c
      j = j + 1
      if (j > n) exit outer
    end do
  end do outer

  do i = 1, n
    a(i) = max(a(i), sub(i))
  end do

  print "(i0)", sum(a)
  contains

  recursive subroutine quicksort(a)
    integer(8), intent(inout) :: a(:)
    integer(8) :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort

  recursive subroutine quicksort2(a)
    type(pair), intent(inout) :: a(:)
    type(pair) :: pivot, tmp
    integer :: i, j, k, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot%c <= a(i)%c)
        i = i + 1
      end do
      do while (.not. a(j)%c <= pivot%c)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort2(a(1:i - 1))
    call quicksort2(a(j + 1:n))
  end subroutine quicksort2
end program main


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

int main() {
    string s;
    getline(cin, s);
    for(int i = 0; i < (int)s.length(); i++) {
        if(isalpha(s[i])) {
            if(isupper(s[i])) s[i] = tolower(s[i]);
            else s[i] = toupper(s[i]);
        }
    }
    cout << s << endl;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

constexpr int MAX_LEN = 5 * 2;
int A, B;
char S[MAX_LEN + 1];

void _main() {
  cin >> A >> B >> S;

  rep(i, 0, A) {
    if (!isdigit(S[i])) {
      cout << "No" << "\n";
      return;
    }
  }
  if (S[A] != '-') {
    cout << "No" << "\n";
    return;
  }
  rep(i, 0, B) {
    if (!isdigit(S[A+1+i])) {
      cout << "No" << "\n";
      return;
    }
  }
  cout << "Yes" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin>>x;
	vector<bool> dp(x+1,false);
	dp[0]=true;
	rep(i,x+1){
		for(int j=100;j<=105;j++){
			if(i+j<=x){
				dp[i+j]=dp[i+j]|dp[i];
			}
		}
	}/*
	rep(i,x+1){
		cout<<i<<' '<<dp[i]<<endl;
	}*/
	//cout<<dp[201]<<endl;
	cout<<dp[x]<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
/*        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int b = int.Parse(input[2]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
        string a = ReadLine();
        string b = ReadLine();
        if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]){
            WriteLine("YES");
        }else{
            WriteLine("NO");
        }
    }
}

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N;

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

	cin >> N;

	int ans = 1;
	int m = 1;

	for(int i = 1; i <= N; i++){
		int x = i;
		int cont = 0;
		while(x % 2 == 0){
			x /= 2;
			cont++;
		}

		if(cont >= m){
			m = cont;
			ans = i;
		}
	}

	cout << ans << "\n";


	return 0;		
}

Measured memory_bytes: 256
# coding: utf-8
#
# :u ノードのインデックス
# :k u の出次数
# :v u に隣接する頂点の番号
# :w 隣接する頂点への重み
#
INF  = Float::INFINITY
Node = Struct.new(:u, :k, :v, :w)

class Graph
  attr :nodes, :dist
  def initialize(n)
    @nodes = Array.new(n){ Node.new }
    @nodes = @nodes.map.with_index do |node,idx|
      node.u = idx
      node
    end
    @dist = Array.new(n).map{Array.new(n, 0)}
  end

  def add_graph_edge(u, v, w)
    #puts "#{u} -> #{v} (#{w})"
    if @nodes[u].v.nil?
      @nodes[u].v = [v]
      @nodes[u].w = {v=>w}
    elsif @nodes[u].v.is_a?(Array)
      @nodes[u].v << v
      @nodes[u].w = {v=>w}.merge(@nodes[u].w)
    else
      @nodes[u].v = [@nodes[u].v, v]
      @nodes[u].w = {v=>w}.merge(@nodes[u].w)
    end
    @nodes[u].k = if @nodes[u].v.is_a?(Array)
                    @nodes[u].v.length
                  else
                    1
                  end
  end

  def warshall_floyd()
    # initialize
    for i in 0...@nodes.length
      for j in 0...@nodes.length
        @dist[i][j] = if not @nodes[i].w.nil? and @nodes[i].w.has_key?(j)
                        @nodes[i].w[j]
                      else
                        INF
                      end
      end
      @dist[i][i] = 0
    end

    # calc
    for k in 0...@nodes.length
      for i in 0...@nodes.length
        for j in 0...@nodes.length
          if @dist[i][k] != INF and @dist[k][j] != INF
            @dist[i][j] = [@dist[i][j], @dist[i][k] + @dist[k][j]].min
          end
        end
      end
    end
  end

  def has_negative_cycle?()
    ans = false
    for v in 0...@nodes.length
      ans = true if @dist[v][v] < 0
    end
    ans
  end
end

lines = $stdin.read
array = lines.split("\n")

N,M = array[0].split(" ").map(&:to_i)
graph = Graph.new(N)

array[1..M].each do |s|
  s,t,d = s.split(" ").map(&:to_i)
  graph.add_graph_edge(s-1,t-1,d)
  graph.add_graph_edge(t-1,s-1,d)
end

# execute WarshallFloyd !
graph.warshall_floyd()

ans = array[1..M].count do |s|
  s,t,d = s.split(" ").map(&:to_i)
  s,t = s-1,t-1
  graph.dist[s][t] != d
end

puts ans


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

int main() {
  int N, K; 
  cin >> N >> K;
  int Nco = 1;
  for (int i = 0; i < N; i++){
    if (Nco < K){
      Nco *= 2;
    }else{
      Nco += K;
    }
  }
  cout << Nco << endl;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))
dd=dict()
td=dict()
for i in d:
    if i in dd:
        dd[i]+=1
    else:
        dd[i]=1
for i in t:
    if i in td:
        td[i]+=1
    else:
        td[i]=1
for i,j in td.items():
    if i not in dd:
        print('NO')
        exit()
    elif dd[i]<j:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 56788
n,k,*a=map(int,open(0).read().split())
r=range(n)
while k:
 k-=1;b=[0]*n*3
 for i in r:t=a[i];b[max(0,i-t)]+=1;b[i-~t]-=1
 for i in r:b[i+1]+=b[i]
 a=b[:n]
 if min(a)==n:break
print(*a)

Measured memory_bytes: 173180
from collections import deque

n,m = map(int,input().split())
edges_p = {}
edges_l = {}

for i in range(1,m+1):
    edges_l[i] = []

for i in range(1,n+1):
    tmp = list(map(int, input().split()))
    edges_p[i] = tmp[1:]
    for j in edges_p[i]:
        edges_l[j].append(i)


remains = set(range(1,n+1))
remains_l = set(range(1,m+1))
d = deque()

d.append(1)
remains.remove(1)

while(len(d) > 0):
    tmp = d.pop()
    for i in edges_p[tmp]:
        if i in remains_l:
            for j in edges_l[i]:
                if j in remains:
                    d.append(j)
                    remains.remove(j)
            remains_l.remove(i)

if(len(remains) == 0):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 94564
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, C = LI()
    D = [LI() for _ in range(C)]
    c = [LI_() for _ in range(N)]

    # 座標グループごとに、その色に塗り替えるとかかるコストを前計算
    a = [[0] * C for _ in range(3)]
    for i, j in itertools.product(range(N), repeat=2):
        for k in range(C):
            a[(i+j)%3][k] += D[c[i][j]][k]

    # 座標グループごとに色の割当とそのコストを全探索
    ans = INF
    for i, j, k in itertools.permutations(range(C), 3):
        ans = min(a[0][i] + a[1][j] + a[2][k], ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12420
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()

int main(){
  int n,m;
  long long count=0,stock=0;
  vector<pair<int,int>> p(n);
  int a[n],b[n];
  cin >> n >> m;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  for(int i=0;i<n;i++){
    p[i]=make_pair(a[i],b[i]);
  }
  sort(ALL(p));
  //for(int i=0;i<n;i++){
    //for(int j=i+1;j<n;j++){
      //if(a[i]>a[j]){
        //swap(a[i],a[j]);swap(b[i],b[j]);
      //}
    //}
  //}
  //for(int i=0;i<n;i++)cout << a[i] << "\n";
  //for(int i=0;i<n;i++)cout << b[i] << "\n";
  int k=0;
  while(1){
  if(p[k].second < m){
	m-=p[k].second;count+=(long long)p[k].first*p[k].second;
  }
  else{
    count+=(long long)m*p[k].first;break;
  }
    k++;
  }
  cout << count;
}


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

using namespace std;

#define int int64_t

const int maxn = 1e5 + 42;

int a[maxn][3];
int sum = 0;
set<pair<int, int>> penalty[3][3];

void penalty_ins(int x, int i)
{
    sum += a[i][x];
    penalty[x][0].insert({a[i][x] - a[i][0], i});
    penalty[x][1].insert({a[i][x] - a[i][1], i});
    penalty[x][2].insert({a[i][x] - a[i][2], i});
}

void penalty_rem(int x, int i)
{
    sum -= a[i][x];
    penalty[x][0].erase({a[i][x] - a[i][0], i});
    penalty[x][1].erase({a[i][x] - a[i][1], i});
    penalty[x][2].erase({a[i][x] - a[i][2], i});
}

bool change(int x, int y)
{
    auto it1 = begin(penalty[x][y]);
    auto it2 = begin(penalty[y][x]);
    int c1 = it1->first;
    int c2 = it2->first;
    int n1 = it1->second;
    int n2 = it2->second;
    if(c1 + c2 < 0)
    {
        penalty_rem(x, n1);
        penalty_rem(y, n2);
        penalty_ins(x, n2);
        penalty_ins(y, n1);
        return 1;
    }
    return 0;
}

bool change(int x, int y, int z)
{
    auto it1 = begin(penalty[x][y]);
    auto it2 = begin(penalty[y][z]);
    auto it3 = begin(penalty[z][x]);
    int c1 = it1->first;
    int c2 = it2->first;
    int c3 = it3->first;
    int n1 = it1->second;
    int n2 = it2->second;
    int n3 = it3->second;
    if(c1 + c2 + c3 < 0)
    {
        penalty_rem(x, n1);
        penalty_rem(y, n2);
        penalty_rem(z, n3);
        penalty_ins(x, n3);
        penalty_ins(y, n1);
        penalty_ins(z, n2);
        return 1;
    }
    return 0;
}

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    int n = x + y + z;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
        if(i < x)
            penalty_ins(0, i);
        else if(i < x + y)
            penalty_ins(1, i);
        else
            penalty_ins(2, i);
    }
    while(true)
    {
        bool rep = 0;
        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                if(change(i, j))
                    rep = 1;
        for(int i = 0; i < 3; i++)
            for(int j = 0; j < 3; j++)
                for(int k = 0; k < 3; k++)
                    if(i != j && j != k && i != k)
                        if(change(i, j, k))
                            rep = 1;
        if(!rep)
            break;
    }
    cout << sum << endl;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int Ans=0;
	int N;
	cin>>N;
	for (int i=1;i<=N;++i)
	{
		int v;
		cin>>v;
		if (v&1)
			if (i&1)
				++Ans;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"

using namespace std;

#define ll               long long int
#define endl             '\n'

static const int maxn = 3e5 + 5;

int arr[maxn], dp[maxn];

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);


      int n;
      cin >> n;
      for (int i = 1; i <= n; i++) cin >> arr[i];
      int maxi = 0;
      dp[n] = 1;
      for (int i = n - 1; i >= 1; i--)
      {
            if (arr[i] >= arr[i + 1]) dp[i] = 1 + dp[i + 1];
            else dp[i] = 1;
            maxi = max(maxi, dp[i] - 1);
      }
      cout << maxi << endl;
}


Measured memory_bytes: 1024
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
#define rep(x,y,z) for(int x=y;x<z;x++)
int main(){
	ll n;
	cin>>n;
	vector<ll> ht(n);
	rep(i,0,n){
		cin>>ht[i];
	}
	if(n==2){
		cout<<abs(ht[0]-ht[1])<<"\n";
		return 0;
	} 
	ll prev1=abs(ht[0]-ht[1]), prev2=0;
	rep(i,2,n){
		ll tmp = min(prev1+abs(ht[i-1]-ht[i]), prev2+abs(ht[i-2]-ht[i]));
		prev2=prev1;
		prev1=tmp;
	}
	cout<<prev1<<"\n";
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

string s;
const string north("north");
const string west("west");

pair<LL, LL> solve() {
    VB xs;
    rep(i, s.size()) {
        if (s[i] == 'n') {
            xs.PB(true);
            i += 4;
        } else {
            xs.PB(false);
            i += 3;
        }
    }

    // p / q
    LL p = xs.back() ? 0 : 90;
    LL q = 1;

    LL q2 = 2;
    for (int i = xs.size() - 2; i >= 0; --i) {
        LL p2 = xs[i] ? -90 : 90;

        LL np = p * q2 + p2 * q;
        LL nq = q * q2;
        LL c = __gcd(np, nq);
        p = np / c;
        q = nq / c;

        q2 *= 2LL;
    }

    return MP(p, q);
}

int main(void) {
    while (cin >> s, s != "#") {
        pair<LL, LL> x = solve();
        if (x.snd == 1) {
            cout << x.fst << endl;
        } else {
            cout << x.fst << "/" << x.snd << endl;
        }
    }

	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(void)
{
    int n;
    int num[256][3];
    int cnt[128];
    int score[256] = {0};
    int i, j;

    scanf("%d", &n);
    for (i = 0; i < n; i++){
        for (j = 0; j < 3; j++){
            scanf("%d", &num[i][j]);
        }
    }

    for (i = 0; i < 3; i++){
        for (j = 1; j <= 100; j++){
            cnt[j] = 0;
        }
        for (j = 0; j < n; j++){
            cnt[num[j][i]]++;
        }
        for (j = 0; j < n; j++){
            if (cnt[num[j][i]] == 1){
                score[j] += num[j][i];
            }
        }
    }

    for (i = 0; i < n; i++){
        printf("%d\n", score[i]);
    }

    return (0);
}

Measured memory_bytes: 600
import collections
n = int(input())
a = collections.Counter([int(x) for x in input().split()])
res = 0
for key in a.keys():
    k_int = int(key)
    val = a[key]
    if k_int == val:
        continue
    elif k_int < val:
        res += val - k_int
    else:
        res += val
print(res)

Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int digit_length(long long n) {
    int res = 0;
    while (n) {
        res++;
        n /= 10;
    }
    return res;
}

void _main() {
    int N;
    cin >> N;
    int ans = 1LL << 30;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i != 0) continue;
        int A = i, B = N / i;
        ans = min(ans, max(digit_length(A), digit_length(B)));
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.14159265;

int main(){
	IO;
	int l;
	cin>>l;
	printf("%.12f", 1.0*l*l*l/27);
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    cout << (s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  vll p(n);
  vll q(n);
  vll lst;
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  rep(i, n) lst.push_back(i + 1);

  ll ord = 1;
  ll a = -1;
  ll b = -1;
  do {
    if (lst == p)
      a = ord;
    if (lst == q)
      b = ord;
    ord++;
  } while (next_permutation(lst.begin(), lst.end()));
  assert(a >= 1 && b >= 1);

  cout << abs(a - b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100000
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int INF = 2147483647;
#define B 1000
 
int bucket[MAX/B][B];
int data[MAX/B];
void update(int a, int b, int x){
    int f1 = 1, f2 = 1;
    while(a <= b && a%B != 0){
        if(f1 && data[a/B] != -1){
            for(int i = 0;i < B;i++)bucket[a/B][i] = data[a/B];
            f1 = 0;data[a/B] = -1;
        }
        bucket[a/B][a%B] = x;
        a++;
    }
    while(a <= b && b%B != B-1){
        if(f2 && data[b/B] != -1){
            for(int i = 0;i < B;i++)bucket[b/B][i] = data[b/B];
            f2 = 0;data[b/B] = -1;
        }
        bucket[b/B][b%B] = x;
        b--;
    }
    while(a < b){
        data[a/B] = x;
        a += B;
    }
}
 
int find(int x){
    if(data[x/B] != -1){
        for(int i = 0;i < B;i++)bucket[x/B][i] = data[x/B];
        data[x/B] = -1;
    }
    return bucket[x/B][x%B];
}
 
int main(){
    int n, q, c, s, t, x, ans;
    scanf("%d%d", &n, &q);
    fill(data, data+MAX/B, -1);
    fill((int*)bucket, (int*)(bucket+MAX/B), INF);
    while(q--){
        scanf("%d", &c);
        if(!c){
            scanf("%d%d%d", &s, &t, &x);
            update(s, t, x);
        }else{
            scanf("%d", &x);
            ans = find(x);
            printf("%d\n", ans);
        }
    }
    //rep(i,n)printf("%d ", bucket[0][i]);
    return 0;
}

Measured memory_bytes: 3592
t[9999][999],j;main(p,W,a,b,c){for(;scanf("%d",&W),W;printf("Case %d:\n%d\n%d\n",p++,t[0][W],j)){for(scanf("%d",&c);c&&scanf("%d,%d",&b,&a);j=c--)for(j=0;j<=W;j++)t[c-1][j]=j<a?t[c][j]:fmax(t[c][j],(t[c][j-a]+b));for(;t[0][++j]-t[0][W];);}} 

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

using namespace std;

int main(void){
    int n,w;
    cin >> n >> w;
    vector <int> wt(n);
    vector <int> val(n);
    for (int i=0;i<n;i++){
        cin >> wt[i] >> val[i];
    }
    // sort(wt.begin(), wt.end());
    // sort(val.begin(), val.end());

    long long dp[n+1][w+1];
    for(int i=0;i<n+1;i++){
        for (int j=0;j<w+1;j++){
            if (i == 0 || j == 0){
                dp[i][j] = 0;
            }else if (wt[i-1] > j){
                dp[i][j] = dp[i-1][j];
            }else if (wt[i-1] <= j){
                dp[i][j] = max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
            }
        }
    }

    cout << dp[n][w] << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    int t = n % 1000;

    if (t == 0) {
        cout << 0 << endl;
    } else {
        cout << 1000 - t << endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();

        ArrayList<Integer> s = new ArrayList<>();
        for(int i=0; i<N; i++) {
        	s.add(sc.nextInt());
        }

        long score = 0;
        for(int c=1; c<=N-1; c++) {
        	long tmp = 0;
        	Set<Integer> t = new HashSet<Integer>();
        	for(int k=0; k*c<N-1; k++) {

        		//進む<=戻る
        		if((N-1) - k*c<=c) break;

        		if(t.contains(k*c)) break;
        		tmp += s.get(k*c);
        		t.add(k*c);

        		if(t.contains((N-1)-k*c)) break;
        		tmp += s.get((N-1)-k*c);
        		t.add((N-1)-k*c);

            	score = Math.max(score, tmp);
        	}
        }
        System.out.println(score);
        sc.close();

    }

}


Measured memory_bytes: 67272
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- Sun Mar 22 18:28:30 2020

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


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}
  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 	
 	ll a=LL,b=LL;
 	ll ans=((a*(a-1))/2)+ ((b*(b-1))/2);
 	cout<<ans<<endl;
 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N, W := ReadInt(), ReadInt()

	ws := make([]int, N+1)
	vs := make([]int, N+1)

	for i := 1; i <= N; i++ {
		ws[i], vs[i] = ReadInt(), ReadInt()
	}

	prev := [1e5 + 1]int{}
	for i := 1; i <= N; i++ {
		next := [1e5 + 1]int{}
		for w := 1; w <= W; w++ {
			next[w] = prev[w]
			if w-ws[i] >= 0 {
				next[w] = Max(next[w], prev[w-ws[i]]+vs[i])
			}

		}
		prev = next
	}
	fmt.Println(prev[W])
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 3408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=10001 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
ll n;
vector<string>ans ;
void fun(ll i,ll j,string s)
{
    if(i==n)
    {
        ans.pb(s) ;
    }
    else
    {
        string ns=s ;
        for(ll k=0;k<j;k++)
        {
            ns=s ;
            ns+=(char)('a'+k) ;
            fun(i+1,j,ns) ;
        }
        if(s.length()==0)
            return ;

        if(j<26)
        {
            ns=s ;
            ns+=(char)('a'+j) ;
            fun(i+1,j+1,ns) ;
        }



    }
}
int main()
{
   fast ;
   ll tests=1 ;
  // cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
      ///cout<<"Case #"<<testcase<<": " ;
      ///Read,Think ans Test Properly,then code
      ///Try to avoid using print statements debug on your own
     cin>>n ;

     fun(0,1,"") ;

     sort(all(ans)) ;

     for(string s:ans)
        cout<<s<<endl ;





   }
}
/// ans ->for answer
/// cur ->for local answer
/// level ->for depth in tree
/// v -> adjacency matrix
/// r -> array
/// s ->string



Measured memory_bytes: 7796
player = {}

player['a'] = list(input())
player['b'] = list(input())
player['c'] = list(input())
flag = 1
next_player = player['a'][0]
player['a'].pop(0)
while flag:
    if player[next_player]:
        before_player = next_player
        next_player = player[next_player][0]
        player[before_player].pop(0)
    else:
        print(next_player.upper())
        break

Measured memory_bytes: 3064
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 23:39:17 2018
//
package main

import (
	"fmt"
	"sort"
)

func max(slice ...int) int {
	sort.Ints(slice)
	return slice[len(slice)-1]
}

func main() {
	var N, C int
	fmt.Scan(&N, &C)

	xs := make([]int, N)
	vs := make([]int, N)
	for i := range xs {
		fmt.Scan(&xs[i], &vs[i])
	}

	right := make([]int, N)
	for i := range right {
		right[i] = vs[i]
		if i > 0 {
			right[i] += right[i-1]
		}
	}

	left := make([]int, N)
	for i := range left {
		left[i] = vs[len(vs)-1-i]
		if i > 0 {
			left[i] += left[i-1]
		}
	}

	rightMax := make([]int, N)
	for i, r := range right {
		cal := r - xs[i]
		rightMax[i] = cal
		if i > 0 {
			rightMax[i] = max(rightMax[i], rightMax[i-1])
		}
	}

	leftMax := make([]int, N)
	for i, l := range left {
		cal := l - (C - xs[len(left)-1-i])
		leftMax[i] = cal
		if i > 0 {
			leftMax[i] = max(leftMax[i], leftMax[i-1])
		}
	}

	ans := max(0, rightMax[len(rightMax)-1], leftMax[len(leftMax)-1])
	for i := range rightMax {
		left := 0
		if i < len(rightMax)-1 {
			left = leftMax[N-i-2]
		}
		ans = max(ans, rightMax[i]-xs[i]+left)
	}

	for i := range leftMax {
		right := 0
		if i < len(leftMax)-1 {
			right = rightMax[N-i-2]
		}
		ans = max(ans, leftMax[i]-(C-xs[len(left)-1-i])+right)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  if(m>=n*2){
    ans+=n;
    m-=n*2;
    ans+=m/4;
  }else{
    ans+=m/2;
  }
  cout<<ans<<endl;
}

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

using namespace std;

const int N = 200000 + 7;

typedef long long ll;
int main() {
  string s;
  cin >> s;
  //for(int i = 0; i < 4; ++i) s[i] -= '0';
  string s1 = s.substr(0, 2);
  string s2 = s.substr(2, 2);
  //cout << s1 << "x" << s2 << endl;
  if("00" < s1 && s1 <= "12" && "00" < s2 && s2 <= "12") {
    cout << "AMBIGUOUS" << endl;
  } else if((s1 == "00" || s1 > "12") && "00" < s2 && s2 <= "12"){
    cout << "YYMM" << endl;
  } else if("00" < s1 && s1 <= "12" && (s2 > "12" || s2 == "00")) {
    cout << "MMYY" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


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

int main()
{
    long long i,j,n,ans=0;
    scanf("%lld",&n);
    long long a[(3*n)];
    for(i=0;i<3*n;i++)
    {
        scanf("%lld",&a[i]);
    }

    sort(a,a+(3*n));
    for(i=0,j=(n*3)-2;i<n;i++,j-=2)
    {
        ans+=a[j];
    }
    printf("%lld",ans);

    return 0;
}

Measured memory_bytes: 6172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x=scanner.nextInt();
		int y=scanner.nextInt();
		while(x!=0||y!=0) {
			if(x<y) {
				System.out.println(x+" "+y);
			}else {
				System.out.println(y+" "+x);
			}
			x=scanner.nextInt();
			y=scanner.nextInt();
		}

	}
}



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

signed main(void)
{
	int h, w, d, l, r, q;
	cin >> h >> w >> d;
	P memo[h * w];
	vector<int> dist(h * w, 0);

	rep(i, h) rep(j, w)
	{
		int a;
		cin >> a;
		a--;
		memo[a] = P(i, j);
	}
	rep(i, h * w - d)
	{
		dist[i + d] = dist[i] + abs(memo[i].first - memo[i + d].first) +\
					  abs(memo[i].second - memo[i + d].second);
	}
	cin >> q;
	rep(i, q)
	{
		cin >> l >> r;
		--l; --r;
		cout << dist[r] - dist[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    x, y = map(int, input().split())

    A = [1,3,5,7,8,10,12]
    B = [4,6,9,11]
    C = [2]

    if x in A and y in A:
        print('Yes')
    elif x in B and y in B:
        print('Yes')
    elif x in C and y in C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10492
#include<iostream>
using namespace std;
int main()
{
	long long x,temp;
	cin >> x;
	int flag = 0;
	for (long long i = -120; i <= 120; i++) {
		if (flag) break;
		for (long long j = -120; j <= 120; j++) {
			temp = j * j * j * j * j - i * i * i * i * i;
			if (temp == x) {
				cout << j << ' ' << i;
				flag = 1;
				break;
			}
			if (temp > x) break;
		}
	}
	return 0;
}

Measured memory_bytes: 3600