akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second
 
using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;
 
llong get_max(llong A2, llong B1) {
    llong ret = A2 * B1;
    llong x = (A2 + B1) / 2;
    llong y = A2 + B1 - x;
    if (x <= A2 && B1 <= y) ret = max(ret, x * y);
    return ret;
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        int s = 0, e = b - 1;
        while (s < e) {
            int m = (s + e + 1) / 2;
            if (get_max(m, a + 1) < (llong)a * b) s = m;
            else e = m - 1;
        }
        printf("%d\n", a - 1 + s);
    }
    return 0;
}

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back
#define mp make_pair
#define pii pair<int, int>

const int MAXN = 200009;
int n, m, x, y, len;
int a[2][MAXN];
int b[2][MAXN];
pii dp[MAXN];

bool f(int t)
{
    dp[len].ff = 0;
    dp[len].ss = 0;
    pii cur(0, 0);
    for (int i = len - 1; i >= 0; i--)
    {
        dp[i].ff = dp[i + 1].ff + min(0ll, a[t][i]);
        dp[i].ss = dp[i + 1].ss + max(0ll, a[t][i]);
        //cout << t << " " << dp[i].ff << " " << dp[i].ss << "\n";
        if (t == 0 && x + dp[i].ff < 0)
        {
            int q = abs(x + dp[i].ff);
            q = min(q, cur.ss);
            cur.ss -= q;
            dp[i].ff += q;
            dp[i].ss += q;
        }
        if (t == 1 && y + dp[i].ff < 0)
        {
            int q = abs(y + dp[i].ff);
            q = min(q, cur.ss);
            cur.ss -= q;
            dp[i].ff += q;
            dp[i].ss += q;
        }
        if (t == 0 && x + dp[i].ss >= n)
        {
            int q = (x + dp[i].ss) - (n - 1);
            q = min(q, -cur.ff);
            cur.ff += q;
            dp[i].ff -= q;
            dp[i].ss -= q;
        }
        if (t == 1 && y + dp[i].ss >= m)
        {
            int q = (y + dp[i].ss) - (m - 1);
            q = min(q, -cur.ff);
            cur.ff += q;
            dp[i].ff -= q;
            dp[i].ss -= q;
        }
        if (t == 0 && x + dp[i].ff < 0)
            return true;
        if (t == 1 && y + dp[i].ff + cur.ss < 0)
            return true;
        if (t == 0 && x + dp[i].ss + cur.ff >= n)
            return true;
        if (t == 1 && y + dp[i].ss + cur.ff >= m)
            return true;
        if (dp[i].ff == dp[i].ss)
        {
            cur.ff += min(0ll, b[t][i]);
            cur.ss += max(0ll, b[t][i]);
        }
        else
        {
            dp[i].ff += max(0ll, b[t][i]);
            dp[i].ss += min(0ll, b[t][i]);
        }
        //cout << t << " " << dp[i].ff << " " << dp[i].ss << "\n";
    }
    return false;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> len >> x >> y;
    x--; y--;
    string s1, s2;
    cin >> s1 >> s2;
    for (int i = 0; i < len; i++)
    {
        if (s1[i] == 'D')
            a[0][len - 1 - i] = 1;
        else if (s1[i] == 'U')
            a[0][len - 1 - i] = -1;
        else if (s1[i] == 'L')
            a[1][len - 1 - i] = -1;
        else
            a[1][len - 1 - i] = 1;

        if (s2[i] == 'D')
            b[0][len - 1 - i] = 1;
        else if (s2[i] == 'U')
            b[0][len - 1 - i] = -1;
        else if (s2[i] == 'L')
            b[1][len - 1 - i] = -1;
        else
            b[1][len - 1 - i] = 1;
    }
    //cout << f(0) << " " << f(1) << "\n";
    if (f(0) || f(1))
        cout << "NO";
    else
        cout << "YES";
}

Measured memory_bytes: 10264
#include<iostream>
#include<string>
using namespace std;
int n;
void dfs(string s,char mx){
	if(s.length()==n){
		cout<<s<<endl;
		s=="";
	}
	else{
		for(char c='a';c<=mx;c++){
			dfs(s+c,(c==mx)?(char)(mx+1):mx);
		}
	}
}
int main(){
	
	cin>>n;
	dfs("",'a');
	
	return 0;
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 2e5 + 10, mod = 1e9 + 7;

int pow_mod(int x, int n = mod - 2) {
	int y = 1;
	while(n) {
		if(n & 1) {
			y = (long long) y * x % mod;
		}
		x = (long long) x * x % mod;
		n >>= 1;
	}
	return y;
}

int n, a[maxn], cnt[maxn], d[maxn], way, ans, fen[maxn];
vector<int> p0;

int lowbit(int i) {
	return i & (-i);
}

void M(int i, int x) {
	for(; i <= n; i += lowbit(i)) {
		fen[i] = (fen[i] + x) % mod;
	}
	return;
}

int Q(int i) {
	int x = 0;
	for(; i; i ^= lowbit(i)) {
		x = (fen[i] + x) % mod;
	}
	return x;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		++cnt[a[i]];
	}
	for (int i = n; i; --i) {
		cnt[i] += cnt[i + 1];
	}
	way = 1;
	d[0] = 1;
	for (int i = 1; i <= n; ++i) {
		cnt[i] -= (n - i);
		way = (long long) way * cnt[i] % mod;
		int x = (long long) (cnt[i] - 1) * pow_mod(cnt[i]) % mod;
		if(!x) {
			p0.push_back(i);
			x = 1;
		}
		d[i] = (long long) x * d[i - 1] % mod;
	}
	if(!way) {
		puts("0");
		return 0;
	}
	p0.push_back(n + 1);
	for (int i = n; i; --i) {
		int &ai = a[i], aj = p0[lower_bound(p0.begin(), p0.end(), ai + 1) - p0.begin()] - 1;
		ans = ((long long) (Q(aj) - Q(ai - 1)) * pow_mod(d[ai]) + ans) % mod;
		M(ai, d[ai]);
	}
	memset(fen, 0, sizeof(fen[0]) * (n + 1));
	for (int i = 1; i <= n; ++i) {
		int &ai = a[i], aj = p0[lower_bound(p0.begin(), p0.end(), ai + 1) - p0.begin()] - 1;
		ans = ((long long) ans - (long long) (Q(aj) - Q(ai)) * pow_mod(d[ai])) % mod;
		M(ai, d[ai]);
	}
	ans = (ans + mod) % mod;
	if(ans & 1) {
		ans = ans + mod >> 1;
	}
	else {
		ans >>= 1;
	}
	memset(fen, 0, sizeof(fen[0]) * (n + 1));
	for (int i = n; i; --i) {
		ans = (ans + Q(a[i] - 1)) % mod;
		M(a[i], 1);
	}
	printf("%d\n", (long long) ans * way % mod);
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if((int)(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    puts(":(");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <vector>
#include <map>

using namespace std;

using Z = int;
constexpr Z INF = numeric_limits<Z>::max();

#ifdef DEBUG
# define dump(x) cerr << #x << " = " << (x) << endl
# define mesg(m) cerr << m << endl
# define debug if (true)
#else
# define NDEBUG
# define dump(x)
# define mesg(m)
# define debug if (false)
#endif
#define rep(i, n) for (auto i = 0; i < n; i++)
#define rrep(i, n) for (auto i = n; 

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Z n;
  cin >> n;
  map<Z, Z> cnt;
  rep (i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  Z even = 0;
  for (auto&& p : cnt)
    if (p.second % 2 == 0)
      even++;
  Z ans = cnt.size() - even % 2;
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int A,B,C; cin>>A>>B>>C;
  cout<<C<<" "<<A<<" "<<B<<endl;
  }


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

using namespace std;

int main() {

    int n, m, x, y;
    vector<int> dx, dy;
    scanf("%d%d%d%d", &n,&m,&x,&y);

    for(int i = 0; i < n; i++) {
    	int d;
    	scanf("%d", &d);
    	dx.push_back(d);
    }

    for(int i = 0; i < m; i++) {
    	int d;
    	scanf("%d", &d);
    	dy.push_back(d);
    }

    sort(dy.begin(),dy.end());
    sort(dx.begin(),dx.end());

    bool war = true;

    //for(int i = 0; i < n; i++) {
   // 	printf("%d ", dx[i]);
    //}

    //printf("\n");
    
   // for(int i = 0; i < m; i++) {
   // 	printf("%d ", dy[i]);
   // }
    for(int i = x+1; i <= y; i++) {
    	if(i <= dy[0] && i > dx[n-1]) {
    		war = false;
    		break;
    	}
    } 

    if(war) printf("War\n");
    else printf("No War\n"); 

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC111 C

from operator import itemgetter
import collections

n = int(input())
v = list(map(int,input().split()))

s = [v[i] for i in range(n) if i % 2 == 0]
t = [v[i] for i in range(n) if i % 2 == 1]

sc = collections.Counter(s)
tc = collections.Counter(t)
sc = list(sc.items())
tc = list(tc.items())
ls = len(sc)
lt = len(tc)
sc.sort(key = itemgetter(1))
tc.sort(key = itemgetter(1))
if sc[-1][0] == tc[-1][0]:
    if ls == 1 and lt == 1:
        print(n - sc[-1][1])
    elif ls == 1 and lt != 1:
        print(n - sc[-1][1] - tc[-2][1])
    elif ls != 1 and lt == 1:
        print(n - sc[-2][1] - tc[-1][1])
    else:
        ma = max(sc[-2][1],tc[-2][1])
        print(n - sc[-1][1] - ma)
else:
    print(n - sc[-1][1] - tc[-1][1])


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll Q = N / (A + B);
    ll R = N % (A + B);
    PR(A*Q+MIN(A,R));

    return 0;
}

/*



*/

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

int main() {
  string S; cin >> S;
  reverse(S.begin(), S.end());
  S += '0';
  int L = S.size();
  const int INF = 1000000007;
  vector<vector<int>> dp(L+1, vector<int>(2, INF));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < L; i++) {
    for (int j = 0; j < 2; j++) {
      int D = S.at(i) - '0';
      D += j;
      dp.at(i+1).at(0) = min(dp.at(i+1).at(0), dp.at(i).at(j) + D);
      dp.at(i+1).at(1) = min(dp.at(i+1).at(1), dp.at(i).at(j) + (10 - D));
    }
  }
  int ans = dp.at(L).at(0);
  cout << ans << endl;
}

Measured memory_bytes: 55940
import numpy as np
d=int(input())
c=list(map(int,input().split()))
TotalLoss=sum(c)
for i in range(26):
  c[i]=TotalLoss-c[i]
c=np.array(c)
s=[]
for i in range(d):
  si=list(map(int,input().split()))
  s.append(si)
s=np.array(s)
ans=[]
for i in range(d):
  si=s[i]
  si-=c
  index=np.argmax(si)
  ans.append(index+1)
for i in range(d):
  print(ans[i])

Measured memory_bytes: 27488
n, y = map(int, input().split())

ca, cb, cc = -1, -1, -1
for a in range(n+1):
    for b in range(n-a+1):
        c = n - (a+b)
        total = 10000*a + 5000*b + 1000*c
        if total == y:
            ca, cb, cc = a, b, c
            
print(ca, cb, cc)

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i, n) cin>>a[i];
	int res = 0;
	for(int i = 0; i < n; i++){
		res++;
		while(i<n-1 && a[i]==a[i+1]) i++;
		if(i==n-1) break;
		int j = i;
		while(j<n-1&&(a[i+1]-a[i])*(a[j+1]-a[j])>=0) j++;
		i = j;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int i, n, A[10001], q, key, sum = 0;

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

  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&key);
    if(linearSearch(A, n, key)){
      sum++;
    }
  }
  printf("%d\n",sum);

  return 0;
}

int linearSearch(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key){
    i++;
  }
  return i != n;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define __m int mid=(l+r)/2;

template<class T>
inline bool read(T &num)  
{
    char in;bool IsN=false;
    while(in=getchar(),in!='-'&&(in<'0'||in>'9'))if(in==EOF)return false;
    in=='-'?(IsN=true,num=0):num=in-'0';
    while(in=getchar(),in>='0'&&in<='9')num=num*10+in-'0';
    return IsN?num=-num:num,true;
}
#define DEBUG

#ifdef DEBUG
    #define debug(a) cout<<"nico : "<<a<<endl;
#else
    #define debug(a) ;
#endif

#define read2(a,b) read(a)&read(b)
#define read3(a,b,c) read(a)&read(b)&read(c)

const int maxn =2e5+7;
const int inf  =2e9+7;
const int mod  =1e9+7;

int fa[maxn],w[maxn];
void init(){
    for(int i=0;i<maxn;i++){
        fa[i]=i;
        w[i]=0;
    }
}
int find(int x){
    if(x==fa[x])
        return x;
    int newfa=find(fa[x]);
    w[x]=(w[x]+w[fa[x]]);
    return fa[x]=newfa;
}
void merge(int x,int y,int c){
    int fx=find(x);
    int fy=find(y);
    if(fx==fy) 
        return ;
    fa[fx]=fy;
    w[fx]=(c-w[x]+w[y]);
}

int main() {
#ifdef fakeLOCAL
    freopen("sample.in", "r", stdin);
#endif
    int n,m;
    init();
    bool ans=true;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        int fx=find(a);
        int fy=find(b);
        if(fx==fy){
            if(w[b]-w[a]!=c){
                ans=false;
            }

        } else {
            merge(b,a,c);
        }
    }
    if(ans)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
} 


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
using Int = long long;
int main()
{
    int H, W, D;
    cin >> H >> W >> D;
    vector<pair<int, int>> P(H*W+1);
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            int a;
            cin >> a;
            P[a] = make_pair(y, x);
        }
    }
    vector<int> S(H*W+1);
    for (int i = 0; i < S.size(); i++) {
        int last = i - D;
        if (last < 0) continue;
        S[i] = S[last] + abs(P[i].first - P[last].first) + abs(P[i].second - P[last].second);
    }
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int L, R;
        cin >> L >> R;
        cout << S[R] - S[L] << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main
{
	public static void main( String[] args ) throws IOException
	{
		Reader.init(System.in);
		long n = Reader.nextLong();
		String num = String.valueOf(n);
		long res = 0;
		for ( int i = 0 ; i < num.length() ; i++ )
		{
			res = res + Character.getNumericValue(num.charAt(i));
		}
		//System.out.println(res+" RESULT ");
		if ( n%res == 0 )
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}

/** Class for buffered reading int and double values */
class Reader 
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) 
    {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) 
        {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

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

int n, k;

bool need(int*, int);
int main(){
  cin >> n >> k;
  int a[n+1];
  for(int i=1; i<=n; i++) cin >> a[i];
  sort(a+1, a+n+1);

  int l=1, r=n, m;
  if(need(a, 1)){
    cout << 0 << endl;
    return 0;
  }
  if(!need(a, n)){
    cout << n << endl;
    return 0;
  }

  while(l+1<r){
    m = (l+r)/2;
    if(need(a, m)){
      r = m;
    }
    else{
      l = m;
    }
  }

  cout << r-1 << endl;

  return 0;
}

//カードindexが要るならtrue, いらないのならfalse
bool need(int* a, int index){
  int tmp[n];
  for(int i=1, j=1; i<=n; i++){
    tmp[j] = a[i];
    if(i!=index) j++;
  }

  bool dp[n][k];
  for(int i=0; i<n; i++){
    for(int j=0; j<k; j++) dp[i][j] = false;
  }
  dp[0][0] = true;

  for(int i=1; i<n; i++){
    for(int j=0; j<k; j++){
      if(j<tmp[i]) dp[i][j] = dp[i-1][j];
      else dp[i][j] = dp[i-1][j] || dp[i-1][j-tmp[i]];
    }
  }

  for(int j=max(0, k-a[index]); j<k; j++){
    if(dp[n-1][j]) return true;
  }

  return false;
}


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

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

    int count = 0;
    if (S[0] == 'o') count++;
    if (S[1] == 'o') count++;
    if (S[2] == 'o') count++;

    cout << 700 + 100*count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n , 0);
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    a[temp - 1]++;
  }
  sort(a.begin(), a.end());
  long long sum = 0;
  for(int i = 0; i < n - k; i++) sum += a[i];
  cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();
		int dx = tx - sx;
		int dy = ty - sy;
		for(int i = 0  ; i < dx ; i++) {
			System.out.print("R");
		}
		for(int i = 0 ; i < dy ; i++) {
			System.out.print("U");
		}
		for(int i = 0 ; i < dx ; i++) {
			System.out.print("L");
		}
		for(int i = 0 ; i < dy ; i++) {
			System.out.print("D");
		}
		System.out.print("D");
		for(int i = 0 ; i < dx + 1; i++) {
			System.out.print("R");
		}
		for(int i = 0 ; i < dy + 1 ; i++) {
			System.out.print("U");
		}
		System.out.print("L");
		System.out.print("U");
		for(int i = 0 ; i < dx + 1 ; i++) {
			System.out.print("L");
		}
		for(int i = 0 ; i < dy + 1; i++) {
			System.out.print("D");
		}
		System.out.println("R");
	}
}


Measured memory_bytes: 25408
import sys
from collections import deque
import copy


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A_list = []
    B_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [A, B] = [int(input_raw[0]), int(input_raw[1])]
        A_list.append(A)
        B_list.append(B)

    count = 0
    for i in range(N - 1, -1, -1):
        count = B_list[i] * ((A_list[i] + count)/B_list[i] + (0 if (A_list[i] + count)%B_list[i] == 0 else 1)) - A_list[i]
    print count

if __name__ == '__main__':
    main()

Measured memory_bytes: 12768
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_A
// Sort II - Counting Sort

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 2000000;
const int k = 10000;

unsigned short A[MAX_N + 1];
unsigned short B[MAX_N + 1];
ui64 C[k + 1];

void counting_sort(int n) {
    memset(C, 0, sizeof(C));

    for (int i = 1; i <= n; ++i) C[A[i]]++;

    for (int i = 1; i <= k; ++i) C[i] += C[i - 1];

    for (int j = n; j >= 1; --j) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int n = 7;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> A[i];

    counting_sort(n);

    for (int i = 1; i <= n; ++i) {
        cout << B[i];
        if (i != n) cout << " ";
        else cout << endl;
    }

    return 0;
}


Measured memory_bytes: 10956
// https://dwacon5th-prelims.contest.atcoder.jp/tasks/dwacon5th_prelims_c

#include<cstdio>
const int N=1e6+10;
int n,m,T,D[N],M[N],C[N],x,y;
char s[N];
long long sum,ans;
int main()
{
	scanf("%d%s%d",&n,s,&T);
	for(int i=0;i<n;i++)
		if(s[i]=='C')C[i+1]=1;
		else if(s[i]=='D')D[i+1]=1;
		else if(s[i]=='M')M[i+1]=1;
	while(T--)
	{
		scanf("%d",&m);
		ans=sum=x=y=0;
		for(int i=1;i<=n;i++)
		{
			if(i>=m&&D[i-m])
			{
				x--;
				sum-=y;
			}
			if(i>=m&&M[i-m])y--;
			if(D[i])x++;
			if(M[i])
			{
				y++;
				sum+=x;
			}
			if(C[i])ans+=sum;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [f64; n],
    }
    let sum_of_inv_a: f64 = a.iter().map(|x| 1.0 / x).sum();
    println!("{}", 1.0 / sum_of_inv_a);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int m,d;
	cin >> m >> d;
	int cnt = 0;
	for(int i=1;i<=m;i++){
		for(int j=10;j<=d;j++){
			if(i==j%10 * (j/10%10) && j%10>=2 && (j/10%10)>=2 ){
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#B
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
b=[int(input()) for i in range(n)]
appear=[[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                appear[i][j]=True
                break
ans="No"
for i in range(3):
    if appear[i][0]==appear[i][1]==appear[i][2]==True:
        ans="Yes"
    if appear[0][i]==appear[1][i]==appear[2][i]==True:
        ans="Yes"
if appear[0][0]==appear[1][1]==appear[2][2]==True:
    ans="Yes"
if appear[2][0]==appear[1][1]==appear[0][2]==True:
    ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s;
int ans;
int main()
{
	cin>>s;
	int len=s.size();
	for(int i=0;i<=len/2;i++)
	{
		char x=s[i],y=s[len-1-i];
		if(x>='A'&&x<='Z') x-='A'-'a';
		if(y>='A'&&y<='Z') y-='A'-'a';
		if(x!=y) 
		{
			ans++;
			s[i]=y;
//			printf("%c %c\n",x,y);
		}
	}
	printf("%d",ans);
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define REFOR(i,m,n) for(int i=int(n-1); i>=int(m); i--)
#define ALL(obj) (obj).begin(),(obj).end()
 
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>
 
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>
 
#define SUMI(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SUMD(obj) accumulate((obj).begin(), (obj).end(), 0.)
#define SUML(obj) accumulate((obj).begin(), (obj).end(), 0LL)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

#define PB push_back
#define Cout(str) cout << str << endl

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const ll EPS = (ll)1e-8;

int main(){
	int n,m;
	int a,b,c,d;
	int sum;
	string str;
	string s,t;
	char ch;
	VI vi;
	vector<char> vc;
	VS vs;
	int reserve_vi = 100;
	map<int, int> table; 
	string str2, str3;
	map<char, string> vowel;
	vector<char> vowel_vec = {'a', 'e', 'i', 'o', 'u'};

	//cin >> n >> m;
	//cin >> a >> b;
	cin >> a >> b >> c;
	//cin >> a >> b >> c >> d;
	//cin >> str;
	//cin >> str >> str2 >> str3;
	//cin >> n;
	
	//cin >> s >> t;
	//cin >> ch;
	//cin >> a >> ch >> b;
	

	if(b-a == c-b)cout << "YES" << endl;
	else cout << "NO" << endl;
	//cout << accumulate(vi.begin(), vi.begin()+n, 0) << endl;
	//replace(ALL(str), ',', ' ');

	//swap(a, b);
	//vi.resize(N);
	//fill(vi.begin(), vi.end(), 1);
	//vi.reserve(reserve_vi);
	//vi.PB(n);

	//vc.resize(5);
	//vc[i] = (str[i]);

	//sort(vc.begin(), vc.end(), greater<char>());
	//sort(vc.begin(), vc.end());

	//for(auto itr = table.begin(); itr != table.end(); ++itr) {
	return 0;
}



Measured memory_bytes: 256
N, M  = list(map(int, input().split()))

lst = []
solved = set()
for i in range(M):
    pstr, s = list(input().split())
    pnum = int(pstr)
    lst.append((pnum, s))
    if s == 'AC':
        solved.add(pnum)

seen = set()
wa = 0
for (p, s) in lst:
    if p in solved and p not in seen:
        if s == 'AC':
            seen.add(p)
        else:
            wa += 1
print("{} {}".format(len(solved), wa))


Measured memory_bytes: 29724
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,i,hs;
ll rmt(ll aa)
{
	ll hh=0;
	while(aa>0)
	{
		hh+=(aa%10);
		aa/=10;
	}
	return hh;
}
int main()
{
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)
	{
		if(a<=rmt(i)&&rmt(i)<=b)
		hs+=i;
	}
	cout<<hs<<"\n";
}

Measured memory_bytes: 256
n = int(input())
 
lines = []
for i in range(n):
  x,l = map(int,input().split())
  lines.append([x-l,x+l])
lines = sorted(lines,key=lambda x:x[1])
count = 0
kari = -9999999999999
for i in range(n):
  if lines[i][0] >= kari:
    count += 1
    kari = lines[i][1]
print(count)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()


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

  int N,T;
  cin>>N>>T;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i]; 
  int Min=INT_MAX;
  vector<int>res(N);
  for(int i=0;i<N;i++){
    Min=min(Min,A[i]);
    res[i]=A[i]-Min;
  }
  int Max=*max_element(rng(res));
  int ans=0;
  for(int i=0;i<N;i++){
    if(Max==res[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < n; i++)
ll a[10000];

int main(void){
    ll n, m, x;
    cin >> n >> m >> x;

    rep(i, m){
        ll tmp;
        cin >> tmp;
        a[tmp] = 1;
    }

    ll count1 = 0, count2 = 0;
    rep(i, x){
        if(a[i] == 1){
            count1++;
        }
    }
    for(int i = x; i < n; i++){
        if(a[i] == 1){
            count2++;
        }
    }

    cout << min(count1, count2) << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] x = new int[n + 1], y = new int[m + 1];
			x[0] = scanner.nextInt();
			y[0] = scanner.nextInt();
			IntStream.rangeClosed(1, n).forEach(i -> x[i] = scanner.nextInt());
			IntStream.rangeClosed(1, m).forEach(i -> y[i] = scanner.nextInt());
			System.out.println(
					(Arrays.stream(x).max().getAsInt() < Arrays.stream(y).min().getAsInt()) ? "No War" : "War");
		}
	}
}


Measured memory_bytes: 36476
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;

signed main(){  
    cin >> N;
    int ans = 1;
    while(ans * 2 <= N){
        ans *= 2;
    }
    cout << ans << endl;


    return 0;
}

/*

*/


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

const int MAX = 100;

double abs(double n) {
	return n >= 0 ? n : -n;
}
int main() {
	int N, a[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i];
	double sum = 0;
	for (int i = 0;i < N;++ i) sum += a[i];
	sum /= N;
	double diff = abs(sum - a[0]), eps = 0.00001;
	int ans = 0;
	for (int i = 0;i < N;++ i) {
		if (diff > eps + abs(sum - a[i])) {
			ans = i;
			diff = abs(sum - a[i]);
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

平均値求めて、差が最小になるの選んでいくだけ
*/

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    ArrayList<Integer> a = new ArrayList<Integer>();
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
    	int brick = 0; //砕くレンガの数
    	int count = 1;//残ったレンガの要素数
    	
    	for (int i=0; i<N; i++) {
    		int tmp = sc.nextInt();
        	if (count != tmp) {
        		brick++;
        	} else {
        		a.add(tmp);
        		count++;
        	}
        }
    	
        if (brick == N) {
        	brick = -1;
        }
        return brick;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 65652
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
#define rep(i,s,t) for(ll i=s ; i<t ; i++)
typedef pair<ll,ll> P;
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  ll n,m; cin >> n >> m;
  cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    char xg, yg;
    
    cin >> x;
    cin >> y;
    
    if (x == 2) {
        xg = 'c';
    }
    else if (x == 4 || x == 6 || x == 9 || x == 11) {
        xg = 'b';
    }
    else {
        xg = 'a';
    }
    
    if (y == 2) {
        yg = 'c';
    }
    else if (y == 4 || y == 6 || y == 9 || y == 11) {
        yg = 'b';
    }
    else {
        yg = 'a';
        
    }
    
    if (xg == yg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    
    return 0;
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int g[105][105];
int dist[105]={-1};
bool visit[105];

int main(void){
    int n;
    cin>>n;
    for(int i=0;i<105;i++)dist[i]=-1;
    for(int i=0;i<n;i++){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++){
            int v;
            cin>>v;
            g[u][v]=1;
        }
    }
    queue<int>que;
    que.push(1);
    dist[1]=0;
    visit[1]=true;
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(int i=1;i<=n;i++){
            if(i==now)continue;
            if(visit[i])continue;
            if(g[now][i]){
                dist[i]=dist[now]+1;
                que.push(i);
                visit[i]=true;
            }
        }
    }
    for(int i=1;i<=n;i++)cout<<i<<" "<<dist[i]<<endl;
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// s = "112223" -> [[1,2],[2,3],[3,1]]
vector<pair<int,int>> rle (vector<int> x) {
  vector<pair<int,int>> res;
  int n = (int)x.size();
  for (int i = 0; i < n;) {
    int j = i;
    int cnt = 0;
    while (j < n && x[j] == x[i]) {
      ++j;
      ++cnt;
    }
    res.emplace_back(x[i], cnt);
    i = j;
  }
  return res;
}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  auto p = rle(a);

  int ans = 0;
  rep(i,sz(p)) {
    if (p[i].se%2) ans++;
  }

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

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

int mincost(int n ,vector<int>&height)
{
     vector<int>dp(n,0);
     for(int i =1;i<n;i++)
     {    if(i==1)dp[i] = dp[i-1]+abs(height[i]-height[i-1]);
       else
       dp[i] = min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
     }
    return dp[n-1];
}
int main(){
    int n ;
  cin>>n;
  vector<int>height(n);
  for(int i=0;i<n;i++)
  {  cin>>height[i];
  }
  cout<<mincost(n,height)<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#pragma region Include/Defines
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <limits.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <memory.h>
#include <string.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <time.h>

using namespace std;
typedef long long lli;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
typedef vector<pii> vpii;
typedef vector <pll> vpll;
typedef long double ld;
#define all(a) std::begin(a), std::end(a)

const int INF = 0x3f3f3f3f;
const lli LINF = 0x3f3f3f3f3f3f3f3f;

template<typename T, typename T2> inline void _max(T &a, T2 b) { a = max((T)a, (T)b); }
template<typename T, typename T2> inline void _min(T &a, T2 b) { a = min((T)a, (T)b); }

#ifdef _DEBUG
#define epr(...) fprintf(stderr,__VA_ARGS__)
#else
#define epr(...) 
#endif
#pragma endregion

const int MAX = 1e5 + 10;
int n, a[MAX];

void clear() {
}

void read() {
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
}

void solve() {
	int res = 0;
	int p = -1, np = 0;
	for (int i = 0; i < n; i++)
		if (a[i] == p) np++;
		else {
			res += np / 2;
			np = 1, p = a[i];
		}
	res += np / 2;
	printf("%d\n", res);
}

int main() {
#ifdef _LOCAL_VAN
	freopen("in.txt", "r", stdin);
#endif
	while (scanf("%d", &n) == 1) {
		clear();
		read();
		solve();
#ifndef _LOCAL_VAN
		return 0;
#endif
	}
	return 0;
}

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

using namespace std;

int main()
{
    long long x;
    long long n=100;
    int sum=0;
    cin>>x;
    while(1)
    {
        sum++;
        n=n*1.01;
        if(n>=x)
            break;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3636
N,C,K=map(int,input().split())
TT=[int(input()) for _ in range(N)]
TT.sort()

B=0
L=0
ans=0
for T in TT:
  if B==0:
    L=T+K
    B=C-1
    ans+=1
  else:
    if L>=T:
      B-=1
    else:
      L=T+K
      B=C-1
      ans+=1
  #print(T,B,L)
print(ans)

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

using namespace std;

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

	if (N[N.size() -1] == '3') {
		cout << "bon" << endl;
	}
	else if (N[N.size() - 1] == '0' || N[N.size() - 1] == '1' || N[N.size() - 1] == '6' || N[N.size() - 1] == '8') {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
/*
Input
a と b が１つの空白で区切られて与えられます。

Output
面積と周の長さを１つの空白で区切って１行に出力して下さい。

Constraints
1 ≤ a, b ≤ 100
*/
#include <stdio.h>

int main(void) {
    int a, b;
    fscanf(stdin, "%d %d", &a, &b);
    
    printf("%d %d\n", a * b, a * 2 + b * 2);
    
    return 0;
}


Measured memory_bytes: 2104
tokens = gets.split

stack = []

until tokens.empty?
  token = tokens.shift

  case token
  when '+'
    a = stack.shift
    b = stack.shift
    stack.unshift(a + b)
  when '-'
    b = stack.shift
    a = stack.shift
    stack.unshift(a - b)
  when '*'
    a = stack.shift
    b = stack.shift
    stack.unshift(a * b)
  else
    stack.unshift(token.to_i)
  end
end

puts stack.shift

Measured memory_bytes: 8672
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int w,h,n;cin>>w>>h>>n;
	int sx,sy;cin>>sx>>sy;
	int x,y;
	int all=0;
	for(int i=1;i<n;i++)
	{
		cin>>x>>y;
		if((sx-x)*(sy-y)>=0)
		{
			all+=max(abs(sx-x),abs(sy-y));
		}
		else
		{
			all+=abs(sx-x)+abs(sy-y);
		}
		sx=x;sy=y;
	}
	cout<<all<<endl;
	return 0;
}

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

ll gcd(ll a, ll b ,ll c )
{
    ll gcd1=__gcd(a,b);
    ll gcd2=__gcd(gcd1,c);
    return gcd2;
}
int main()
{
    ll n,sum=0;
    cin>>n;
    ll i,j,k;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                sum=sum+gcd(i,j,k);
               //cout<<i<<" "<<j<<" "<<k<<" "<<gcd(i,j,k)<<endl;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

int main() {
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s, t; cin >> s >> t;
    int len = s.length();
    int tlen = t.length();
    if(tlen != len + 1){
        cout << "No";
        return 0;
    }
    for(int i = 0; i < len; ++i){
        if(s[i] != t[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
	
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<string> a(N);
	for (int i = 0; i < N; i++)
		cin >> a.at(i);
	bool b = true;
	for(int i = 0; i < N-1; i++){
		for(int j = i+1; j < N; j++){
			if(a.at(i) == a.at(j))
				b = false;
		}
	}
	for(int i = 0; i < N-1; i++){
		if(a.at(i)[a.at(i).size()-1] != a.at(i+1)[0])
			b = false;
	}
	string ans = (b == 1 ? "Yes" : "No");
	cout << ans << endl;
	return 0;
}

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

#define SORT(vec) sort(vec.begin(), vec.end());
typedef long long ll;

using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

	string S, T; cin >> S >> T;
	int ans = 0;

	for (int i = 0; i < 3; i++)
	{
		if (S[i] == T[i])
		{
			ans += 1;
		}
		
	}
	
	cout << ans << "\n";

}

Measured memory_bytes: 256
N= int(input())
E = [input().split()[2:] for _ in range(N)]
Q = [0]
L = [0] + [-1]*N
def func(ide):
    global Q
    for i in E[ide]:
        i = int(i) - 1
        if L[i] < 0 :L[i] = L[ide] +1 ;Q.append(i)
    

while Q:top = Q.pop(0);func(top)

for i in range(N):print(i + 1 ,int(L[i]))



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
vector<ll> test,raf;
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>m>>l>>k)
    {
        ll ara[n],bara[m],tara[l];
        for(i=0;i<n;i++) cin>>ara[i];
        for(i=0;i<m;i++) cin>>bara[i];
        for(i=0;i<l;i++) cin>>tara[i];
        test.clear();
        for(i=0;i<n;i++){
            for(j=0;j<m;j++) test.pb(ara[i]+bara[j]);
        }

        sort(test.begin(),test.end(),greater<ll>());
        sort(tara,tara+l);
        raf.clear();
        
        ll siz=test.size();
        for(i=0;i<min(k,siz);i++) {
            for(j=0;j<min(k,l);j++) raf.push_back(test[i]+tara[j]);
        }

        sort(raf.begin(),raf.end(),greater<ll>());
        siz=raf.size();
        for(i=0;i<siz && k;i++){
             cout<<raf[i]<<endl;
             --k;
        }

        
    }





}

Measured memory_bytes: 43236
def solve():
    def recur(i, n, total):
        # print("i, n, total", i, n, total)

        if not TABLE[i][n][total] == -1:
            return TABLE[i][n][total]

        if not i < N:
            if n > 0 and total == A * n:
                TABLE[i][n][total] = 1
                return TABLE[i][n][total]

            TABLE[i][n][total] = 0
            return TABLE[i][n][total]

        ans1 = recur(i + 1, n, total)
        ans2 = recur(i + 1, n + 1, total + XS[i])

        # print(ans1, ans2)

        TABLE[i][n][total] = ans1 + ans2
        return TABLE[i][n][total]

    N, A = tuple(map(int, input().split()))
    XS = tuple(map(int, input().split()))

    TABLE = []
    for _ in range(N + 1):
        lines = [[-1 for x in range(N * 50 + 1)] for y in range(N + 1)]
        TABLE.append(lines)

    return recur(0, 0, 0)


if __name__ == '__main__':
    print(solve())


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

struct topoloricalSort_runnner {
	typedef vector<vector<int>> Graph;
	vector<int> input;

	bool topologicalSort(const Graph& graph, vector<int>& order) {
		int n = graph.size();
		//入次数
		input.assign(n, 0);
		rep(i, n) {
			for (auto dest : graph[i]) {
				input[dest]++;
			}
		}
		//rootを幅優先探索
		queue<int> q;
		rep(i, n) {
			if (input[i] == 0) {
				q.push(i);
			}
		}
		int multiple = 0;
		while (!q.empty()) {
			//順位が一位に決まらない
			if (q.size() >= 2) {
				multiple = 1;
			}
			auto id = q.front(); q.pop();
			order.push_back(id);
			for (auto next : graph[id]) {
				//すべての親を処理し終わったら処理する
				input[next]--;
				if (input[next] == 0) {
					q.push(next);
				}
			}
		}
		return multiple;
	}
};


int main() {
	ll n,k;
	cin >> n >> k;
	vector<ll> as(n);
	vector<vector<ll>> rev(n);
	rep(i, n) {
		cin >> as[i];
		as[i]--;
	}
	ll sum = 0;
	if (as[0] != 0) {
		sum++;
		as[0] = 0;
	}
	rep(i, n) {
		rev[as[i]].push_back(i);
	}
	vector<ll> dist(n, -1);
	function<ll(ll, ll)> dfs = [&](ll current, ll parent){
		if (dist[current] >= 0) return dist[current];
		ll u = 0;
		for (auto p : rev[current]) {
			if (p == current) continue;
			ll d = dfs(p, current);
			chmax(u, d);
		}
		if (u >= k - 1 && parent != 0) {
			sum++;
			dist[current] = 0;
			return dist[current];
		}
		u++;
		//cout << current << " " << u << endl;
		dist[current] = u;
		return u;
	};
	dfs(0, 0);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 21204