akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

string S;
int main(){
  cin >> S;
  if (S[0]==S[1] || S[2]==S[1] || S[2]==S[3]){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}

ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r,w;
ll l,ans,sum;
ll num;
ll x[500005],y[500005],z[500005];
bool dame,flag,ok;

int main(){
	cin >> n >> h >> w;
	p((n - h + 1) * (n - w + 1));
	return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ULL;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fll;
const LL M=1e9+7;
const LL maxn=4e5+7;
const double eps=0.00000001;
const double pi=acos(-1);
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<typename T>inline T powMM(T a,T b){T ret=1;for (;b;b>>=1ll,a=a*a%M) if (b&1) ret=1ll*ret*a%M;return ret;}

int cnt[maxn];
int pre;
int ans;
    int n,q;
int A[maxn],B[maxn],C[maxn];
int calc(int t){
    LL ret=0,k=n-1,i;
    REP(i,n){
        while (k>=0&&A[i]+B[k]>=t) k--;
        ret+=(n-1-k);
    }
//    printf("%d:%d\n",t,ret);
    return ret&1;
}
int main(){
    int i,j,k;
    scanf("%d",&n);
    REP(i,n) scanf("%d",&A[i]);
    REP(i,n) scanf("%d",&B[i]);
    sort(A,A+n);sort(B,B+n);
    rREP(j,30){
        int k=lower_bound(A,A+n,1<<(j+1))-A;
        REP(i,n) A[i]%=1<<(j+1);
        merge(A,A+k,A+k,A+n,C);
        REP(i,n) A[i]=C[i];

        k=lower_bound(B,B+n,1<<(j+1))-B;
        REP(i,n) B[i]%=1<<(j+1);
        merge(B,B+k,B+k,B+n,C);
        REP(i,n) B[i]=C[i];
//        REP(i,n) printf("%d ",A[i]);puts("");
//        REP(i,n) printf("%d ",B[i]);puts("");
//        REP(i,n) printf("%d ",C[i]);puts("");
        ans|=(calc(1<<j)^calc(2<<j)^calc(3<<j))<<j;
//        printf("%d\n",ans);
    }printf("%d\n",ans);
}
/*
*/


Measured memory_bytes: 5632
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);
    int[] b = na(n);
    
    int[][] arr = new int[n * 2][2];
    int ptr = 0;
    for (int v : a) {
      arr[ptr ++] = new int[] {v, 0};
    }
    for (int v : b) {
      arr[ptr ++] = new int[] {v, 1};
    }
    Arrays.sort(arr, (o1, o2) -> o1[0] - o2[0]);

    int mod = 1000000000 + 7;
    int[] cnt = new int[2];
    long ret = 1;
    for (int[] v : arr) {
      if (cnt[v[1] ^ 1] > 0) {
        ret *= cnt[v[1] ^ 1];
        cnt[v[1] ^ 1] --;
        ret %= mod;
      } else {
        cnt[v[1]] ++;
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 53600
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1];
	((A + B) % 24).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#ABC130C-RectangleCutting.py

import sys

def main():
    W, H, x, y = list(map(int, sys.stdin.readline().split()))
    print(W*H/2)
    if W/2 == x and H/2 == y:
        print(1)
    else:
        print(0)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
int a[100];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i < N; i++) {
		if (a[i] != a[i - 1]) continue;
		ans++;
		for (int j = 1; j <= 10000; j++) {
			if (j == a[i] || (i + 1 < N && j == a[i + 1])) continue;
			a[i] = j;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n,k,s = mi()
    ans = []
    BIG = 10**9
    if s == BIG:
        for i in range(k):
            ans.append(s)
        for i in range(n-k):
            ans.append(1)
        print(*ans)
    else:
        for i in range(k):
            ans.append(s)
        for i in range(n-k):
            ans.append(BIG)
        print(*ans)
            
    




main()


Measured memory_bytes: 8740
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N,K;
		std::string S;

		cin >> N >> K >> S;

		int count = 0;
		for (int i = 1; i < N; i++) {
			char pre = S[i - 1];
			char now = S[i];
			if (pre == now) count++;
		}
		ll happy = count;

		happy += 2 * K;


		cout << MIN(happy, N-1) << '\n';

		return 0;
	}



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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  	const int mod = 1e9 + 7;
	string st;
	cin >> st;
	int n = st.size();
	long long e[n], s[n], l[n];
	if (st[ n - 1] == '0') {
		e[n - 1] = 1;
		s[n - 1] = 0;
		l[n - 1] = 2;
	}
	else {
		e[n - 1] = 2;
		s[n - 1] = 1;
		l[n - 1] = 0;
	}
	for (int i = n - 2; i >= 0; i--) {
		if (st[i] == '0') {
			e[i] = e[i + 1];
			s[i] = s[i + 1];
			l[i] = 2 * e[i + 1] + 2 * s[i + 1] + 3 * l[i + 1];
		}
		else {
			e[i] = 2 * e[i + 1];
			s[i] = e[i + 1] + 3 * s[i + 1] + l[i + 1];
			l[i] = 2 * l[i + 1];
		}
		e[i] %= mod;
		s[i] %= mod;
		l[i] %= mod;
	}
	cout << (e[0] + s[0]) % mod << '\n';
	return 0;
}

Measured memory_bytes: 6124
// Problem : F - Division or Substraction
// Contest : AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//QWsin
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

int main()
{
	ll n;cin>>n;
	if(n==2){
		cout<<1<<endl;
		return 0;
	}
	ll sz=sqrt(n);
	int sum=0;
	for(ll k=2;k<=sz;++k)
	{
		ll t=n;
		while(t%k==0) t/=k;
		if(t%k==1) {
			++sum;
			// cout<<k<<endl;		
		}
	}
	ll sz2=sqrt(n-1);
	for(ll k=2;k<=sz2;++k) if((n-1)%k==0) {
		if(k>sz) ++sum;
		if((n-1)/k>sz)	++sum;
	}
	cout<<sum+2<<endl;
	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll gcd(ll x,ll y){
  return y? gcd(y,x%y):x;
}

template <typename M>
struct SegmentTree{
    using T = typename M::T;
    int n;
    vector<T> dat;
    SegmentTree(){}
    SegmentTree(int n_){init(n_);}
    SegmentTree(const vector<T> &v){build(v);}
    void init(int n_){
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,M::ti());
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=M::f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void set_val(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=M::f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    //[a,b)
    T query(int a,int b,int k=1,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l) return M::ti();
        if(a<=l&&r<=b) return dat[k];
        T vl=query(a,b,k*2,l,(l+r)/2);
        T vr=query(a,b,k*2+1,(l+r)/2,r);
        return M::f(vl,vr);
    }
    T operator[](const int &k) const {return dat[k + n];}
};

struct RgcdQ{
  using T=ll;
    static T ti() { return 0; }
    static T f(const T& l, const T & r) { return gcd(l, r); }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  vll A(N);
  for(ll i=0;i<N;i++){
    cin>>A[i];
  }
  SegmentTree<RgcdQ> seg(A);
  ll ans = 0;
  for(ll i=0;i<N;i++){
    seg.set_val(i,0);
    ans = max(ans,seg.query(0,N));
    seg.set_val(i,A[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  ll x = count(all(s), 'x');

  string r = s;
  reverse(all(r));

  ll ans = -1;

  string ns = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'x') {
      ns += s[i];
    }
  }

  string rs = ns;
  reverse(all(rs));

  if (ns == rs) {
    ll len = (ns.size() + 1) / 2;
    vector<ll> cf(len), cb(len);

    int cfi = 0;
    for (int j = 0; j < s.size(); j++) {
      if (cfi >= len) break;
      if (s[j] == 'x') {
        cf[cfi]++;
      } else {
        cfi++;
      }
    }

    int cbi = 0;
    for (int j = s.size() - 1; j >= 0; j--) {
      if (cbi >= len) break;
      if (s[j] == 'x') {
        cb[cbi]++;
      } else {
        cbi++;
      }
    }

    ans = 0;
    for (int i = 0; i < len; i++) {
      ans += abs(cf[i] - cb[i]);
    }
  }

  if (s == r) {
    ans = 0;
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 1488
package main;import . "fmt";func main(){var n,q,i,j int;var k int64;Scan(&n,&q);p:=[]int64{0,int64(n)};for i=0;i<q;i++{Scan(&k);j=len(p);for k<=p[j-1]{j--};p=append(p[:j],k)};q=len(p)-1;t:=make([]int64,q+1);t[q]=1;a:=make([]int64,n+2);for i=q;i>0;i--{j,k=i,p[i];for k>p[1]{l,r:=1,j;for r-l>1{m:=(l+r)/2;if p[m]>k{r=m}else{l=m}};j=l;t[j]+=k/p[j]*t[i];k%=p[j]};a[k]+=t[i]};for i=n;i>0;i--{a[i]+=a[i+1]};for i=1;i<=n;i++{Println(a[i])}}

Measured memory_bytes: 8064
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	二分答案!
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
	分析样例：奇数or偶数
	偶数
	线段离散化
	make_pair 慢
	坐标离散化
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL (long long)
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	string s;
	int len;
	cin>>len>>s;
	int a=0,b=0;
	int tmpres=0;
	rb(i,1,len){
		int loca=i-1;
		if(s[loca]=='(') tmpres++;
		else tmpres--;
		if(tmpres<0){
			tmpres=0;
			a++;
		}
	}
	b=tmpres;
	rb(i,1,a) printf("(");
	cout<<s;
	rb(i,1,b) printf(")");
	return 0;
}

Measured memory_bytes: 256
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
if a_ls[m-1] < sum(a_ls) / 4 / m:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;

class AOJ0525{
private:
  int r,c,mex;
  bool **preserve;
  int *rows;
  bool *revs;
  map<string,bool> used;
public:
  AOJ0525(int r,int c):r(r),c(c){
    preserve = new bool*[r];
    rep(i,r)
      *(preserve+i) = new bool[c];
    rows = new int[c];
    revs = new bool[r];
    rep(i,c)rows[i] = 0;
    rep(i,r)revs[i] = false;
    mex = 0;
    used.clear();
  }

  ~AOJ0525(){
    delete [] preserve[0];
    delete [] preserve;
    delete [] rows;
  }

  void input(){

    rep(i,r){
      rep(j,c){
	cin >> *(*(preserve+i)+j);
	if(!preserve[i][j])rows[j]++;
      }
    }

  }

  void run(){
    input();
    rec(0);
    cout << mex << endl;
  }

  void check(){
    int total = 0;
    int comp = r%2 == 0?r/2:(int)(r/2)+1;
    rep(i,c){
      if(rows[i] < comp)total += r-rows[i];
      else total += rows[i];
    }

    mex = max(mex,total);
  }


  void print(){
    rep(i,r){
      rep(j,c){
	cout << preserve[i][j] << ' ';
      }
      cout << endl;
    }
    cout << endl;
  }

  void rev(int rc){
    
    rep(i,c){
      //preserve[rc][i] = preserve[rc][i]?(!preserve[rc][i]):preserve[rc][i];
      if(preserve[rc][i])preserve[rc][i] = false,rows[i]++;
      else preserve[rc][i] = true,rows[i]--;
    }
    
  }

  string bts(){
    stringstream ss;
    rep(i,r)
      ss << revs[i];
    return ss.str();
  }


  void rec(int st){
    if(st == r)return;
    string s = bts();
    if(used[s])return;
    used[s] = true;
    for(int i=st;i<r;i++){
    
      check();
      rec(i+1);
      rev(i);
      revs[i] = true;
      check();
      rec(i+1);
      revs[i] = false; 
      rev(i);

    }
    return;
  }

 


};


int main(){

  while(true){
    int c,r;
    //clock_t st,ed;
    //st = clock();
    cin >> r >> c;
    if(r+c == 0)break;
    AOJ0525 ans = AOJ0525(r,c);
    ans.run();
    //ed = clock();
    //cout << setiosflags(ios::fixed) << setprecision(3) << (double)(ed-st)/CLOCKS_PER_SEC << endl;
  }
return 0;
}

Measured memory_bytes: 1472
X, N = list(map(int, input().strip().split()))
l = list(map(int, input().strip().split()))
l = sorted(l, reverse = False)

rslt = 200

#自明なパターン
if N == 0: rslt = X
if N != 0:
  if l[0] > X: rslt = X
  elif l[-1] < X: rslt = X
  elif (l[0]<=X) and (l[-1]>=X):
    e_min = int(l[0]-1)
    e_max = int(l[-1]+1)
    e_l = [i for i in range(e_min, e_max+1) if i not in l]
    for n in e_l[::-1]:
      if abs(X-n) <= abs(X - rslt): rslt = n
  
print(rslt)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll H,W,N=0;
  cin >> H >> W;
  vector<vector<ll>> A(H,vector<ll>(W)),ans(H*W,vector<ll>(4));
  rep(i,H)rep(j,W) cin >> A.at(i).at(j);
  rep(i,H){
    if(i%2==0){
      rep(j,W){
        if(A.at(i).at(j)%2==1){
          A.at(i).at(j)--;
          if(j!=W-1){
            A.at(i).at(j+1)++;
            ans.at(N).at(0)=i+1;
            ans.at(N).at(1)=j+1;
            ans.at(N).at(2)=i+1;
            ans.at(N).at(3)=j+2;
            N++;
          }else if(i!=H-1){
            A.at(i+1).at(j)++;
            ans.at(N).at(0)=i+1;
            ans.at(N).at(1)=j+1;
            ans.at(N).at(2)=i+2;
            ans.at(N).at(3)=j+1;
            N++;
          }
        }
      }
    }else{
      rep(j,W){
        if(A.at(i).at(W-j-1)%2==1){
          A.at(i).at(W-j-1)--;
          if(j!=W-1){
            A.at(i).at(W-j-2)++;
            ans.at(N).at(0)=i+1;
            ans.at(N).at(1)=W-j;
            ans.at(N).at(2)=i+1;
            ans.at(N).at(3)=W-j-1;
            N++;
          }else if(i!=H-1){
            A.at(i+1).at(W-j-1)++;
            ans.at(N).at(0)=i+1;
            ans.at(N).at(1)=W-j;
            ans.at(N).at(2)=i+2;
            ans.at(N).at(3)=W-j;
            N++;
          }
        }
      }
    }
  }
  cout << N << endl;
  rep(i,N){
    cout << ans.at(i).at(0) << " " << ans.at(i).at(1) << " " << ans.at(i).at(2) << " " << ans.at(i).at(3) << endl;
  }
  

}


Measured memory_bytes: 22016
n = int(input())
h = list(map(int, input().split()))
ans = 0
while sum(h) != 0:
    left = float("inf")
    right = float("inf")
    for i in range(n):
        if h[i] > 0:
            left = i
            break
    for j in range(i + 1, n):
        if h[j] <= 0:
            right = j
            break
    if right == float("inf"):
        right = n
    for i in range(left, right):
        h[i] -= 1
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	int S,W;
	cin>>S>>W;
	if(S<=W){
		cout<<"unsafe"<<endl;
	}else{
		cout<<"safe"<<endl;
	}
}

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

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";
    ans += string(ty - sy, 'U');
    ans += string(tx - sx, 'R');
    ans += string(ty - sy, 'D');
    ans += string(tx - sx + 1, 'L');
    ans += string(ty - sy + 1, 'U');
    ans += string(tx - sx + 1, 'R');
    ans += "DR";
    ans += string(ty - sy + 1, 'D');
    ans += string(tx - sx + 1, 'L');
    ans += 'U';

    cout << ans << endl;

    return 0;
}

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

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

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  ll n;
  ll a[5];
  cin >> n;
  REP(i, 5) cin >> a[i];
  sort(a, a+5);
  cout << (n-1)/a[0] + 5 << endl;
  return 0;
}

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

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

    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  double t = sc.nextDouble();
  double a = sc.nextDouble();
  double min = 1000000;
  int ans = 0;
  for(int i = 0;i < n;i++){
    int h = sc.nextInt();
    double tmp = Math.abs(a - (t - h*(0.006)));
    if(tmp < min){
      min = tmp;
      ans = i+1;
    }
  }
  System.out.println(ans);
}}


Measured memory_bytes: 25172
from copy import deepcopy

n, m = [int(i) for i in input().split()]
es = [[int(j) for j in input().split()] for i in range(m)]

x = [float('-inf')] * (n+1)
x[1] = 0

for i in range(n):
    for a, b, c in es:
        x[b] = max(x[b], x[a]+c)

xcp = deepcopy(x)
prevxn = x[n]
for a, b, c in es:
        x[b] = max(x[b], x[a]+c)

if prevxn != x[n]:
    print('inf')
else:
    print(x[n])

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
 
const int maxn = 1e5 + 5;
bitset<160*176> B[80][80];
int dif = 80 * 176;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int cnt[n][m] = {};
    f (n) {
        fr (j, 0, m) {
            cin >> cnt[i][j];
        }
    }
    f (n) {
        fr (j, 0, m) {
            int x;
            cin >> x;
            cnt[i][j] -= x;
        }
    }
    B[0][0][cnt[0][0] + dif] = 1;
    for (int i = 1 ; i < n ; i++) {
        B[i][0] |= B[i-1][0] << abs(cnt[i][0]);
        B[i][0] |= B[i-1][0] >> abs(cnt[i][0]);
    }
    for (int i = 1 ; i < m ; i++) {
        B[0][i] |= B[0][i-1] << abs(cnt[0][i]);
        B[0][i] |= B[0][i-1] >> abs(cnt[0][i]);
    }
    f1 (n-1) {
        fr (j, 1, m) {
            B[i][j] |= B[i-1][j] << abs(cnt[i][j]);
            B[i][j] |= B[i-1][j] >> abs(cnt[i][j]);
            B[i][j] |= B[i][j-1] << abs(cnt[i][j]);
            B[i][j] |= B[i][j-1] >> abs(cnt[i][j]);
        }
    }
    int ans = 1e7;
    f(160*176) {
        if (B[n-1][m-1][i] == 1) {
            ans = min(ans, abs(i-dif));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 22272
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,isPoor=0;
  cin >> a >> b >> c;
  
  if(a==b && b!=c)
    isPoor = 1;
  if(b==c && c!=a)
    isPoor = 1;
  if(c==a && a!=b)
    isPoor = 1;
  
  if(isPoor)
    cout << "Yes";
  else
    cout << "No";
  
}

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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

ll x, cur = 100, t;

int main()
{
	cin >> x;
	while (cur < x)
	{
		cur += cur / 100;
		t++;
	}
	cout << t;
	return 0;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct Stack {
	int top;
	int a[1000000];
	Stack() {
		top = 0;
		memset(a, 0, sizeof(a));
	}
	void push(int x) {
		a[top++] = x;
	}
	int pop() {
		return a[top-- - 1];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	static Stack x;
	while (cin >> s) {
		if (s == "+") {
			int a = x.pop();
			int b = x.pop();
			x.push(a + b);
		}
		else if (s == "*") {
			int a = x.pop();
			int b = x.pop();
			x.push(a*b);
		}
		else if (s == "-") {
			int a = x.pop();
			int b = x.pop();
			x.push(b - a);
		}
		else x.push(stoi(s));
	}
	cout << x.pop() << endl;
	return 0;
}

Measured memory_bytes: 7052
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		
		int total = 0, not_jp = 0;
		for(final char ch : sc.next().toCharArray()){
			if(ch == 'a'){
				if(total < (A + B)){
					total++;
					System.out.println("Yes");
				}else{
					System.out.println("No");
				}
			}else if(ch == 'b'){
				if(total < (A + B) && not_jp < B){
					total++;
					not_jp++;
					System.out.println("Yes");
				}else{
					System.out.println("No");
				}
			}else{
				System.out.println("No");
			}
		}
		
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21368
def f(d,x,y):n=int("9"*x+"0"*y);return d==0 if x<1 else sum(f(d-i*n,x-2,y+1)*(10-abs(i)-(y<1))for i in range(-9,10)if abs(d-i*n)<n)
D=input();print sum(f(D,i,0)*(10-i%2*9)for i in range(1,21))


Measured memory_bytes: 2568
def main():
    n = int(input())
    if n == 0:
        print("Yes")
        return
    slup = []
    sldown = []
    for i in range(n):
        height, mi = 0, 0
        for si in input():
            if si == "(":
                height += 1
            else:
                height -= 1
                mi = min(mi, height)
        if height >= 0:
            slup.append([mi, height])
        else:
            sldown.append([mi-height, -height])

    slup.sort(reverse=True)
    sldown.sort(reverse=True)
    if sum([si[1] for si in slup]) + sum([-si[1] for si in sldown]):
        print("No")
        return
    h = 0
    for si in slup:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    h = 0
    for si in sldown:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    print("Yes")
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 247960
import sys
sys.setrecursionlimit(10 ** 7)

N, M = [int(_) for _ in input().split()]
A = [int(input()) for i in range(M)]
isBroken = [False] * (N + 1)
for i in A:
    isBroken[i] = True


def solve():

    # It's impossible
    if M >= 1:
        temp = A[0]
        for a in A[1:]:
            if a - 1 == temp:
                return 0
            temp = a

    # We can
    memo = [0] * (N + 2)

    def rec(i):
        if i == 0:
            return 1
        if i < 0:
            return 0
        if isBroken[i]:
            return 0

        if memo[i] == 0:
            count1 = rec(i - 1) % 1000000007
            count2 = rec(i - 2) % 1000000007
            memo[i] = (count1 + count2) % 1000000007
        return memo[i]
    return rec(N)


print(solve())


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> str(H + 2);
  for(int i = 0; i < (H + 2); i++){
    if(i == 0 || i == H + 1){
      for(int j = 0; j < W; j++)
      str.at(i) += '#';
    }
    else
      cin >> str.at(i);
   cout << '#' << str.at(i) << '#' << endl; 
  }
}

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

int n, a[100001], f[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    f[1]=0; f[2]=abs(a[2]-a[1]);
    for (int i = 3; i <= n; i++)
    {
        f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    }
    cout << f[n];
    return 0;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int a,b,c;
  cin>>b>>c>>a;
  cout<<(b<=a&&a<=c?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,=pin()
    An=lispin()
    count_An=dict(Counter(An))
    S=sum(An)
    Q,=pin()
    erachan=0
    for i in range(Q):
        a,b=pin()
        temp=0
        try:
            temp=count_An[a]
            count_An[a]=0
            count_An.setdefault(b,0)
            count_An[b]+=temp
        except KeyError:erachan+=1
        S=S+(b-a)*temp
        print(S)
        
#%%submit!
resolve()

Measured memory_bytes: 94552
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	ll ans = K;

	for(int i = 0; i < N-1; i++){
		ans *= K;
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}




Measured memory_bytes: 3212
from itertools import*
n,*a=map(int,open(0).read().split())
acc=list(accumulate(sorted(a)))[::-1]
c=1
i=0
while i<n-1:
  if acc[i]-acc[i+1]<=acc[i+1]*2:
    c+=1
    i+=1
  else:
    break
print(c)

Measured memory_bytes: 14484
#include<iostream>
using namespace std;
// 5
// H4 C9 S4 D2 C3

struct Card {char suit,value; };

void bubbleSort(struct Card A[],int N ){
    for(int i=0;i<N-1;i++){
        for(int j=N-1;j>i;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j]; A[j]=A[j-1]; A[j-1]= t;
            }
        }
    }

}


void selectionSort(struct Card A[],int N){
    int min,minj;
    for(int i=0; i<N; i++){
        min=A[i].value;
        minj = i;
        for(int j=i+1; j<N; j++){
            if(A[j].value<min){
                min = A[j].value;
                minj = j;
            }
        }
        if(minj != i){
            Card t = A[i];
            A[i]= A[minj];
            A[minj]= t;
        }
    }

}

void print(struct Card A[],int N){
    for(int i=0; i < N; i++){
        if(i>0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i =0; i < N ;i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    char ch;

    cin >> N;
    for( int i=0; i<N;i++){
        cin >> C1[i].suit >>C1[i].value;
    }
    
    for( int i = 0; i < N; i++) C2[i] = C1[i]; 
    bubbleSort(C1,N);
    selectionSort(C2,N);
    print(C1,N);
    cout << "Stable" << endl;

    print(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;

    }
    else{
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
N=int(input())
ans=N
for i in range(N+1):
    cnt=0 #カウント初期化
    t=i
    while t>0:    #tが正の時，カウントにtを6で割ったあまりを足す．そしてtは6で割った商に更新
        cnt+=t%6
        t//=6
    j=N-i #jにn-iを代入
    while j>0:
        cnt+=j%9
        j//=9
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 41012
import Data.Foldable (for_)
import Data.Functor ((<$>))

main = do
  xs <- takeWhile (\[_, op, _] -> op /= "?") . map words . lines <$> getContents
  for_ xs $ \[a', op, b'] ->
    let a = read a' :: Int
        b = read b' :: Int
    in case op of
      "+" -> print $ a + b
      "-" -> print $ a - b
      "*" -> print $ a * b
      "/" -> print $ a `div` b



Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353

int main()
{
    int n;cin>>n;
    vector<int> d(n);
    int i,j;
    long long ans=1;
    for(i=0;i<n;i++)cin>>d.at(i);
    vector<long long> count(n,0);
    int max=-1;
    for(i=0;i<n;i++)
    {
        count.at(d.at(i))++;
        if(d.at(i)>max)max=d.at(i);
    }
    if(count.at(0)!=1||d.at(0)!=0)ans=0;
    else
    {
        for(i=1;i<=max;i++)
        {
            for(j=0;j<count.at(i);j++)
            {
                ans=(ans*count.at(i-1))%MOD;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
N, Ma, Mb = map(int, input().split())
dp = [{} for i in range(N+1)]
dp[0][(0, 0)] = 0
for i in range(N):
  a, b, c = map(int, input().split())
  for p, q in dp[i]:
    if (p, q) not in dp[i+1]: dp[i+1][(p, q)] = 100000
    dp[i+1][(p, q)] = min(dp[i+1][(p, q)], dp[i][(p, q)])
    if (p+a, q+b) not in dp[i+1]: dp[i+1][(p+a, q+b)] = 100000
    dp[i+1][(p+a, q+b)] = min(dp[i+1][(p+a, q+b)], dp[i][(p, q)]+c)
#print(dp[N])
rs = []
for k in range(1, 10000):
  if (k*Ma, k*Mb) in dp[N]:
    r = dp[N][(k*Ma, k*Mb)]
    rs.append(r)
if len(rs) == 0:
  print(-1)
else:
  r = min(rs)
  print(r)


Measured memory_bytes: 39896
n = int(input())
s = input()
alph = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

cnt = 0
for i in range(n):
    prev = s[:i]
    subseq = s[i:]
    inner_cnt = 0
    for j in alph:
        if j in prev and j in subseq:
            inner_cnt += 1
    if inner_cnt > cnt:
        cnt = inner_cnt
print(cnt)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=510;
int dp[maxn][maxn],a[maxn][maxn];
int n,m,q;
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	while(m--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		a[l][r]++;
	}
	for(int l=n;l>=1;l--)
	{
		for(int r=1;r<=n;++r)
		{
			dp[l][r]=dp[l+1][r]+dp[l][r-1]-dp[l+1][r-1]+a[l][r];
		}
	}
	while(q--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",dp[l][r]);
	}
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long
#define fio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
ll mod = 1e9+7;
using namespace std;
ll dp[100005], h[100005];
int n, k;
ll mx = 1e15;
ll fun(int i)
{
	if(dp[i] != -1)
		return dp[i];
	dp[i] = mx;
	for(int j=1;j<=k&&i+j<n;j++)
		dp[i] = min(dp[i], fun(i+j) + abs(h[i]-h[j+i]));
	
	if(dp[i] == mx)
		dp[i] = 0;
	return dp[i];
}
int main()
{
	// int n;
	// cin>>n;
	// vector<int> v(n+5);
	// for(int i=1;i<=n;i++)
	// 	cin>>v[i];
	// int cnt = 0;
	// vector<int> ans;
	// for(int i=1;i<=n;i++)
	// {
	// 	if(v[i] == i)
	// 	{
	// 		cnt++;
	// 		ans.pb(i);
	// 	}
	// }
	// for(int i=0;i<ans.size()-1;i++)
	// {
	// 	for(int j=ans[i];j<=ans[i+1];j++)
	// 	{
	// 		if(v[j]>ans[i+1])
	// 		{
	// 			cnt--;
	// 			break;
	// 		}
	// 	}
	// }

	// cout<<cnt;
	memset(dp, -1, sizeof(dp));
	cin>>n>>k;
	for(int i=0;i<n;i++)
		 cin>>h[i];
	cout<<fun(0);

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>x>>k>>d;
    if(x>0)
    {
        n=x/d;
        a=x-(min(k,n)*d);
        k-=min(k,n);
    }
    else
    {
        n=x/d;
        a=x+(min(k,abs(n))*abs(d));
        k-=min(k,abs(n));
    }
    if(k%2)cout<<min(abs(a-d),abs(a+d))<<endl;
    else cout<<abs(a)<<endl;
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 500001;
const int M = 1 << 20;

int a[N], p[N], dp[M], cdp[M], z[N], l[M];

int main()
{
	fio;
	int n;
	cin >> n;
	for(int i=1; i<=n; i++)
		cin >> a[i];
	for(int i=1; i<=n; i++)
	{
		p[i] = p[i-1] ^ a[i];
		z[i] = z[i-1];
		int v = p[i];
		if(v == 0)
			z[i]++;
		else if(l[v] == 0)
			dp[v] = cdp[v] = 1;
		else
		{
			int zs = z[i] - z[l[v]];
			dp[v] = (cdp[v] * 1ll * zs + dp[v]) % MOD;
			cdp[v] = (dp[v] + cdp[v]) % MOD;
		}
		l[v] = i;
	}
	int ans = 0;
	if(p[n] == 0)
	{
		for(int i=1; i<M; i++)
			ans = (ans + cdp[i]) % MOD;
		int t = 1;
		for(int i=1; i<z[n]; i++)
			t = (t << 1) % MOD;
		ans = (ans + t) % MOD;
	}
	else
		ans = dp[p[n]];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 18432
S = gets.chomp
T = gets.chomp

# $stdout = File.open(File::NULL, "w")

def main
  t = S.length - T.length + 1
  min = S.length
  t.times.each do |s|
    count = 0
    T.chars.each.with_index do |c, i|
      if S[s + i] != c
        count += 1
      end
    end
    if count < min
      min = count
    end
  end
  return min
end

STDOUT.puts main


Measured memory_bytes: 14316
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n,m=map(int,input().split())
ks=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
ans=0

for i in range(2**n):
    ol=[0]*n
    cntt=0
    for j in range(n):
        if ((i>>j)&1):
            ol[j]=1
    #print(ol)
    for k in range(m):
        cnt=0
        for j in range(ks[k][0]):
            if ol[ks[k][j+1]-1]==1:
                cnt+=1
        
        if cnt%2==p[k]:
            cntt+=1
            #print(ks[k],p[k],cnt)
    if cntt==m:
        ans+=1
        #print(ol)
print(ans)

Measured memory_bytes: 3064