akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Complex{
    double r,i;
    Complex(double r,double i):r(r),i(i){}
    Complex(){}
	inline Complex operator + ( const Complex& rhs )  const  {
		return Complex ( r + rhs.r, i + rhs.i ) ;
	}
	inline Complex operator - ( const Complex& rhs )  const  {
		return Complex ( r - rhs.r, i - rhs.i ) ;
	}
	inline Complex operator * ( const Complex& rhs )  const  {
		return Complex ( r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r ) ;
	}
	inline void operator /= ( const double& x )   {
		r /= x, i /= x ;
	}
	inline void operator *= ( const Complex& rhs )   {
		*this = Complex ( r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r ) ;
	}
	inline void operator += ( const Complex& rhs )   {
		r += rhs.r, i += rhs.i ;
	}
};

const int maxn=4e6+6;
#define PI 3.14159265354
int pos[maxn];
void init ( const int& n )  {
    for ( int i = 0 ,j=0; i < n ; ++ i )  {
        pos[i]=j;for (int l = n >> 1; (j ^= l) < l; l >>= 1);
    }
}

void transform ( Complex *a, const int& n, bool inverse ) {
    for ( int i = 0; i < n ; ++ i ){
        if (i > pos[i]) std ::swap(a[i], a[pos[i]]);
    }

    for ( int l = 2 ; l <= n ; l <<= 1 )  {
        int m = l / 2;Complex omega={cos(2*PI/l),inverse?-sin(2*PI/l):sin(2*PI/l)};
        for ( Complex *p = a ; p != a + n ; p += l )  {
            Complex x={1,0};
            for ( int i = 0 ; i < m ; ++ i ,x *= omega)  {
                Complex t = x  * p [m + i] ;
                p [m + i] = p [i] - t ;p [i] += t ;
            }
        }
    }
}

void dft ( Complex *a, const int& n )  {
    transform ( a, n, 0 ) ;
}

void idft ( Complex *a, const int& n )  {
    transform ( a, n, 1) ;
    for ( int i = 0 ; i < n ; ++ i ) a [i] /= n ;
}
Complex A[maxn],B[maxn],C[maxn];
void FFT(int n,int m) {// len(A),len(B)
    int cnt=1;while(cnt<=(n+m)) cnt<<=1;
    init(cnt);dft(A,cnt);dft(B,cnt);
    for(int i=0;i<cnt;i++) C[i]=A[i]*B[i];
    idft(C,cnt);
    // for(int i=0;i<=n+m;i++) C[i].r=ll(C[i].r+0.3);
}
const int mod=200003;
const int g=2;
std::vector<ll> pw(mod),rev(mod);
int main(){
	ll now=1;pw[0]=1;rev[1]=0;
	for(int i=1;i<mod-1;i++) {
		now=now*g%mod;pw[i]=now;
		rev[now]=i;
	}
	int n;cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++) {
		ll tem;cin>>tem;
		if(tem==0) continue;
		ans-=tem*tem%mod;
		A[rev[tem]].r+=1;
		B[rev[tem]].r+=1;
	}
	FFT(mod,mod);	
	for(int i=0;i<=2*mod;i++) {
		ll x=ll(C[i].r+0.3);
		ans+=pw[i%(mod-1)]*x;
	}
	cout<<ans/2<<endl;
}


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector <ll> a(n);
    for (ll &it : a) cin >> it;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = int(1e5 + 10);
vector< int > adj[N];
int marked[N];

void dfs(int u){
	marked[u] = 1;

	for(int i = 0 ; i < adj[u].size() ; i++){
		int v = adj[u][i];

		if(!marked[v]){
			dfs(v);
		}
	}
}

int main(){
	int n, m;

	scanf("%d %d", &n, &m);

	for(int i = 0 ; i < m ; i++){
		int ui, vi, wi;

		scanf("%d %d %d", &ui, &vi, &wi);

		adj[ui].push_back(vi);
		adj[vi].push_back(ui);
	}

	int ask = 0;

	for(int i = 1 ; i <= n ; i++){
		if(!marked[i]){
			ask++;
			dfs(i);
		}
	}

	cout << ask << endl;
	
	return 0;
}

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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int x;
    cin >> x;
    cout << x * 32 << endl;

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




Measured memory_bytes: 3092
#include <iostream>
using namespace std;
typedef long long ll;
int mod = 1e9+7;

int main() {
	ll H;
	cin >> H;

	ll atkCnt = 0;
	ll enmCnt = 1;
	ll enmHP = H;

	while (enmHP > 0) {
		atkCnt += enmCnt;
		enmCnt *= 2;
		enmHP /= 2;
	}

	cout << atkCnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int x = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			int s = Integer.parseInt(sc.next());
			if (x == 0 && y == 0 && s == 0) break;
			int max = 0;
			for (int i = 1; i < s; i++) {
				for (int j = 1; j < s; j++) {
					if (i * (100 + x) / 100 + j * (100 + x) / 100 != s) continue;
					max = Math.max(max, i * (100 + y) / 100 + j * (100 + y) / 100);
				}
			}
			System.out.println(max);
		}
	}
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

template<typename T> 
struct BIT {
	vector<T> dat;

	BIT (int n) { dat.assign(n+1, 0); }

	void add(int k, T x) {
		for (++k; k < dat.size(); k += k & -k) dat[k] += x;
	}

	T query(int k) {
		T sum = 0;
		for (++k; k > 0; k -= k & -k) sum += dat[k];
		return (sum);
	}

	int lower_bound(T x) {
		int l, r;
		l = -1, r = dat.size();
		while (l + 1 < r) {
			int m = (l + r) / 2;
			if (query(m) >= x) r = m;
			else l = m;
		}
		return (r);
	}
};

void Main() {
	int N; cin >> N;
	vector<BIT<int>> tree(26, BIT<int>(N+1));
	string S; cin >> S;
	for (int i = 0; i < N; i++) {
		tree[S[i]-'a'].add(i, 1);
	}
	int Q;
	cin >> Q;
	while (Q--) {
		int a; cin >> a;
		if (a == 1) {
			int i;
			char c;
			cin >> i >> c; --i;
			tree[S[i]-'a'].add(i, -1);
			S[i] = c;
			tree[S[i]-'a'].add(i, 1);
		} else {
			int l, r;
			cin >> l >> r; --r, --l;
			int cnt = 0;
			for (int i = 0; i < 26; i++) {
				int num = tree[i].query(r);
				if (l > 0) num -= tree[i].query(l-1);
				if (num > 0) cnt++;
			}
			cout << cnt << el;
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b, c, k; cin >> a >> b >> c >> k;
    int cnt = 0;
    while(a>=b){cnt++; b*=2;}
    while(b>=c){cnt++; c*=2;}

    if(cnt<=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int MOD = 924844033, G = 5, N = 600000;
int rev[N];
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
void prework(int n) {
  rev[0] = 0;
  for (int i = 1 ; i < n ; ++ i)
    if (i&1) rev[i] = rev[i-1] | (n >> 1);
    else rev[i] = rev[i>>1] >> 1;
}
void dft(int* a,int n,int sgn) {
  for (int i = 0 ; i < n ; ++ i)
    if (i < rev[i]) swap(a[i],a[rev[i]]);
  int w,wp,u,v;
  for (int s = 2 ; s <= n ; s <<= 1) {
    wp = power(G,(MOD-1) / s);
    if (sgn) wp = power(wp,MOD-2);
    for (int k = 0 ; k < n ; k += s) {
      w = 1;
      for (int j = k ; j < k + (s >> 1) ; ++ j) {
	u = a[j];
	v = 1ll * w * a[j + (s >> 1)] % MOD;
	a[j] = u + v;
	if (a[j] >= MOD) a[j] -= MOD;
	a[j + (s >> 1)] = u - v + MOD;
	if (a[j + (s >> 1)] >= MOD) a[j + (s >> 1)] -= MOD;
	w = 1ll * w * wp % MOD;
      }
    }
  }
  if (sgn) {
    wp = power(n,MOD-2);
    for (int i = 0 ; i < n ; ++ i)
      a[i] = 1ll * a[i] * wp % MOD;
  }
}
int n,sz[N],jc[N],inv[N],a[N],b[N];
struct edge {
  int la,b;
} con[N];
int tot,fir[N];
void add(int from,int to) {
  con[++tot] = (edge) {fir[from],to};
  fir[from] = tot;
}
void dfs(int pos,int fa) {
  sz[pos] = 1;
  for (int i = fir[pos] ; i ; i = con[i].la) {
    if (con[i].b == fa) continue;
    dfs(con[i].b,pos);
    sz[pos] += sz[con[i].b];
    a[sz[con[i].b]] --;
  }
  a[n - sz[pos]] --;
  a[n] ++;
}
int main() {
  int x,y;
  scanf("%d",&n);
  for (int i = 1 ; i < n ; ++ i) {
    scanf("%d%d",&x,&y);
    add(x,y);
    add(y,x);
  }
  jc[0] = 1;
  for (int i = 1 ; i <= n ; ++ i)
    jc[i] = 1ll * jc[i-1] * i % MOD;
  inv[n] = power(jc[n],MOD-2);
  for (int i = n - 1 ; i >= 0 ; -- i)
    inv[i] = 1ll * inv[i+1] * (i+1) % MOD;
  dfs(1,0);
  for (int i = 0 ; i <= n ; ++ i)
    a[i] = 1ll * (a[i] + MOD) % MOD * jc[i] % MOD;
  for (int i = 0 ; i <= n ; ++ i)
    b[i] = inv[n-i];
  int l = 1;
  while (l < n + n + 2) l <<= 1;
  prework(l);
  dft(a,l,0);
  dft(b,l,0);
  for (int i = 0 ; i < l ; ++ i)
    a[i] = 1ll * a[i] * b[i] % MOD;
  dft(a,l,1);
  for (int i = 1 ; i <= n ; ++ i)
    printf("%lld\n",1ll * a[i+n] * inv[i] % MOD);
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
ll A[111];
ll i, j, k;
int main(){
    scanf("%lld%lld", &N, &M);
    j = 0;
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        j += A[i];
    }
    k = 0;
    fornum(i,0,N){
        if(4*M*A[i]>=j){
            ++k;
        }
    }
    if(k>=M){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

#define N 1000

#define id(x,y) ((y)*(N+2)+(x))

class UnionFind {
	int parent[(N+2)*(N+2)];
public:
	void init() {
		for(int i=0; i<N+2; ++i) {
			for(int j=0; j<N+2; ++j) {
				parent[id(j,i)] = id(j,i);
			}
		}
	}
	int find(int x) {
		if(parent[x]==x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		if(find(x)==find(y)) return;
		if(find(x)<find(y)) {
			parent[find(y)] = parent[find(x)];
		}else {
			parent[find(x)] = parent[find(y)];
		}
	}
	bool alone(int x) {
		return find(x)==x;
	}
	bool same(int x, int y) {
		return find(x)==find(y);
	}
};

typedef pair<int, int> P;

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

int main() {
	int w, h, tx[1000], ty[1000], gx, gy, n, ans;
	char map[N+2][N+2];
	UnionFind uf;
	stack<P> s;
	while(cin >> w >> h) {
		for(int i=0; i<h+2; ++i) for(int j=0; j<w+2; ++j) map[i][j] = '#';
		for(int i=1; i<=h; ++i) {
			for(int j=1; j<=w; ++j) {
				cin >> map[i][j];
				if(map[i][j]=='t') {
					gx = j; gy = i;
				}
			}
		}
		uf.init();
		for(int i=1; i<=h; ++i) {
			for(int j=1; j<=w; ++j) {
				if(map[i][j]!='#'&&uf.alone(id(j,i))) {
					s.push(P(j, i));
					while(!s.empty()) {
						int x = s.top().first, y = s.top().second; s.pop();
						for(int k=0; k<4; ++k) {
							if(map[y+dy[k]][x+dx[k]]!='#'&&!uf.same(id(x,y), id(x+dx[k],y+dy[k]))) {
								uf.unite(id(x,y), id(x+dx[k],y+dy[k]));
								s.push(P(x+dx[k],y+dy[k]));
							}
						}
					}
				}				
			}
		}
		ans = -1;
		cin >> n;
		for(int i=0; i<n; ++i) {
			cin >> tx[i] >> ty[i];
			tx[i]++; ty[i]++;
		}
		if(uf.same(id(1,1), id(gx,gy))) ans = 0;
		else for(int i=0; i<n; ++i) {
			if(map[ty[i]][tx[i]]!='#') continue;
			map[ty[i]][tx[i]] = '.';
			for(int k=0; k<4; ++k) {
				if(map[ty[i]+dy[k]][tx[i]+dx[k]]!='#') {
					uf.unite(id(tx[i],ty[i]), id(tx[i]+dx[k],ty[i]+dy[k]));
				}
			}
			if(uf.same(id(1,1), id(gx,gy))) {
				ans = i+1; break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 10152
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

template<typename T> T mo(T x, T y) { x %= y; return x <= 0 ? x + y : x; }

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (ans.size() + 1 < x) {
            cout << -1 << "\n";
            return 0;
        }
        ans.insert(ans.begin() + (x - 1), x);
    }
    for (int x : ans) {
        cout << x << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
  while(true){
    int n, k, nums[100000], dp[100000][2], ans = 1, white = 0;
    scanf("%d%d", &n, &k);
    ans = 1;
    if(n == 0 && k == 0)return 0;
    for(int i = 0;i < k;i++){
      scanf("%d", nums + i);
      if(nums[i] == 0){
	white = 1;
	i--;
	k--;
      }
    }
    sort(nums, nums + k);
    dp[0][0] = 1;
    dp[0][1] = 2;
    for(int i = 1;i < k;i++){
      dp[i][0] = 1;
      dp[i][1] = 2;
      if(nums[i] - 1 == nums[i - 1]){
	dp[i][0] = dp[i - 1][0] + 1;
	dp[i][1] = dp[i - 1][1] + 1;
      }
      if(nums[i] - 2 == nums[i - 1]){
	dp[i][1] = dp[i - 1][0] + 2;
      }
      ans = max(ans, dp[i][0]);
      if(white == 1)ans = max(ans, dp[i][1]);
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1988
//
// Created by Myabu on 2020/01/07.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    string N;
    cin>>N;

    if(N[0] == N[1] && N[1] == N[2]){
    }else{
        int temp = (N[0] - '0') * 100 + (N[1] -'0') *10 + (N[2] -'0');
        int temp_2 = (N[0] - '0') * 100 + (N[0] -'0') *10 + (N[0] -'0');

        if(temp <= temp_2){
            for (int i = 0; i < N.length(); ++i) {
                N[i] = N[0];
            }
        }else{
            N[0] += 1;
            for (int i = 0; i < N.length(); ++i) {
                N[i] = N[0];
            }
        }
    }

    cout<<N<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

ll dfs(int x, int s, int N, bool first) {
    if (s == 0) {
        if (!first && x <= N) {
            string T = to_string(x);
            set<char> st;
            for (auto t : T) st.insert(t);
            if (st.size() == 3) return 1;
            else return 0;
        }
        else return 0;
    }

    ll res = 0;
    if (first) res += dfs(x, s - 1, N, first);
    res += dfs(10 * x + 3, s - 1, N, false);
    res += dfs(10 * x + 5, s - 1, N, false);
    res += dfs(10 * x + 7, s - 1, N, false);
    return res;
}

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

    int N;
    cin>>N;

    int s = to_string(N).size();
    ll ans = dfs(0, s, N, true);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import numpy as np
import collections

N,K = map(int, input().split())
As = input().split()
for i in range(N):
  As[i] = int(As[i])
As = np.array(As)

As_c = collections.Counter(As)

ans = 0
counter = 0
for a in sorted(As_c.values()):
  if counter < len(As_c) - K:
    ans += a 
    counter += 1
  else:
    break
print(int(ans))

Measured memory_bytes: 37996
#include<bits/stdc++.h>
using namespace std;    
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

const int MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    double ans = 0;
    double fac = 1/(double)n;
    double coin = 0.5;
    FOR(i,1,min(k,n+1)){
        double N = 0;
        while(pow(2,N)*i<k){
            N++;
        }
        //cout << N << endl;
        ans += fac*pow(coin,N);
    }
    if(n>=k)
        ans += (double)(n-k+1)*fac;
    cout << setprecision(20) <<ans;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
R=[list(map(int,input().split())) for _ in range(N)]
T=0
A=0
for t,a in R:
  n=max((T-1)//t+1,(A-1)//a+1)
  T=n*t
  A=n*a
  if T+A==0:
    T+=t
    A+=a
print(T+A)

Measured memory_bytes: 3188
#include <iostream>
#include <deque>
using namespace std;
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
int K, cnt;
ll ans = 0;
deque<ll>dq;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> K;
	if(K<=9){cout << K << nl; return 0;}
	for(int i = 1;i<=9;i++){
		dq.push_back(i);
		++cnt;
	}
	while(ans==0){
		int s = dq.size();
		for(int i = 1;i<=s;i++){
			ll x, y; x = dq.front(); dq.pop_front();
			if(x%10!=0){
				y = 10*x+x%10-1; ++cnt;
				if(cnt==K)ans = y;
				dq.push_back(y);
			}
			y = 10*x+x%10; ++cnt;
			if(cnt==K)ans = y;
			dq.push_back(y);
			if(x%10!=9){
				y = 10*x+x%10+1; ++cnt;
				if(cnt==K)ans = y;
				dq.push_back(y);
			}
		}
	}
	cout << ans << nl;
}

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

int dp[1005][1005];

int lcs(string x, string y){
    for (int i = 1; i <= x.size(); i++){
        for (int j = 1; j <= y.size(); j++)
        {
            if(x[i-1] != y[j-1])
                dp[i][j] = dp[i-1][j] > dp[i][j-1] ? dp[i-1][j] : dp[i][j-1];
            else
                dp[i][j] = dp[i-1][j-1] + 1;
        }
    }
    return dp[x.size()][y.size()];
}

int main()
{
    int n; cin >>n;
    string x, y;
    
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        cout << lcs(x, y) << endl;
    }
}


Measured memory_bytes: 7088
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    vector<string> u(s.size());
    for(int i = 0; i < s.size(); i++){
        char k = s[0];
        for(int j = 0; j <s.size() - 1; j++){
            s[j] = s[j + 1];
        }
        s[s.size() - 1] = k;
        u[i] = s; 
    }
    bool ans = false;
    for(int i = 0; i < s.size(); i++){
        if(u[i] == t)
        ans = true;
    }
    if(ans)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX_NUM 1000000
int collect_prime[MAX_NUM] = {0};

void
find_prime()
{
        int i;
        int j;

        collect_prime[1] = 1;
        for (i = 2; i < MAX_NUM; i++) {
                if (collect_prime[i] != -1) {
                        for (j = i * 2; j < MAX_NUM; j += i)
                                collect_prime[j] = -1;
                        collect_prime[i] = 1;
                }
        }
}

void
count()
{
        int i;
        for (i = 2; i < MAX_NUM; i++)
                if (collect_prime[i] == -1)
                        collect_prime[i] = collect_prime[i - 1];
                else
                        collect_prime[i] = collect_prime[i - 1] + 1;
}


int
main(int argc, char *argv[])
{
        char buf[8];
        int n;

        find_prime();
        count();
        while (fgets(buf, 8, stdin)) {
                sscanf(buf, "%d", &n);  
                printf("%d\n", collect_prime[n] - 1);
        }
        return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(m);
  vector<int> d(m);
  for(int i = 0; i < n; i++){
    cin >> a.at(i) >> b.at(i);
  }
  for(int i = 0; i < m; i++){
    cin >> c.at(i) >> d.at(i);
  }
  pair<int,int> ans;
  for(int i = 0; i < n; i++){
    ans.first = abs(a.at(i) - c.at(0)) + abs(b.at(i) - d.at(0));
    ans.second = 1;
    for(int j = 1; j < m; j++){
      if(abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j)) < ans.first){
        ans.first = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
        ans.second = j + 1;
      }
    }
    cout << ans.second << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for_each(begin(A), end(A), [](auto& x) { cin >> x; });
  A.push_back(0); // dummy
  // 買い局面と売り局面がある
  bool buy = true;
  ll before = 0;
  ll buy_min = 300;
  ll buy_max = 0;
  ll sell_min = 300;
  ll sell_max = 0;

  ll money = 1000;
  ll stock = 0;
  ll money_max = 1000;
  for (ll i = 1; i <= N; i++) {
    before = A[i - 1];
    // 売り局面切り替え
    if (before > A[i]) {
      //売れるだけ売る
      money += before * stock;
      stock = 0;
      // その瞬間の所持金メモ
      money_max = max(money_max, money);
    } else {
      // 買い局面だった
      //買えるだけ買っていたこととする
      ll count = money / before;
      money -= before * count;
      stock += count;
    }
  }

  cout << money_max << endl;
  return 0;
}


Measured memory_bytes: 3592
S=input()

stock=0

L=len(S)
ANS=0
i=0
while i<L:
    if S[i]=="A":
        stock+=1
        i+=1

    elif i<L-1 and S[i]=="B" and S[i+1]=="C":
        ANS+=stock
        i+=2

    else:
        stock=0
        i+=1

print(ANS)
        

Measured memory_bytes: 40176
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        String S=sc.next();
        int i=0;
        for(i=S.length();i>4;i--){
            String s5=S.substring(i-5,i);
            if(s5.equals("dream")||s5.equals("erase")){
                i-=4;
                continue;
            }
            String s6=S.substring(i-6,i);
            if(s6.equals("eraser")){
                i-=5;
                continue;
            }
            String s7=S.substring(i-7,i);
            if(s7.equals("dreamer")){
                i-=6;
                continue;
            }
            break;
        }
        System.out.println(i==0?"YES":"NO");
    }
}

Measured memory_bytes: 40388
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    m = n.upper()
    if m == n:
        print("A")
    else:
        print("a")

resolve()

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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = (int)1e6+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n, m;
int a[N];
map<int,int> pos;

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    sort(a, a+n);
    int res = 0;
    rep(i, 0, n) {
        if (i % 2 != 0) continue;
        res += pos[a[i]] % 2;
    }
    cout << res << endl;

    return 0;
}


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

int main()
{
    int k, s,z, count=0;
    scanf("%d %d\n",&k,&s) ;
    for(int x=0; x<=k; x++)
    {
        for(int y=0; y<=k; y++)
        {
            z=s-x-y;
            if(z>=0&&z<=k)
            {
                count++;
            }

        }
    }
    printf("%d\n",count) ;

    return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
l=[input() for i in range(n)]
c=collections.Counter(l)
k=c.most_common()
s=k[0][1]
b=[]
for i in k:
  if s==i[1]:
    b.append(i[0])
  else:
    break
m=sorted(b)
for o in m:
  print(o)

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

int main(){
    int X,Y,t;
    int g[20][20];
    rep(i,20)rep(j,20) g[i][j] = 0;
    while(~scanf("%d,%d,%d\n",&X,&Y,&t)){
        rep(y,10)rep(x,10){
            if(t==1 && abs(x-X)+abs(y-Y) <= 1) ++g[y][x];
            if(t==2 && max(abs(x-X),abs(y-Y)) <= 1) ++g[y][x];
            if(t==3 && abs(x-X)+abs(y-Y) <= 2) ++g[y][x];
        }
    }
    map<int,int> m;
    rep(i,10)rep(j,10) m[g[i][j]]++;
    printf("%d\n%d\n", m.begin()->second, m.rbegin()->first);
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>
#include <complex>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

#define EPS 1e-9
#define EQ(a,b) (abs((a)-(b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ return a.real()*b.real() + a.imag()*b.imag();}

int main(){
  int i,j,k,n;
  double xA,yA,xB,yB,xC,yC,xD,yD;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD) != EOF){
    P ab((xB-xA),(yB-yA)), cd((xD-xC),(yD-yC));
    if(EQ(0,dot(ab,cd))) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int k,n; cin>>k>>n; 
    vi a(n+1);
    for (int i=0;i<n;i++){
        cin >> a[i] ; 
    } a[n]=a[0]+k;
    int mx=0;
    for (int i=1;i<=n;i++){
        mx = max(mx,a[i]-a[i-1]);
    }
    cout << k-mx << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4816
n, x = map(int, input().split())
a = list(map(int, input().split()))

# 魔法0回のときの合計時間
ans = sum(a)
time = a[:]

# 魔法をj回唱える
for j in range(1, n):
    # 色iのスライムを得る最短時間はmin(a[i-j:i+1]) + j * x
    for i in range(n):
        time[i] = min(time[i], a[i - j])
    ans = min(ans, j * x + sum(time))

print(ans)

Measured memory_bytes: 43756
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
  long long dp[100];
  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i < 100; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  int n;
  cin >> n;
  cout << dp[n] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin >> x;//xは4桁の問題となる整数
  
  int a,b,c,d;//判定に使う変数を宣言
  
  a = x/1000;			//aは1000の位を表す
  b=(x-1000*a)/100; 			//bは100の位
  c=(x-1000*a-100*b)/10;
  d=x-1000*a-100*b-10*c;			//ここで位取り終わり
    
    if (a==b && b == c){
      cout << "Yes" << endl;
    }
  else if (b==c && c==d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

int n,r[100010];
string s;



signed main(){
    bool can=false;
    cin>>n>>s;
    rep(i,0,4){
        bool b[n];
        b[0]=((i&1)!=0);
        b[1]=((i&2)!=0);
        rep(j,2,n)b[j]=b[j-1]^b[j-2]^(s[j-1]=='o');
        if((s[0]=='o')^b[0]^b[n-1]^b[1])continue;
        if((s[n-1]=='o')^b[n-1]^b[n-2]^b[0])continue;
        rep(j,0,n)cout<<(b[j]?'S':'W');
        cout<<endl;
        return 0;
    }
    
    
    
    
    
    
    
    
    
    cout<<-1<<endl;
    return 0;
    
}

Measured memory_bytes: 640
from math import factorial
mod = int(1e+9 + 7)

X, Y = map(int, raw_input().split())

X2 = 2*X - Y
Y2 = -X + 2*Y

if X2 < 0:
    print "0"
    exit()
elif Y2 < 0:
    print "0"
    exit()

if X2%3 != 0:
    print "0"
    exit()
elif Y2%3 != 0:
    print "0"
    exit()

X2 = X2/3
Y2 = Y2/3

ans = 1

n = X2+Y2
m = Y2

for i in range(n-m+1, n+1):
    ans = (ans*i)%mod


new = 1
for i in range(2, m+1):
    new = (new*i)%mod

new = pow(new, mod-2, mod)

ans = (ans*new)%mod

print ans


Measured memory_bytes: 16028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll K, X;
    cin >> K >> X;
    cout << ((500 * K >= X) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

int digCount(int a)
{
    int ret = 0;
    do
    {
        a /= 10;
        ret++;
    } while (a > 0);
    return ret;
}

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

    string str;
    cin >> str;

    int n = str.length();

    arri arr;
    arr.resize(n, 0);

    int prev = 0;
    for (int i = 0; i < (n - 1); i++)
    {
        if (str[i] == 'R')
        {
            prev++;
            if (str[i + 1] == 'L')
            {
                arr[i] = prev;
                prev = 0;
            }
        }
    }
    prev = 0;
    for (int i = n - 1; i > 0; i--)
    {
        if (str[i] == 'L')
        {
            prev++;
            if (str[i - 1] == 'R')
            {
                arr[i] = prev;
                prev = 0;
            }
        }
    }

    for (int i = 0; i < (n - 1); i++)
    {
        if (arr[i])
        {
            int firstToTransfer = arr[i] / 2;
            int firstToRemain = arr[i] - firstToTransfer;

            int secondToTransfer = arr[i + 1] / 2;
            int secondToRemain = arr[i + 1] - secondToTransfer;

            arr[i] = firstToRemain + secondToTransfer;
            arr[i + 1] = firstToTransfer + secondToRemain;

            i++;
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << arr[i] << " ";
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  LL ans=0,tmp;
  int ms;
  for(int i=0;i<=30;i++){
    tmp=0;
    if(k&(1<<i)){
      ms=(1<<30)-1-(k-(k&((1<<(i+1))-1))+((1<<i)-1));
    }else{
      ms=(1<<30)-1-k;
    }
    for(int j=0;j<n;j++){
      if((ms&a[j])==0) tmp+=b[j];
    }
    ans=max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long 
const int MODN=998244353;
const int MAXN=3010;
using namespace std;

int dp[2][MAXN];
//滚动数组
int32_t main(){
    dp[0][0]=1;
    int cur=1;
    int n,k;cin>>n>>k;
    vector<int> arrmv(n+1);
    for(int i=0;i<n;i++)cin>>arrmv[i+1];
    vector<int> a=arrmv;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(k-a[i]>=0){
            if(k-a[i]>0)ans+=dp[cur][k-a[i]]*(n-i+1);
            else ans+=i*(n-i+1);
                ans%=MODN;
        }
        cur=!cur;
        for(int j=k;j>=0;j--){
            dp[cur][j]=0;
            dp[cur][j]+=dp[!cur][j];
            if(j-a[i]>0)dp[cur][j]+=dp[!cur][j-a[i]];
            else if(j==a[i])dp[cur][j]+=i;
            dp[cur][j]%=MODN;
        }
        cout<<endl;
    }
    cout<<ans<<endl;
	return 0;
}

//无滚动
// #include <bits/stdc++.h>
// #define int long long 
// const int MODN=998244353;
// const int MAXN=3010;
// using namespace std;
 
// int dp[MAXN][MAXN];
// int32_t main(){
    // dp[0][0]=1;
    // int n,k;cin>>n>>k;
    // vector<int> arrmv(n+1);
    // for(int i=0;i<n;i++)cin>>arrmv[i+1];
    // vector<int> a=arrmv;
    // int ans=0;
    // for(int i=1;i<=n;i++){
        // if(k-a[i]>=0){
            // if(k-a[i]>0)ans+=dp[i-1][k-a[i]]*(n-i+1);
            // else ans+=i*(n-i+1);
                // ans%=MODN;
        // }
        // for(int j=k;j>=0;j--){
            // dp[i][j]+=dp[i-1][j];
            // if(j-a[i]>0)dp[i][j]+=dp[i-1][j-a[i]];
            // else if(j==a[i])dp[i][j]+=i;
            // dp[i][j]%=MODN;
            // cout<<dp[i][j]<<" ";
        // }
        // cout<<endl;
    // }
    // cout<<ans<<endl;
	// return 0;
// }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
typedef pair<int, pii > ppi;
const int mod = 1000000007;
const int INF = 1000000009;

int N, P;
int ans = 1ll;

int pows(int a, int b)
{
    int tmp = 1;
    for(int i = 0; i < b; i++){
        tmp *= a;
    }
    return tmp;
}

signed main()
{
    cin >> N >> P;
    for(int i = 2ll; i * i <= P; i++){
        int cnt = 0ll;
        while(P % i == 0ll){
            P /= i;
            cnt++;
        }
        if(cnt >= N){
            ans *= pows(i, cnt / N);
        }
    }
    if(P > 1ll){
        if(N == 1ll){
            ans *= P;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A_even = [num for num in A if num%2 == 0]
A_odd = [num for num in A if num%2 != 0]
e = len(A_even)
o = len(A_odd)

if(o%2 == 0):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 14108
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int get_ab(string str) {
	bool isA = false;
	int res = 0;
	if (str[0] == 'A') isA = true;
	for (int i = 1; i < str.length(); i++) {
		if (isA && str[i] == 'B') { res++; isA = false; }
		else if (str[i] == 'A') isA = true;
		else isA = false;
	}
	return res;
}

int main(void) {
	//Program Start	

	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	rep(i, M)cin >> B[i];

	int res = 0;

	rep(i, N) {
		int tmp = C;
		rep(j, M) {
			int inp;
			cin >> inp;
			tmp += inp * B[j];
		}
		if (tmp > 0) res++;
	}

	cout << res << endl;

ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    int x4 = x3 - (y3 - y2);
    int y4 = y3 + (x3 - x2);

    std::cout << x3 << std::endl;
    std::cout << y3 << std::endl;
    std::cout << x4 << std::endl;
    std::cout << y4 << std::endl;
}


Measured memory_bytes: 256
letter = "abcdefghijklmnopqrstuvwxyz"
dic = {}
for i in letter:
    dic.setdefault(i,0)
while 1:
    try:
        a = str(input()).lower()
    except:
        break
    for i in a:
        for j in letter:
            if i == j:
                dic[i] += 1
for i in dic:
    print(f"{i} : {dic[i]}")


Measured memory_bytes: 5576
#include <iostream>
using namespace std;
int main()
{
  int n,t;
  int menor = 1001;
  cin >> n;
  cin >> t;
  while(n-- > 0){
  	int a,b;
  	cin >> a;
  	cin >> b;
  	if(b <= t){
  	    if(a <= menor){
  	        menor = a;
  	    }
  	}    
  }
    (menor == 1001) ? cout << "TLE" : cout << menor;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 3e5 + 1e3;
int k, n;
int a[N], Last;

inline void Decrese() {
	if (Last == n) {
		if (!(-- a[Last])) -- Last;
	} else {
		if (!(-- a[Last])) -- Last;
		else while (Last < n) a[++ Last] = k;
	}
}

int main () {
	File();

	cin >> k >> n;

	if (k & 1) {
		For (i, 1, n)
			a[i] = (k + 1) / 2;
		Last = n;

		For (i, 1, n / 2) Decrese();

		For (i, 1, Last)
			printf ("%d%c", a[i], i == iend ? '\n' : ' ');
	} else {
		For (i, 1, n) {
			int val = (i == 1) ? k / 2 : k;
			printf ("%d%c", val, i == iend ? '\n' : ' ');
		}
	}
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;
const int MAXH = 10010;
const int MAXN = 1010;
int dp[MAXN][MAXH];

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, MAXN) rep(j, MAXH) dp[i][j] = INF;

  dp[0][0] = 0;
  rep(i, n) for (int j = 0; j <= h; ++j) {
    int nj = min(j + a[i], h);      // 配列外参照しないように
    chmin(dp[i + 1][j], dp[i][j]);              // 選ばない
    chmin(dp[i + 1][nj], dp[i + 1][j] + b[i]);  // 小さければ選ぶ
  }
  cout << dp[n][h] << endl;
}



Measured memory_bytes: 39808
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
vector<ll>v;
int main(){
    ll n;
    cin>>n;
    vector<ll>dp(n,0);
    for(ll i=0;i<n;i++){
        ll s;
        cin>>s;
        v.push_back(s);
    }
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=0;i<n;i++){
        if(i==0){
            dp[i]=0;
        }
        else if(i==1){
            dp[i]=abs(v[i]-v[i-1]);
        }
        else{
            dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;

    }


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const ll inf = 0x3f3f3f3f3f3f3f3f;

ll ans=inf;
ll n,a,b,c,d;
map<ll,ll> mp;

ll solve(ll x){
    if(!x)return 0;
    if(x==1)return d;
    if(mp.count(x))return mp[x];
    ll l2=(x/2)*2;
    ll r2=((x+1)/2)*2;
    ll l3=(x/3)*3;
    ll r3=((x+2)/3)*3;
    ll l5=(x/5)*5;
    ll r5=((x+4)/5)*5;
    ll res=1e18;
    if(x<res/d)res=x*d;
    res=min(res,llabs(l2-x)*d+a+solve(l2/2));
    res=min(res,llabs(r2-x)*d+a+solve(r2/2));
    res=min(res,llabs(l3-x)*d+b+solve(l3/3));
    res=min(res,llabs(r3-x)*d+b+solve(r3/3));
    res=min(res,llabs(l5-x)*d+c+solve(l5/5));
    res=min(res,llabs(r5-x)*d+c+solve(r5/5));
    mp[x]=res;
    return res;
}
int main(){
    IOS;
    int _;cin>>_;
    while(_--) {
        mp.clear();
        cin>>n>>a>>b>>c>>d;
        cout<<solve(n)<<endl;
    }
    return 0;
}

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

int main(){
	int n,x ; cin >> n ;
	char c ;
	int ans = x = 0 ;
	for(int i=0;i<n;i++){
		cin >> c ;
		if(c=='I'){
			if(ans==x) ans = x = x+1 ;
			else x++ ;
		}else x-- ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 256
s = input()
t = input()
dp = [[0 for i in range(len(s)+1)] for j in range(len(t)+1)]
for i in range(len(t)):
    for j in range(len(s)):
        if s[j] == t[i]:
            dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])

ans = ''
i = len(t)
j = len(s)
while i >= 1 and j >= 1:
    if dp[i][j] == dp[i-1][j]:
        i -= 1    
    elif dp[i][j] == dp[i][j-1]:
        j -= 1    
    else:
        ans = s[j-1] + ans
        i -= 1
        j -= 1
print(ans)

Measured memory_bytes: 120028
// Takoyaki

package main

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

func takoyaki(n, x, t int) int {
	return int(math.Ceil(float64(n)/float64(x))) * t
}

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, _ := nextInt(sc)
	x, _ := nextInt(sc)
	t, _ := nextInt(sc)

	r := takoyaki(n, x, t)
	fmt.Println(r)
}

Measured memory_bytes: 1776