akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
int calcOver(int, int);
int calcM(int, int ,int);

int main() {
  while(true) {
    int e;
    cin >> e;
    if(e == 0) break;
    int y = 0;
    int z = 0;
    int maxover = 0;
    int limity = pow(e, 1.0 / 2.0) + 1;
    int limitz = pow(e, 1.0 / 3.0) + 1;
    int maxy = limity;
    int maxz = limitz;
    int minm = e;
    bool flag = false;
    //cout << limity << ":" << limitz << endl;
    for(y = limity; y >= 0; --y) {
      for(int z = limitz; z >= 0; --z) {
        int m = calcM(e, y, z);
        //if((y + z <= m) && (m <= y + z + e)) {
        if(e >= calcOver(y, z)) {
          //cout << y << ":" << z << ":" << ":" << m << endl;
          if(minm > m) {
            maxy = y;
            maxz = z;
            minm = m;
          }
        }
      }
    }
    //cout << maxy << ":" << maxz << endl;
    cout << minm << endl;
  }
  return 0;
}

int calcOver(int y, int z) {
  return (y*y + z*z*z);
}
int calcM(int e, int y, int z) {
  return (e - y*y - z*z*z + y + z);
}

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

int main(){
	int n, m, r;
	cin >> n >> m >> r;
	int64_t t[r];
	for(int64_t &i:t){
		cin >> i;
		i--;
	}
	sort(t, t + r);
	int64_t cost[n][n];
	fill(cost[0], cost[n], 1ll << 60);
	while(m--){
		int64_t a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		cost[a][b] = cost[b][a] = c;
	}
	for(int i = 0; i < n; i++) cost[i][i] = 0;
	for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
	int64_t ans = 1ll << 60;
	do{
		int64_t tmp = 0;
		for(int i = 1; i < r; i++) tmp += cost[t[i - 1]][t[i]];
		ans = min(ans, tmp);
	}while(next_permutation(t, t + r));
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    long sum = 0;
    for (int i = 0; i < N; i++) {
      sum += A[i];
    }
    if (sum % 2 == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 51720
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
    scanf("%d %d", &x, &n);
	if (n == 0) {
		printf("%d", x);
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &t);
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
        printf("%d", x);
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
 	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
        printf("%d", rV);
	} else if (d2 < d1) {
		printf("%d", lV);
	} else {
		printf("%d", min(rV, lV));
	}
	return 0;
}

Measured memory_bytes: 3232
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e3 + 10 , M = 5e3 + 10 , inf = 1<<28;
int n , par[N] , x[N] , q[N] , dp[N][2] , f[M] , g[M];
vi G[N];

void Update(int &x,int d){
    x = min(x , d);
}

int main(){
    cin >> n;
    rep(i,2,n+1) cin >> par[i] , G[par[i]].pb(i);
    rep(i,1,n+1) cin >> x[i];
    int _ = 0;q[_++] = 1;
    rep(i,0,_) for(auto e : G[q[i]]) q[_++] = e;
    per(ii,0,_) {
        int i = q[ii];
        rep(j,0,x[i] + 1) f[j] = inf;
        f[0] = 0;
        for(auto e : G[i]) {
            rep(j,0,x[i] + 1) g[j] = inf;
            per(j,0,x[i] + 1) if(j - x[e] >= 0)
                Update(g[j] , f[j - x[e]] + dp[e][0]);
            per(j,0,x[i] + 1) if(j - dp[e][1] >= 0)
                Update(g[j] , f[j - dp[e][1]] + x[e]);
            rep(j,0,x[i] + 1) f[j] = g[j];
        }
        dp[i][0] = inf;
        rep(j,0,x[i] + 1) Update(dp[i][0] , f[j]);

        rep(j,0,x[i] + 1) f[j] = inf;
        f[0] = 0;
        for(auto e : G[i]) {
            rep(j,0,x[i] + 1) g[j] = inf;
            per(j,0,x[i] + 1) if(j - x[e] >= 0)
                Update(g[j] , f[j - x[e]] + dp[e][1]);
            per(j,0,x[i] + 1) if(j - dp[e][0] >= 0)
                Update(g[j] , f[j - dp[e][0]] + x[e]);
            rep(j,0,x[i] + 1) f[j] = g[j];
        }
        dp[i][1] = inf;
        rep(j,0,x[i] + 1) Update(dp[i][1] , f[j]);
    }
    puts(min(dp[1][0] , dp[1][1]) != inf ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,x,ans=1,d=0;
    cin >> n >> x;
    vector<int> vec(n);
    for(size_t i = 0 ; i < n  ; i++){
        cin >> vec[i];
    }

    for(size_t i = 0 ; i < n ; i++){
        d = d + vec[i];
        if(d <= x){
           ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

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

const int MAX_N=1e5+10;

int dist[MAX_N][2],N;
vector <int> G[MAX_N];

inline void dfs(int Mark,int at,int fr){
	for(int i=0;i<G[at].size();i++){
		int to=G[at][i];
		if(to!=fr){
			dist[to][Mark]=dist[at][Mark]+1;
			dfs(Mark,to,at);
		}
	}
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b; cin>>a>>b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	dist[0][0]=0; dist[N-1][1]=0;
	dfs(0,0,-1); dfs(1,N-1,-1);
	int sumS=0,sumF=0;
	for(int i=0;i<N;i++){
		if(dist[i][0]>dist[i][1]) sumS++;
		else sumF++;
	}
	if(sumF>sumS) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;  
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int a, b, x;
    cin >> a >> b>> x;
    if(x < a ||x > a+b) cout<<"NO\n";
    else cout <<"YES\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[105];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n-1;i++)
    {
        for(int j=0;j<n-1-i;j++)
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                ans++;
            }
    }
    for(int i=0;i<n;i++)
    {
        if(i)cout<<' ';
        cout<<a[i];
    }
    cout<<endl;
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  string s; cin >> s;
  int mn = 1e9, mx = -1;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'C') mn = min(mn, i);
    if(s[i] == 'F') mx = max(mx, i);
  }
  if(mn < mx) {
    cout << "Yes" << '\n';
  }
  else {
    cout << "No" << '\n';
  }
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) (n int, err error) {
	sc.Scan()
	s := sc.Text()
	n, err = strconv.Atoi(s)
	return
}

func readIntNums(sc *bufio.Scanner, n int) ([]int, error) {
	nums := make([]int, n)
	for i, _ := range nums {
		if a, err := nextInt(sc); err == nil {
			nums[i] = a
		} else {
			return nums, err
		}
	}
	return nums, nil
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var i int
	for {
		i++
		n, err := nextInt(sc)
		if n == 0 || err != nil {
			break
		}
		fmt.Printf("Case %d: %d\n", i, n)
	}
}



Measured memory_bytes: 1384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  bool ok = false;
  if (s == "hi") ok = true;
  if (s == "hihi") ok = true;
  if (s == "hihihi") ok = true;
  if (s == "hihihihi") ok = true;
  if (s == "hihihihihi") ok = true;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,k;
	int sum=0;
	int l[50];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	sort(l,l+n,std::greater<int>());
	
	for(int i=0;i<k;i++){
		sum+=l[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  int p=0;
  int ans=0;

  rep(i,M){
    int k;
    cin >> k;
    rep(j,k){
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
  }
  rep(i,M){
    int x;
    cin >> x;
    p |= x << i;
  }

  for(int s=0;s<(1<<N);s++){
    int t=0;
    rep(i,N){
      if(s>>i&1){
        t ^= a[i];
      }
    }
    if(t==p){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def solve():

    N, K = map(int, input().split())
    hlist = [int(input()) for i in range(N)]

    # sortして走破？
    hlist.sort()
    l = []

    for i in range(N-K+1):
        l.append(hlist[i+K-1]-hlist[i])

    print(min(l))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 55640
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String date = sc.next();
		int num = Integer.parseInt(date);
		int a = num / 100;
		int b = num % 100;
		boolean isYYMM = true;
		boolean isMMYY = true;
		if (a < 1 || a > 12)
			isMMYY = false;
		if (b < 1 || b > 12)
			isYYMM = false;
		if (isYYMM && isMMYY)
			out.println("AMBIGUOUS");
		else if (isYYMM && !isMMYY)
			out.println("YYMM");
		else if (!isYYMM && isMMYY)
			out.println("MMYY");
		else
			out.println("NA");
		
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>p(N);
  ins(p);
  vector<long>q=p;
  sort(all(p));
  long cnt=0;
  rep(i,N)if(p[i]!=q[i])cnt++;
  if(cnt<=2)out("YES");
  else out("NO");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    sc.close();

    Map<Integer, Integer> lcm = new HashMap<>();
    for (int i = 0; i < N; i++)
      for (Map.Entry<Integer, Integer> a : f(A[i]).entrySet())
        lcm.put(a.getKey(), Math.max(lcm.getOrDefault(a.getKey(), 0), a.getValue()));


    long mod = 1000000007;
    long ans = 0;

    long modLcm = 1;
    for (Map.Entry<Integer, Integer> lcm_p : lcm.entrySet())
      modLcm = modLcm * modPow(lcm_p.getKey(), lcm_p.getValue(), mod) % mod;

    for (int ai : A)
      ans = (ans + modDiv(modLcm, ai, mod)) % mod;

    System.out.println(ans);
  }

  private static long modDiv(long a, long b, long mod) {
    return (a % mod) * modInv(b, mod) % mod;
  }

  private static long modInv(long x, long mod) {
    return modPow(x, mod - 2, mod);
  }

  private static long modPow(long b, long e, long mod) {
    long ans = 1;
    long x = b % mod;
    for (long y = e; y != 0; y >>= 1) {
      if ((y & 1) == 1) ans = (ans * x) % mod;
      x = (x * x) % mod;
    }
    return ans;
  }

  private static Map<Integer, Integer> f(int n) {
    Map<Integer, Integer> f = new HashMap<>();
    int m = n;
    int s = SIEVE[m - 1];
    while (s != 0) {
      f.put(s, f.getOrDefault(s, 0) + 1);
      m /= s;
      s = SIEVE[m - 1];
    }
    return f;
  }

  private static int[] SIEVE = sieve(1000000);

  private static int[] sieve(int n) {
    int [] sieve = new int[n];
    for (int i = 2; i <= n; i += 2) sieve[i - 1] = 2;
    int sqrt = (int) Math.sqrt(n);
    for (int i = 3; i <= n; i += 2) {
      if (sieve[i - 1] == 0) sieve[i - 1] = i;
      if (i <= sqrt)
        for (int j = i * i; j <= n; j += i)
          if (sieve[j - 1] == 0) sieve[j - 1] = i;
    }
    return sieve;
  }
}

Measured memory_bytes: 44072
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

template <typename T> bool isOK(ll index, T key,vector<T> a) {
    if (a[index] >= key) return true;
    else return false;
}

template <typename T> ll search2(T key,vector<T> a) {
    ll left = -1;
    ll right = (ll)a.size();

    while (right - left > 1) {
        ll mid = left + (right - left) / 2;

        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }

    return right;
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    vll a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    
    sort(ALL(a));
    
    printf("%lld ",a[n-1]);
    
    ll b=search2(a[n-1]/2,a);
    
    if(b==0)printf("%lld\n",a[b]);
    else{
        if(a[b]-a[n-1]/2.0<a[n-1]/2.0-a[b-1])printf("%lld\n",a[b]);
        else printf("%lld\n",a[b-1]);
    }
    
    return 0;
}


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

int main(){
  int x1, y1, x2, y2;
  cin>>x1>>y1>>x2>>y2;
  int a=x2-x1;
  int b=y2-y1;
  int x3, y3, x4, y4;
    x3=x2-b;
    y3=y2+a;
    x4=x3-a;
    y4=y3-b;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl; 
}


Measured memory_bytes: 256
a, b = map(int, input().split())
def xor(x):
    num = [0 for i in range(41)]
    for i in range(41):
        temp = (x + 1) // (2 ** (i + 1))
        temp2 = (x + 1) % (2 ** (i + 1))
        num[i] += temp * (2 ** i)
        num[i] += max(temp2 - 2 ** i, 0)
    return num
temp = [0 for i in range(41)]
temp2 = xor(b)
temp3 = xor(a - 1)
for i in range(41):
    temp[i] += temp3[i]
    temp[i] -= temp2[i]
    temp[i] %= 2
ans = 0
for i in range(41):
    ans += temp[i] * 2 ** i
print(ans)

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

ll f[100010];

ll mul(ll a,ll b){ return (a*b)%mod;}

ll power(ll n, ll r){
    if(r==1)return n;
    if(r%2==0)return power(mul(n,n),r/2);
    else return mul(power(mul(n,n),r/2),n);
}

ll divm(ll a,ll b){
    return mul(a, power(b, mod-2));
}

ll fact(ll n){
    if(f[n]) return f[n];
    if(n==0) return 1;
    return f[n] = mul(n,fact(n-1));
}

ll com(ll n,ll r){
    if(n<r) return 0;
    return divm(fact(n),mul(fact(n-r),fact(r)));
}

int main(void){
    int n,l=0,r=0;
    cin>>n;
    vector<int> a(n+1),pos(n+1,-1);
    rep(i,n+1){
        cin>>a[i];
        if(pos[a[i]]>=0){
            l = pos[a[i]];
            r = i;
        }
        pos[a[i]] = i;
    }
    
    for(int k = 1; k<=n+1; k++){
        cout<<(com(n+1,k)+mod-com(l+n-r,k-1))%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
using namespace std;

int main () {
  int S, h, m, s;
  scanf("%d", &S);
  s = (S % 3600) % 60;
  m = ((S - s) % 3600) / 60;
  h = (S - s - 60 * m) / 3600;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}


Measured memory_bytes: 2736
#include <stdio.h>
#include <math.h>

int main()
{
	int price, num, x, y, i;

	price = 0;
	num = 0;
	i = 0;

	while(scanf("%d,%d", &x, &y) != EOF){
		price += x*y;
		num += y;

		i++;
	}

	printf("%d\n%d\n", price, (int)round((double)num/(double)i));

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    for(int i = 0;i < n;i++) cin >> x[i];
    long long ans = 9223372036854775806,tmp;
    
    for(int i = 0;i <= n-k;i++){
        tmp = min(abs(x[k-1+i])+abs(x[i]-x[k-1+i]),abs(x[i])+abs(x[i]-x[k-1+i]));
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin >> n;

    int x[n];
    REP(i, n) cin >> x[i];

    bool check = true;
    REP(i, n){
        if (x[i] % 2 == 0){
            if (x[i] % 3 == 0 || x[i] % 5 == 0) continue;
            check = false;
        }
    }

    if (check) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
from math import factorial
def comb(n,k):
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)
  b=factorial(k)
  c=factorial(n-k)
  return a//(b*c)
n=int(input())
s=[sorted(list(input())) for i in range(n)]
s.sort()
cnt=1
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
if cnt>=2:
  ans+=comb(cnt,2)
print(ans)

Measured memory_bytes: 25516
'''
方針：各Aiをそれぞれ見て、いくつ偶数があっていくつ奇数があるかを数える。
以下偶数がX個、奇数がY個あるとする。(X+Y=N,0≦X,Y)
そしてこの問題は偶数の集合の中からの選ぶことと奇数の集合の中から選ぶことを独立に考えることができる。
よって（偶数の集合からの選び方）×（奇数の集合からの選び方）で求めることができる。
（偶数の集合からの選び方）については、どのように選んでも全体の合計を2で割った余りは変わらないので全事象を考えることができる。
よって2^Xである。
（奇数の集合からの選び方）についてはY個のうちk個（k≡P mod 2）である場合の数の合計なので
Σ[k:0→Y and k≡P mod 2]C(Y,k)である。
ただし、C(Y,k)は二項係数を表していて、Σ[k:0→Y and k≡P mod 2]は0≦k≦Nかつk≡P mod 2であるものすべてを足し合わせたという意味である。
'''
def C(n,m):
    S=1
    for i in range(1,n+1):
        S=S*i
    for i in range(1,m+1):
        S=S//i
    for i in range(1,n-m+1):
        S=S//i
    return S
N,P=map(int,input().split())
A=[int(i) for i in input().split()]
X=0;Y=0
#X:偶数
#Y:奇数
for i in range(N):
    if A[i]%2==0:
        X+=1
    else:
        Y+=1
Z=0
for i in range(Y+1):
    if i%2==P:
        Z+=C(Y,i)
print(Z*2**(X))


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)

{  

int a,b,d,r;  

double f;

 scanf("%d %d",&a,&b);

 d=a/b;

 r=a%b;

 f=(double)a/b;  

 printf("%d %d %lf\n",d,r,f);  

 return 0;

}
 

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;


 
int main(){
  ios_base::sync_with_stdio(false);
  
  int n;
  int ans = 0;
  int cnt = 0;

  cin >> n;

  for(int i=1;i<=n;i+=2){
    cnt = 0;
    for(int j=1;j<=i;j++){
      if(i % j == 0)cnt++;
    }
    if(cnt == 8){
      //cout << i << endl;
      ans++;
    }
  }

  cout << ans << endl;
 
  return 0;
}



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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=0;true;i++){
  c=c-b;
  if(c<=0){
  cout<<"Yes"<<endl;
  return 0;
  }
  a=a-d;
  if(a<=0){
  cout<<"No"<<endl;
  return 0;
  }
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


int main(){
    int N,K;
    cin >>N >>K;


    int x[N];
    //int bp=0;
    FOR(i,N){
        cin >>x[i];
        
    }
    long score=1e9;

    for(int i=0;i<N-K+1;i++){
        long tmp;
        //cout << i <<"~"<<i+K-1<<endl;
        
        if(x[i]<0){
            if(x[i+K-1]<0){
                tmp=abs(x[i]);
            }else{
                tmp=x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1]));
            }
        }else{
            tmp=x[i+K-1];
        }
        //cout<< "tmp"<<tmp<<endl;
        if(tmp<score){
            score=tmp;
        }
    }
    cout <<score<<endl;
    return 0;

    


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count_1 = 0, count_2 = 0;
  cin >> N;
  int A_i;
  cin >> A_i;
  while (A_i > 0) {
    if (A_i % 2 == 0) {
      A_i /= 2;
      count_1++;
    }
    else {
      break;
    }
  }
  for (int i = 0; i < N-1; i++) {
    count_2 = 0;
    cin >> A_i;
    while (A_i > 0) {
      if (A_i % 2 == 0) {
        A_i /= 2;
        count_2++;
      }
      else {
        break;
      }
    }
    if (count_1 > count_2) {
      count_1 = count_2;
    }
  }
  cout << count_1 << endl;
  
}

Measured memory_bytes: 256
from collections import Counter


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


A, B = map(int, input().split())

AP = Counter(prime_factorize(A))
BP = Counter(prime_factorize(B))
comm = AP + BP - (AP - BP) - (BP - AP)

for key in comm.keys():
    comm[key] //= 2

print(len(list(comm.keys())) + 1)


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

int main(void)
{
  int n, k;
  long long int ans = 1;

  cin >> n >> k;
  for (int i = 0; i < n; i++){
    ans *= (i == 0) ? k : k - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class  Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int fiv = 0;
        int sev = 0; //初期値設定
        
        for(int i = 0; i < 3; i++) {
            int num = Integer.parseInt(sc.next());//入力値
            switch(num){ //
            case 5:
                fiv++;
                break;
            case 7:
                sev++;
                break;
            }
        }
        if(fiv == 2 && sev == 1) {
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21716
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

K, N = LI()
A = LI()

tmp = A[0]
tmp += (K - A[-1])

ans = [tmp]
for i in range(N - 1):
    ans.append(A[i+1] - A[i])

ans.sort(reverse=True)

print(sum(ans[1:]))

Measured memory_bytes: 84468
/***
3 3 2
1 2
5 4
9 2
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
struct node{
    int x,h,flag;
   /// int lazy;
}st[maxn];
ll n,d,a;
struct tree{
    ll w,lazy;
}tr[1000005];
bool cmp(node a,node b){
    return a.x<b.x;
}
ll Find(ll s){
    ll l=1,r=n,res=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(st[mid].x<=s) l=mid+1,res=mid;
        else r=mid-1;
    }
    return res;
}
void pushup(ll u){
    tr[u].w=max(tr[u<<1].w,tr[u<<1|1].w);
}
void pushdown(ll u){
    tr[u<<1].w+=tr[u].lazy;
    tr[u<<1|1].w+=tr[u].lazy;
    tr[u<<1].lazy+=tr[u].lazy;
    tr[u<<1|1].lazy+=tr[u].lazy;
    tr[u].lazy=0;
}
void build(ll u,ll l,ll r){
    if(l==r){
        tr[u].w=st[l].h;
        return ;
    }
    ll mid=(l+r)>>1;
    build(u<<1,l,mid);build(u<<1|1,mid+1,r);
    pushup(u);
}
void add(ll x,ll y,ll l,ll r,ll u,ll v){
    if(x<=l&&y>=r){
        tr[u].w+=v;
        tr[u].lazy+=v;
        return ;
    }
    pushdown(u);
    int mid=(l+r)>>1;
    if(x<=mid) add(x,y,l,mid,u<<1,v);
    if(y>mid) add(x,y,mid+1,r,u<<1|1,v);
    pushup(u);
}
ll ask(ll x,ll y,ll l,ll r,ll u){
    if(x<=l&&y>=r) return tr[u].w;
    pushdown(u);
   ll mid=(l+r)>>1;
    ll res=-0x3f3f3f3f;
    if(x<=mid) res=max(res,ask(x,y,l,mid,u<<1));
    if(y>mid) res=max(res,ask(x,y,mid+1,r,u<<1|1));
    return res;
}
void AC(){
    scanf("%lld%lld%lld",&n,&d,&a);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&st[i].x,&st[i].h);
        st[i].flag=0;///表示未被打败
    }
    sort(st+1,st+1+n,cmp);
    ///如果第i个位置上的没有死，就在x[i]+d上放炸弹
    build(1,1,n);
    ///线段树维护每个怪物的血量
    ll i=1;
    ll ans=0;
    while(i<=n){
        ll s=st[i].x+d*2;
        ll id=Find(s);
        ll g=ask(i,i,1,n,1);
        ll ci=(g+a-1)/a;
        ans+=ci;
        add(i,id,1,n,1,-(ci*a));
        ll l=i,r=id,res=i;
        while(l<=r){
            int mid=(l+r)>>1;
            if(ask(i,mid,1,n,1)<=0) l=mid+1,res=mid;
            else r=mid-1;
        }
        i=res+1;
    }
    printf("%lld\n",ans);
}
int main(){
    AC();
    return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint calcNumOfCombination_mint(mint n, mint r){
  mint num = 1;
  for(mint i = 1; i.x <= r.x; i.x++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int x, y;
  cin >> x >> y;
  if((x+y) % 3 != 0){
    cout << 0 << endl;
    return 0;
  }
  int w = (2*x-y)/3, h = (2*y-x)/3;
  if(w < 0 || h < 0){
    cout << 0 << endl;
    return 0;
  }
  cout << calcNumOfCombination_mint(w+h, w).x << endl;
  return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        int cnt = 0;
        int sum = 0;
        int[] inputs = ReadInts();
        int N = inputs[0];
        int M = inputs[1];
        int C = inputs[2];
        int[] B = ReadInts();
        for(int i=0;i<N;i++)
        {
            sum = 0;
            int[] A = ReadInts();
            for(int j = 0;j<M;j++)
            {
                sum += A[j] * B[j];
            }
            sum += C;
            if (sum > 0) cnt++;
        }

        return cnt.ToString();
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = 0;
        if(x >= 1800 && x < 2000) ans = 1;
        else if(x >= 1600 && x < 1800) ans = 2;
        else if(x >= 1400 && x < 1600) ans = 3;
        else if(x >= 1200 && x < 1400) ans = 4;
        else if(x >= 1000 && x < 1800) ans = 5;
        else if(x >=  800 && x < 1000) ans = 6;
        else if(x >=  600 && x <  800) ans = 7;
        else if(x >=  400 && x <  600) ans = 8;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char s[11] = {0};

int main()
{
	int i = 0;
	int len = 0;
	int min = 10000;
	int val = 0;
	scanf("%s", &s[0]);
    len = strlen(s);

	for(i = 0; i < 10; i++) {
        s[i] &= 0x0f;
	}

	for(i = 0; i < (len-2); i++) {
		val = abs(753 - ((s[i] * 100) + (s[i+1] * 10) + (s[i+2])));
		if (val < min) {
			min = val;
		}
	}
    printf("%d",min);
	return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    if(k%2==0){
        cout << a-b << endl;
    }else{
        cout << b-a << endl;
    }

    return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        char c = br.readLine().charAt(0);
        
        out.println(++c);
        out.close();
        
    }
}

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

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
     cin>>a[i];
     sort(a,a+n);
     int k=abs(a[n-1]-a[0]);
     cout<<k;

    return 0;
}


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

#define int long long

int n,a,b,c;
int h[100002];
int p[100002];

bool ck(int mid){

	for(int i=0;i<n;i++){
		p[i]=h[i]-mid*b;
	}
	
	int cnt=0;
	for(int i=0;i<n;i++){
		if(p[i]>0)cnt += p[i]/c;
		if(p[i]>0 && p[i]%c)cnt++;
		if(cnt>mid)return(false);
	}
	if(cnt>mid)return(false);
	return(true);

}

main(){
	cin>>n>>a>>b;
	c=a-b;
	for(int i=0;i<n;i++)scanf(" %d",&h[i]);

	int hage=1000000000;
	int left=1,right=1000000000,mid;
	while(left<=right){
		mid=(left+right)/2;
		if(ck(mid)){
			hage=min(hage,mid);
			right=mid-1;
		}
		else left=mid+1;
		//cout<<mid<<endl;
	}

	cout<<hage<<endl;

}

Measured memory_bytes: 1920
from itertools import accumulate
from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int, input().split()))


# あらかじめ数列から１を引いておく
A = [a - 1 for a in A]

# mod K の累積和を取る
S = [0] + list(accumulate(A))
S = [s % K for s in S]


ans = 0
counter = defaultdict(int)
for i, s in enumerate(S):
    ans += counter[s]  # 過去の出現数を参考に数え上げ

    counter[s] += 1  # 今見たところを追加
    if i - K + 1 >= 0:
        counter[S[i - K + 1]] -= 1  # 条件を見たしうる長さK-1からはみ出たところを取り除く

print(ans)


Measured memory_bytes: 41416
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int a[101010], b[101010];

int main(){
    
    // 1. 入力情報.
    int A, B, M, minA = 202020, minB = 202020;
    scanf("%d %d %d", &A, &B, &M);
    rep(i, A){
        scanf("%d", &a[i]);
        minA = min(minA, a[i]);
    }
    rep(i, B){
        scanf("%d", &b[i]);
        minB = min(minB, b[i]);
    }
    
    // 2. 購入金額の最小値は？
    int ans = minA + minB;
    rep(i, M){
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define maxn 100005
using namespace std;
typedef struct node
{
    int a;
    int b;
} node;
int cmp(node n1,node n2)
{
    return n1.a<n2.a;
}
int main()
{
    int n,k,s;
    cin>>n>>k>>s;
    for(int i=1; i<=n; i++)
        {
            if(i<=k)
                cout<<s;
            else
                {
                    if(s==1)
                        cout<<s+1;
                    else
                      cout<<s-1;
                }

            if(i!=n)
                cout<<" ";
       }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
signed main(){
    int X,Y;
    cin >> X >> Y;
    if((X+Y)%3 != 0 || Y*2 < X || X*2 < Y) {
        cout << 0 << endl;
        return 0;
    }
    int cnt = (X+Y)/3;
    int cnt2 = min(Y-cnt,X-cnt);
    int sum = 1;
    for(int i = cnt; i > cnt-cnt2; i--) {
        sum*=i;
        sum%=mod;
    }
    for(int i = 1; i <= cnt2; i++) {
        sum *= mod_pow(i,mod-2);
        sum %= mod;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;

const int maxn=1e6+100;
const int mo=998244353;


int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<b/c-(a-1)/c;


    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
E = [list(map(int,input().split())) for i in range(q)]
def dfs(l,string):
  if l == n:
    global ans
    ans = max(ans,check(string));return
  for i in range(int(string[-1]),m+1):
    dfs(l+1,(string+[str(i)]).copy())

def check(string):
  global count
  count += 1
  re = 0
  for a,b,c,d in E:
    if int(string[b])-int(string[a]) == c:
      re += d
  # print(string,re)
  return re
dfs(0,[1])
print(ans)
# print(count)

Measured memory_bytes: 78352
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  V<string> s(h); for (int i = 0; i < h; i++) cin >> s[i];
  VV<> a(h - 1);
  auto f = [&](int i, int j) { return s[i][j] == '#'; };
  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (f(i, j) + f(i, j + 1) + f(i + 1, j) + f(i + 1, j + 1) & 1) a[i].push_back(j);
    }
    a[i].push_back(w - 1);
  }
  int res = max(h, w);
  V<V<>::iterator> p(h - 1);
  for (int i = 0; i < h - 1; i++) p[i] = a[i].begin();
  for (int j = 0; j < w - 1; j++) {
    V<> b(h - 1), l(h - 1), r(h - 1);
    for (int i = 0; i < h - 1; i++) {
      while (*p[i] < j) p[i]++;
      b[i] = *p[i] - j + 1;
    }
    stack<int> st;
    for (int i = 0; i < h - 1; i++) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      l[i] = b[i] * (i - (!st.empty() ? st.top() : -1));
      st.push(i);
    }
    stack<int>().swap(st);
    for (int i = h - 2; i >= 0; i--) {
      while (!st.empty() and b[st.top()] >= b[i]) st.pop();
      r[i] = b[i] * ((!st.empty() ? st.top() : h - 1) - i);
      st.push(i);
    }
    for (int i = 0; i < h - 1; i++) res = max(res, l[i] + r[i]);
  }
  cout << res << '\n';
}

Measured memory_bytes: 20352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; ll k; cin >> n >> k;
	string s; cin >> s;
	queue<char> q;
	rep(i, n) {
		q.push(s[i]);
	}
	bool f = false;
	rep(i, 2 * n + 2) {
		if (i == k) {
			rep(i, n) {
				char t = q.front(); q.pop();
				if (f) {
					if (t == 'A')t = 'B';
					else t = 'A';
				}
				cout << t;
			}
			cout << endl;
			break;
		}
		char t = q.front();
		if (!f&&t == 'A') {
			q.front() = 'B';
		}
		else if (f&&t == 'B')q.front() = 'A';
		else if (!f&&t == 'B') {
			f = !f; q.pop(); q.push('B');
		}
		else {
			f = !f; q.pop(); q.push('A');
		}
	}
	if (k >= 2 * n + 2) {
		string out;
		while (!q.empty()) {
			char t = q.front(); q.pop();
			if (f) {
				if (t == 'A')t = 'B';
				else t = 'A';
			}
			out.push_back(t);
		}
		if (k % 2) {
			rep(i, n-1) {
				out[i] = 'A' + ('B' - out[i + 1]);
			}
			out[n - 1] = 'A';
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
cnt = []
for i in range(0, 101):
	cnt.append(0)

while True:
	try:
		n = int(raw_input())
		cnt[n] += 1
	except:
		break

tmp = 0
lst = []
for i in range(1, 101):
	if tmp < cnt[i]:
		tmp = cnt[i]
		lst = [i]
	elif tmp == cnt[i]:
		lst.append(i)

for i in range(0, len(lst)):
	print lst[i]

Measured memory_bytes: 6268
use std::mem::swap;
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    s: usize,
    vw: [(usize, usize); n]
    }
    let mut dp = vec![0; s + 1];
    for i in 0..n {
        let mut prev = vec![0; s + 1];
        swap(&mut prev, &mut dp);
        for j in 0..s + 1{
            let (v, w) = (vw[i].0, vw[i].1);
            if j >= w {
                dp[j] = max(prev[j], dp[j - w] + v);
            } else {
                dp[j] = prev[j];
            }
        }
    }
    let ans = dp[s];
    println!("{}", ans);
}



Measured memory_bytes: 5032
#include <stdio.h>
#include <algorithm>

using namespace std;

void print(char str[],int a,int b){
	for(int i = a; i <= b; i++)	printf("%c",str[i]);
	printf("\n");
}

void replace(char str[],char p[],int a,int b){
	int p_length = b-a+1;
	for(int i = 0; i < p_length;i++) str[a+i] = p[i];
}

void reverse(char str[],int a,int b){
	int left = a,right = b;
	while(left < right){
		swap(str[left++],str[right--]);
	}
}

int main(){



	char str[1001],p[1001],order[8];
	int q,a,b;
	scanf("%s",str);
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%s %d %d",order,&a,&b);
		switch(order[2]){
		case 'i':
			print(str,a,b);
			break;
		case 'v':
			reverse(str,a,b);
			break;
		case 'p':
			scanf("%s",p);
			replace(str,p,a,b);
			break;
		}
	}
}



Measured memory_bytes: 2700
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
string S = "";

int main() {
	scanf("%lld", &N);
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		S[i] = 'A' + (((S[i] - 'A') + N) % 26);
	}
	cout << S;
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256