akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct edge
{
        int to, c, h, r;
};

struct node
{
        int v, c, h;
        bool operator<(const node &u) const {
                if(c != u.c) return c > u.c;
                return h > u.h;
        }
};

int n, m, h, k, s, t, p;
int pass[256], done[128][32], ps[256];
vector<edge> G[128];

int dijkstra(int f, int ub)
{
        priority_queue<node> q;
        q.push((node){s,pass[f],0});
        memset(done,0,sizeof(done));

        while(!q.empty()) {
                node u = q.top(); q.pop();
                if(u.v == t or u.c >= ub) return u.c;
                if(done[u.v][u.h]) continue;
                done[u.v][u.h] = 1;

                for(auto &e: G[u.v]) {
                        if(u.h+e.h > h) continue;
                        if(f&(1<<e.r)) q.push((node){e.to, u.c, u.h+e.h});
                        else q.push((node){e.to, u.c+e.c, u.h+e.h});
                }
        }
        return 1e9;
}

int solve()
{
        pass[0] = 0;
        int ans = 1e9;
        for (int i = 0; i < 1<<k; i++) {
                if(pass[i] >= ans) continue;
                ans = min(ans, dijkstra(i, ans));
                for (int j = 0; j < p; j++) {
                        pass[i|ps[j]] = min(pass[i|ps[j]], pass[i]+pass[ps[j]]);
                }
        }

        return ans < 1e9? ans: -1;
}

void init()
{
        for (int i = 0; i < 128; i++) G[i].clear();
        fill(pass,pass+256,1e9);
}

bool input()
{
        cin >> n >> m >> h >> k;
        if(!n) return 0;
        init();
        for (int i = 0; i < m; i++) {
                int a, b, c, h, r;
                cin >> a >> b >> c >> h >> r;
                --a; --b; --r;
                G[a].push_back((edge){b,c,h,r});
                G[b].push_back((edge){a,c,h,r});
        }
        cin >> s >> t >> p;
        --s; --t;
        for (int i = 0; i < p; i++) {
                int l, d, a, as = 0;
                cin >> l >> d;
                for (int j = 0; j < l; j++) {
                        cin >> a;
                        as |= 1<<(a-1);
                }
                ps[i] = as;
                pass[as] = d;
        }
        return 1;
}

int main()
{
        while(input()) cout << solve() << endl;
        return 0;
}

Measured memory_bytes: 1512
//けんちょん見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

vector<int> places[210000];
ll dp[210000];

int main(){
  ll n;
  cin >> n;
  vector<int>c(n);
  for(int i=0; i<n; i++) cin >> c[i];
  for(int i=0; i<n; i++) places[c[i]].push_back(i);
  
  dp[0]=1;
  for(int i=0; i<=n; i++){
    dp[i]+=dp[i-1];
    dp[i]%=mod;
    
    ll color = c[i-1];
    ll it = lower_bound(places[color].begin(),places[color].end(),i-1)-places[color].begin();
    if(it>0){
      ll j = places[color][it-1];
      if((i-1)-j>1){
        dp[i]+=dp[j+1];
        dp[i]%=mod;
      }
    }
  }
  cout << dp[n] << endl;
}
  
  
  


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}

bool solve() {
	map<char,int> cnt;
	string w; cin >> w;
	for (auto&& a : w) {
		cnt[a]++;
	}
	bool ok = true;
	for (auto&& a : cnt) {
		if (a.second & 1) ok = false;
	}
	YesNo(ok);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


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

typedef long long ll;

int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vector<ll>a(x), b(y), c(z);
	for (auto&& i : a)cin >> i;
	for (auto&& i : b)cin >> i;
	for (auto&& i : c)cin >> i;
	
	vector<ll>ab, abc;
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < z; j++) {
			ab.push_back(a[i] + b[j]);
		}
	}
	sort(ab.rbegin(), ab.rend());

	for (int i = 0; i < min(k, (int)ab.size()); i++) {
		for (int j = 0; j < z; j++) {
			abc.push_back(ab[i] + c[j]);
		}
	}
	sort(abc.rbegin(), abc.rend());

	for (int i = 0; i < k; i++)cout << abc[i] << endl;

	return 0;
}

Measured memory_bytes: 43112
#include<bits/stdc++.h>
using namespace std;
int main(){
   // string ss ={ "Sunny","Cloudy" ,"Rainy"};
    string s;
    cin>>s;
    if(s== "Sunny")cout<<"Cloudy";
    if(s== "Cloudy") cout<<"Rainy";
    if(s== "Rainy")cout<< "Sunny";

}


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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()){
    mp[s[i]] += 1;
  }
  for(auto value: mp){
    if(value.second != 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
ar = []
mi = 0
mx = 0
count = 1
for i in range(n):
    a,b = map(int,input().split(" "))
    br = [a+b,a-b]
    ar.append(br)
ar.sort()
for i,r in enumerate(ar):
    if i == 0:
        mx = r[0]
    else:
        if mx <= r[1]:
            count += 1
            mx = r[0]
print(count)

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

// A

void solve() {

}

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,(int)s.size()) if( s[i] == 'R' ) ++cnt;
  if( cnt == 3 ) cout << cnt << endl;
  else if( cnt == 1 ) {
    cout << cnt << endl;
  } else if( cnt == 2 ) {
    if( s[1] == 'S' ) {
      cout << 1 << endl;
    } else {
      cout << cnt << endl;
    }
  } else cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}


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

  reverse(S.begin(), S.end());

  vector<string> kouhos = {"dream", "dreamer", "erase", "eraser"}; 
  rep(i, 4){
    reverse(kouhos[i].begin(), kouhos[i].end());
  }

  // rep(i, 4){
  //   cout << "hoge:" << kouhos[i] << endl;
  // }

  int idx = 0;
  while(S.size() != idx){
    bool found = false;
    for(string kouho: kouhos){
      string tmp = S.substr(idx, kouho.size());
      if(tmp == kouho){
        found = true;
        idx += kouho.size();
        // TODO: remove
        // cout << "found:" << kouho << endl;
        break;
      }
    }

    if(!found){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n, s) for (int i = 0; i < n; i += s)
#define graph map<int, vector<int>>
#define field vector<vector<int>>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n, 1)
    {
        cin >> a[i];
    }
    int ans = 0;
    rep(i, n, 2)
    {
        if (a[i] % 2 != 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N;
    cin>>N;
    vector<ll> v(N);
    rep(i,N) cin>>v[i];
    vector<pair<int,int>> ans;
    ll M=-INF,m=INF;
    ll p,q;
    rep(i,N) {
        if(chmax(M,v[i])) p = i;
        if(chmin(m,v[i])) q = i;
    }
    int patern;
    if(M>=0&&m>=0) patern = 1;
    if(M<0&&m<0) patern = 0;
    if(M>=0&&m<0){
        if(M>=-m){
            patern = 1;
            rep(i,N){
                if(i==p) continue;
                ans.push_back(make_pair(p,i));
                v[i]+=v[p];
            }
        }
        else {
            patern = 0;
            rep(i,N){
                if(i==q) continue;
                ans.push_back(make_pair(q,i));
                v[i]+=v[q];
            }
        }
    }
    if(patern == 1){
        rep(i,N-1){
            if(v[i]<=v[i+1]) continue;
            if(v[i+1]<0&&v[i]<=0) {
                ans.push_back(make_pair(i+1,i));
                v[i]+=v[i+1];
                continue;
            }
            if(0<v[i]&&0<=v[i+1]){
                ans.push_back(make_pair(i,i+1));
                v[i+1]+=v[i];
                continue;
            }
        }
    }
    else{
        for(ll i = N-2; i>=0; i--){
            if(v[i]<=v[i+1]) continue;
            if(v[i+1]<0&&v[i]<=0) {
                ans.push_back(make_pair(i+1,i));
                v[i]+=v[i+1];
                continue;
            }
            if(0<v[i]&&0<=v[i+1]){
                ans.push_back(make_pair(i,i+1));
                v[i+1]+=v[i];
                continue;
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto x:ans) cout<<x.first+1<<" "<<x.second+1<<endl;
}

Measured memory_bytes: 3624
# AOJ DSL_2_D
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D

INF = (-1, 2**31 - 1)
line = input()
n, q = list(map(int, line.split()))
N = 1
while N < n + 1:
    N *= 2
a = [INF for _ in range(0, 2 * N - 1)]

def find(i, k, l, r):
    z = a[0]
    while True:
        m = (l + r) // 2
        if i < m:
            k = k * 2 + 1
            r = m
        else:
            k = k * 2 + 2
            l = m
        z = max(z, a[k])
        if k >= N - 1:
            break
    return z[1]

def update(s, t, x, k, l, r):
    if r <= s or t <= l:
        return
    elif s <= l and r <= t:
        a[k] = x
        return
    m = (l + r) // 2
    update(s, t, x, k * 2 + 1, l, m)
    update(s, t, x, k * 2 + 2, m, r)
    return

for t in range(0, q):
    line = input()
    qu = list(map(int, line.split()))
    if qu[0] == 0:
        update(qu[1], qu[2]+1, (t, qu[3]), 0, 0, N)
    elif qu[0] == 1:
        ans = find(qu[1], 0, 0, N)
        print(ans)




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

typedef long long ll;
const int MAX_N = 1030;    // Change as necessary
const ll  MODD = 1000000009; //

char A[MAX_N][MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int m,n; cin >> m >> n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin >> A[i][j];
  
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(i == 0) { cout << "#"; continue; }
      if(i == m-1) { cout << "."; continue; }
      
      cout << (A[i][j] == '#' || j % 2 ? "#" : ".");
    }
    cout << endl;
  }
  cout << endl;
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(i == m-1) { cout << "#"; continue; }
      if(i == 0) { cout << "."; continue; }
      
      cout << (A[i][j] == '#' || j % 2 == 0 ? "#" : ".");
    }
    cout << endl;
  }
  
  return 0;
}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int n;
    cin >> n;

    map<string, int> mp;

    roop(i, n){
        string s; cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

    return 0;
}

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> x(N+1); x[0] = 0;
    vector<int> y(N+1); y[0] = 0;
    vector<int> t(N+1); t[0] = 0;
    for(int i=1;i<=N;i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i=1;i<=N;i++){
        int d = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
        if( !(t[i]-t[i-1] >= d && (t[i]-t[i-1]-d)%2==0) ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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


int main() {
     ll x;
     cin >> x;
     if (x%11==0){
     cout << x/11*2 <<endl;
     return 0;}
     else if(x%11<7){cout << x/11*2+1;
     return 0;}
     else cout << x/11*2+2<<endl;
  }

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

//入力に必要
int N,M;
int a[50],b[50];
//辺
bool graph[50][50];
//頂点
bool visited[50];

//今いる頂点 v
void dfs(int v){
	visited[v] = true;
	//次の頂点
	rep(v2,N){
		//繋がっていなかったら続ける
		if (graph[v][v2] == false) continue;
		//すでに訪れていたら終わりにする（終わりにならないので）
		if (visited[v2] == true) continue;
		dfs(v2);
	}
}

int main() {
	//N頂点, M辺
	cin>>N>>M;
	rep(i,M){
		cin>>a[i]>>b[i];
		//0indexの関係で
		a[i]--;b[i]--;
		//graph行列（繋がっているのでTrue）
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

	}
	//通ったかどうかをfalseで初期化
	rep(i,M) visited[i] = false;

	int ans = 0;
	//ある辺を除いたときに連結かどうか判定
	rep(i,M){
		//除いてみる
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		//頂点の訪れを初期化
		rep(j,N) visited[j] = false;

		//頂点0からスタート
		dfs(0);

		bool bridge = false;
		//もし一つでも訪れていない頂点があるなら
		//橋だったということ
		rep(j,N) if(visited[j] == false) bridge = true;
		if(bridge)ans++;

		//辺を復活させておく
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a = set(na())

if len(a) == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
#define int long long
using namespace std;
inline int read()
{
	int kkk=0,x=1;
	char c=getchar();
	while((c<'0' || c>'9') && c!='-')
		c=getchar();
	if(c=='-')
		c=getchar(),x=-1;
	while(c>='0' && c<='9')
		kkk=(kkk<<3)+(kkk<<1)+(c-'0'),c=getchar();
	return kkk*x;
}
int n,head[100001],tot;
struct node
{
	int sum,id,size,fa;
}a[100001];
struct sb
{
	int to,nextn;
}con[100001];
inline void ADD(int from,int to)
{
	con[++tot].to=to,con[tot].nextn=head[from];
	head[from]=tot;
}
inline int cmp(node x,node y)
{
	return x.sum>y.sum;
}
inline int find(int V)
{
	int l=1,r=n,bck=0;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(a[mid].sum>=V)
			bck=mid,l=mid+1;
		else
			r=mid-1;
	}
	return bck;
}
inline int check(int u,int fa)
{
	int bck=0;
	for(register int i=head[u];i!=0;i=con[i].nextn)
	{
		int v=con[i].to;
		if(v==fa)
			continue;
		bck+=check(v,u);
	}
	return bck+a[u].size-1;
}
signed main()
{
	n=read();
	for(register int i=1;i<=n;++i)
	{
		a[i].id=i;
		a[i].sum=read();
		a[i].size=1;
	}
	sort(a+1,a+n+1,cmp);
	a[0].sum=0x7f7f7f7f7f7f7f7f;
	for(register int i=1;i<n;++i)
	{
		int sum=a[i].sum+a[i].size-(n-a[i].size);
		if(sum>=a[i].sum)
		{
			puts("-1");
			return 0;
		}
		int zone=find(sum);
		if(a[zone].sum!=sum)
		{
			puts("-1");
			return 0;
		}
		a[zone].size+=a[i].size;
		a[i].fa=zone;
		ADD(zone,i);
	}
	if(check(n,0)!=a[n].sum)
	{
		puts("-1");
		return 0;
	}
	for(register int i=1;i<n;++i)
		printf("%lld %lld\n",a[i].id,a[a[i].fa].id);
	return 0;
}

Measured memory_bytes: 8192
#include <stdio.h>

int main(int argc, char *argv[])
{
        int n, i, x;

        scanf("%d", &n);

        for (i = 1; i <= n; i++) {
                x = i;
                if (x % 3 == 0) {
                        printf(" %d", i);
                        continue;
                }
                while (x) {
                        if (x % 10 == 3) {
                                printf(" %d", i);
                                break;
                        }
                        x /= 10;
                }
        }
        printf("\n");

        return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>

int main(){
	char a[69];
	int i, j=0, flag=0, len;
	scanf("%s", &a);
	
	len = strlen(a);
	
	if(a[0] == 'A'){
		for(i=2; i<len-1; i++){
			if(a[i]=='C'){
				j =1;
				break;
			}
		}
		
		if(j==0){
				printf("WA\n");
				return 0;
			}
		
		for(i=0; i<len; i++){
			if(a[i]>='a' && a[i] <='z'){
				flag++;
			}
		}

		
		if(flag==len-2){
			printf("AC\n");
		}
		else{
			printf("WA\n");
		}
	}
	
	
	else{
		printf("WA\n");
	}
	
	
	return 0;
}


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

 int main() 
    {
    	int n,k;
    	cin>>n>>k;
    	int arr[n];
    	for(int i=0;i<n;i++)
    	 cin>>arr[i];
    	 
    	 int dp[n];
    	 
    	 
    	dp[0]=0; dp[1]=abs(arr[1]-arr[0]);
    	 
    	 for(int i=2;i<n;i++)
    	  {
    	      int j=i-k;
    	      if(j<0)
    	      j=0;
    	      int res=INT_MAX;
    	      for(int k=j;k<i;k++)
    	       {
    	         res=min(res,dp[k]+abs(arr[i]-arr[k]));
    	       }
    	      dp[i]=res;
    	      
    	  }
    	 cout<<dp[n-1];
    	 
    	 return 0;
    	
    }

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int week = sc.nextInt();
		long money = 100000;
		
		for(int i = 0; i < week; i++){
			money += getInterest(money);
			money = revaliationMoney(money);
		}
		
		System.out.println(money);
	}
	
	private static long getInterest(long money){
		return money * 5 / 100;
	}
	
	private static long revaliationMoney(long money){
		long fraction = money % 1000;
		if(fraction != 0){
			money = money - fraction;
			return money + 1000;
		}
		else{
			return money;
		}
	}
}

Measured memory_bytes: 12000
//#pragma GCC optimize (2)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
ll quick_pow(ll base, ll n) {
    ll ans = 1;
    while (n ) {
        if (n & 1 )
            ans *= base;
        base *= base;
        n >>= 1;
    }
    return ans;
}
void solve();
int main() {
    int T=1;
    //cin>>T;
    while (T--){
        solve();
    }
    return 0;
}
void solve(){
    char ch;
    cin>>ch;
    cout<<(isupper(ch)?"A":"a");
}

Measured memory_bytes: 3616
#!/usr/bin/env ruby
n = STDIN.readline().strip.to_i
s = STDIN.readline().strip.chars
def make_direction(s)
  n = s.length
  w, e = [], []
  w[0], e[0] = 0, 0
  for i in (1..n) do
    w[i] = w[i-1] + (s[i-1] == 'W' ? 1 : 0)
  end
  w[n+1], e[n+1] = 0, 0
  n.downto(1) do |i|
    e[i] = e[i+1] + (s[i-1] == 'E' ? 1 : 0)
  end
  w.shift
  w.pop
  e.shift
  e.pop
  # puts "s:#{s}"
  # puts "w:#{w}"
  # puts "e:#{e}"
  # puts "d:#{e.zip(w).map{|e, w| e + w }}"
  e.zip(w).map{|e, w| e + w }
end
def search_min(e_w)
  min, i = e_w.each_with_index.min
  min - 1
end
puts "#{search_min(make_direction(s))}"


Measured memory_bytes: 50920
import java.util.Scanner;

public class Main 
{
	static int gcd(int a, int b)
	{
		if (b == 0) 
			return a; 
		int mod = a%b;
		if(mod<0)mod+=b;
		return gcd(b, mod);
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int[][] gc = new int[201][201];
		
		for(int i = 1; i <= 200; i++)
		{
			for(int j = 1; j <= 200; j++)
			{
				gc[i][j] = gcd(i,j);
			}
		}
		
		int n = sc.nextInt();
		long an = 0;
		
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				for(int k = 1; k <= n; k++)
				{
					an += gc[gc[i][j]][k];
				}
		
		System.out.println(an);
		
	}

}


Measured memory_bytes: 27424
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl k,s;
    cin >> k >> s;
    intl cnt = 0;
    intl a = min(k,s);
    repd(i, a){
        repd(j, a){
            if(i + j > s)continue;
            if(s - i - j <= k)cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

constexpr int MAXN = 1e3 + 1;
constexpr int MOD = 1e9 + 7;
char grid[MAXN][MAXN];
int pos[MAXN][MAXN];
int table[MAXN][MAXN];

int main(void)
{
    int H, W;
    cin >> H >> W;
    for (int i = 1; i <= H; i++)
        for (int j = 1; j <= W; j++)
            cin >> grid[i][j];

    for (int i = 1; i <= H; i++)
        for (int j = 1; j <= W; j++)
            pos[i][j] = (grid[i][j] == '.');

    // initialization:
    for (int j = 1; j <= W; j++)
    {
        if (pos[1][j] == 1)
            table[1][j] = 1;
        else
            break;
    }

    for (int i = 2; i <= H; i++)
        for (int j = 1; j <= W; j++)
        {
            if (pos[i][j] == 0)
                table[i][j] = 0;
            else
                table[i][j] = (table[i - 1][j] + table[i][j - 1]) % MOD;
        }

    cout << table[H][W] << "\n";
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li x;
    cin>>x;
    cout<<(x>=30 ? "Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;

const int MAX = 510000;
ll fact[MAX];
ll inv[MAX];
ll finv[MAX];

void init(){
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<MAX;i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll choose(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    init();
    ll sum[n];
    sum[n-1] = m;
    ll x = m-1;
    for(int i=n-2;i>=0;i--){
        sum[i] = ( choose(n-1,i) * m )%MOD  * x % MOD;
        x = x*(m-1)%MOD;
    }
    ll ans=0;
    for(int j=0;j<=k;j++){
        ans += sum[j];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17108
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  vector<vector<int> > A(3,vector<int>(3));
  cin>>A;

  auto check=[&](int a1,int a2,int a3,int b1,int b2,int b3){
    int a[] = {a1,a2,a3};
    int b[] = {b1,b2,b3};
    for(int i=0;i<3;i++)
      for(int j=0;j<3;j++) if(A[i][j] != a[i] + b[j]) return 0;
    return 1;
  };
  
  int ans = 0;
  for(int a1 = -500; a1 <= 500; a1++){
    int b1 = A[0][0] - a1;
    int b2 = A[0][1] - a1;
    int b3 = A[0][2] - a1;
    int a2 = A[1][0] - b1;
    int a3 = A[2][0] - b1;
    ans |= check(a1,a2,a3,b1,b2,b3);
  }

  cout<<(ans? "Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N,K;

Int a[100010];
Int s[100010], p_s[100010];

int main(){
	cin>>N>>K;
	REP(i,N)cin>>a[i];
	s[0] = p_s[0] = 0;
	REP(i,N){
		s[i+1] = s[i] + a[i];
		p_s[i+1] = p_s[i] + (a[i]>0?a[i]:0);
	}
	Int ans = 0;
	for(int i=0;i<=N-K;i++){//i,i+1,...,i+K-1
		Int t = p_s[i] + p_s[N] - p_s[i+K];
		Int u = max(s[i+K]-s[i],(Int)0);
		t+=u;
		ans=max(t,ans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = NextInt();
        int[] L = LineInt();
        Array.Sort(L);
        Console.WriteLine(L.Take(N-1).Sum() > L[N-1]?"Yes":"No");
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13524
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    if((a==1||a==3||a==5||a==7||a==8||a==10||a==12)&&(b==1||b==3||b==5||b==7||b==8||b==10||b==12)){
        cout << "Yes" << endl;
    }
    else if((a==4||a==6||a==9||a==11)&&(b==4||b==6||b==9||b==11)){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
        
}


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

const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
bool check[1 << 12];
int H, W, K, dp[50][50][1 << 12];
char Gifts[50][50];

int main(){

  cin >> H >> W >> K;
  const int mask = (1 << (K * 4)) - 1;
  for(int i = 0; i <= mask; ++i){
    bool flag = false;
    int y = 0, x = 0, bit = i;
    for(int j = 0; j < 2 * K; ++j){
      y -= dy[bit & 3], x -= dx[bit & 3];
      if(y == 0 && x == 0){
        flag = true;
        break;
      }
      bit >>= 2;
    }
    check[i] = !flag;
  }

  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> Gifts[i][j];
    }
  }
  fill_n( **dp, 50 * 50 * (1 << 12), -1);
  // dp[i][j][S]: ( j, i)にいるときの前に訪れる方法Sにおいての最大値
  dp[0][0][0] = 0;
  for(int i = K; i >= 0; --i){
    for(int j = 0; j < H; ++j){
      for(int k = 0; k < W; ++k){
        for(int l = 0; l <= mask; ++l){
          if(dp[j][k][l] == -1) continue;
          int cost;
          if(isdigit(Gifts[j][k]) && check[l]) cost = Gifts[j][k] - '0';
          else cost = 0;
          for(int m = 0; m < 4; ++m){
            int ny = j + dy[m], nx = k + dx[m];
            if((m > 1 && i == 0) || ny < 0 || ny >= H || nx < 0 || nx >= W || Gifts[ny][nx] == '#') continue;
            int& res = dp[ny][nx][(l << 2 | m) & mask];
            res = max( res, dp[j][k][l] + cost);
          }
        }
      }
    }
  }
  int ret = 0;
  for(int i = 0; i <= mask; ++i){
    ret = max( ret, dp[H - 1][W - 1][i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 41164
#include <bits/stdc++.h>
#define FIO "d"
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define lb(x) ((x)&(-(x)))
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 200010
using namespace std;
typedef long long ll;
int n,m,a[N],cnt[N],b[N],ans;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]++;
	for(int i=1;i<=n;i++)for(int j=max(1,i-cnt[i]+1);j<=i;j++)b[j]++;
	for(int i=1;i<=n;i++)if(!b[i])ans++;
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		if(a[x]-cnt[a[x]]+1>=1&&!--b[a[x]-cnt[a[x]]+1])ans++;cnt[a[x]]--;
		if(y-cnt[y]>=1&&++b[y-cnt[y]]==1)ans--;cnt[y]++;
		a[x]=y;
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
    // 変数宣言、初期設定
    int n, m, x;
    cin >> n >> m >> x;
    int C[n];
    int A[n][m];
    int skill[m];
    int money, ans;
    ans = 2000000;
    bool ok = 1;
    bool flag = 0;
    for (int i=0; i<n; i++) {
        cin >> C[i];
        for (int j=0; j<m; j++) {
            cin >> A[i][j];
        }
    }


    for (int bit = 0; bit < (1<<n); bit++) {
        bitset<12> s(bit);
        //初期化
        ok = 1;
        money = 0;
        for (int j=0; j<m; j++) skill[j] = 0;

        for (int i=0; i<n; i++) {
            if (s.test(i)) {
                for (int j=0; j<m; j++) {
                    skill[j] += A[i][j];
                }
                money += C[i]; 
            }
        }
        for (int j=0; j<m; j++) {
            if (skill[j] < x) {
                ok = 0; //処理を抜ける
                break;
            }
        }
        if (ok) ans = min(ans, money);
    }

    if (ans == 2000000) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }

}

Measured memory_bytes: 3676
ans = ''
while True:
    h, w = map(int, input().split(' '))
    if h == 0 and w == 0:
        break
    else:
        i = 0
        s = ''
        while i < h:
            s += '#' * w
            s += '\n'
            i += 1
        ans += s + '\n'
if ans != '':
    print(ans[:-1])


Measured memory_bytes: 5704
<?php
fscanf(STDIN, '%d %d', $h, $w);
for($i = 1; $i <= $h; $i++) {
    fscanf(STDIN, '%s', $s);
    $map[$i] = '#' . $s . '#';
}
$map[0] = $map[$h + 1] = str_repeat('#', $w + 2);

// 横方向
for($i = 1; $i <= $h; $i++) {
    $dw = 0;
    for($j = 1; $j <= $w + 1; $j++) {
        if ($map[$i][$j] === '#') {
            for ($k = $j - $dw; $k < $j; $k++) $hlight[$i][$k] = $dw;
            $dw = 0;
        } else {
            $dw++;
        }
    }
}

// 縦方向
$max = 0;
for($j = 1; $j <= $w; $j++) {
    $dw = 0;
    for($i = 1; $i <= $h + 1; $i++) {
        if ($map[$i][$j] === '#') {
            for ($k = $i - $dw; $k < $i; $k++) {
                $vlight[$k][$j] = $dw;
                $light = $hlight[$k][$j] + $vlight[$k][$j] - 1;
                $max = max($light, $max);
            }
            $dw = 0;
        } else {
            $dw++;
        }
    }
}
echo $max . PHP_EOL;

Measured memory_bytes: 311800
package main

import "fmt"

func getFirstRune(s string) (f rune) {
	for i, r := range s {
		if i == 0 {
			f = r
			break
		}
	}
	return
}

func main() {
	var N int
	fmt.Scan(&N)
	names := make(map[rune]int, N)
	for i := 0; i < N; i++ {
		var tmp string
		fmt.Scan(&tmp)
		r := getFirstRune(tmp)
		switch r {
		case 'M', 'A', 'R', 'C', 'H':
			names[r]++
		}
	}
	var nums []int
	for _, v := range names {
		nums = append(nums, v)
	}
	cnt := 0
	for i := 0; i < len(nums)-2; i++ {
		for j := i + 1; j < len(nums)-1; j++ {
			for k := j + 1; k < len(nums); k++ {
				cnt += nums[i] * nums[j] * nums[k]
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 3840
n=int(input())
xy=[]
for i in range(n):
  t_a=int(input())
  xy.append([list(map(int,input().split())) for i in range(t_a)])

ans=0
for i in range(2**n):
  list=[[] for j in range(n)]
  honest=[]
  for k in range(n):
    if (i>>k)&1:
      honest.append(k)
      for x,y in xy[k]:
        x-=1
        list[x].append(y)

  check=1
  for m in range(n):
    t_l=list[m]
    if t_l:
      if 0 in t_l and 1 in t_l:
        check=0
      elif 1 in t_l and m not in honest:
        check=0
      elif 0 in t_l and m in honest:
        check=0

  if check==1:
    ans=max(ans,len(honest))

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int N, K, X, Y, ans = 0;

  cin >> N >> K >> X >> Y;

  for(int i = 1;i <= N;i++){
    if(i <= K){
      ans += X;
    } else {
      ans += Y;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {

    int a[10];
    int pri;
    for(int i=1; i<=5; i++) {
        cin>>a[i];
        if(a[i]==0)
            pri=i;
    }
    cout<<pri<<endl;

    return 0;
}


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

shop = []

ans = 0

num = 0

for i in range(N):
  shop.append(list(map(int, input().split())))
  
shop = sorted(shop)
  
for i in range(N):
  for b in range(shop[i][1]):
    if (num == M):
      break
    num += 1
    ans += shop[i][0]
    
print(ans)

Measured memory_bytes: 28656
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  PI acos(-1.0)
#define casePrint(t) printf("Case %d: ",t);

using vi = vector<int>;
using pi = pair<int, int>;
using ll = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

const int mxn = 2e5+10;
const int Mod = 1e9+7;

void solve()
{
    string str1, str2;
    cin>>str1>>str2;
    int ct = 0;
    for(int i=0 ; i<str1.size() ; i++){
        if(str1[i] != str2[i]) ct++;
    }
    cout<<ct<<endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int tc = 1;
    //cin>>tc;
    while(tc--) solve();

    return 0;
}


Measured memory_bytes: 3800
n,m=map(int,input().split())
x=[]
for i in range (m):
    a,b =map(int,input().split())
    x.append(a)
    x.append(b)

for i in range (n):
    cnt=0
    for j in range(m*2):
        if x[j]==i+1:
            cnt = cnt+1
    print(cnt)


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,L=map(int,input().split())
    A=list(map(int,input().split()))

    for i in range(n-1):
        if(A[i]+A[i+1]>=L):
            print("Possible")
            break
    else:
        print("Impossible")
        return

    for j in range(1,i+1):
        print(j)
    for j in range(n-1,i,-1):
        print(j)
resolve()

Measured memory_bytes: 63984
N, K = map(int, input().split())
S = str(input())

ans = ''
ans += S[:K-1]
if S[K-1] == 'A':
  ans += 'a'
elif S[K-1] == 'B':
  ans += 'b'
else:
  ans += 'c'
ans += S[K:]
print(ans)

Measured memory_bytes: 9012
N,M = (int(x) for x in input().split())

cnt_ac = [0]*N
cnt_wa = [0]*N
for i in range(M):
  p_i,S_i = (x for x in input().split())
  p_i = int(p_i)
  
  if S_i == 'AC' and cnt_ac[p_i-1] == 0:
    cnt_ac[p_i-1] += 1
    
  elif S_i == 'WA' and cnt_ac[p_i-1] == 0:
    cnt_wa[p_i-1] += 1
    
for i in range(N):
  if cnt_ac[i] == 0:
    cnt_wa[i] = 0
    
print(sum(cnt_ac),sum(cnt_wa))

Measured memory_bytes: 4596
#include <iostream>
#include<vector>
#include<stdlib.h>
#include<algorithm>
#include<string>
using namespace std;



int main(void){

	int height[10];
	int max1=0, max2=0, max3=0;

	for (int i = 0; i < 10; i++){

		cin >> height[i];	
	}



	for (int i = 0; i < 9; i++){
	
		for (int j = i + 1; j < 10; j++){
		
			if (height[i] < height[j]){
				swap(height[i], height[j]);
			}
		
		}
	}

	
	cout << height[0] << endl;
	cout << height[1] << endl;
	cout << height[2] << endl;

	
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-

def comb(n,k,p):
  ans = 1
  for i in range(1,k+1):
    ans = ans * (n - (i-1)) % p
    ans = ans * pow(i, p-2, p)
  return ans

n,a,b = map(int, input().split())
p = 10**9 + 7


A = comb(n, a, p) % p
B = comb(n, b, p) % p

MAX = pow(2, n, p)-1

ans = MAX - A - B 
ans = ans%p

print(ans)

Measured memory_bytes: 40428
#!/usr/bin/env ruby

CAKE = 4
DOUGHNUT = 7

def dividable?(num)
  num % CAKE == 0 || num % DOUGHNUT == 0
end

def wfs(num)
  queue = [num]
  while ! queue.empty? do
    current = queue.shift
    next if current < CAKE
    return true if dividable?(current)
    queue.push(current - CAKE, current - DOUGHNUT)
  end
  return false
end

puts wfs(gets.to_i) ? "Yes" : "No"


Measured memory_bytes: 1788
t=input()
s=list(t)
k=int(input())
if s==[s[0]]*len(s):
  print((len(s)*k)//2)
  exit()
b=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:b[-1]+=1
  else:b.append(1)
ans=0
for i in b:ans+=i//2*k
if t[0]==t[-1] and (b[0]+b[-1])%2==0:ans+=k-1
print(ans)


Measured memory_bytes: 9116
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
ans = 'Yes'

for a in A:
    if a[0] % 2 == 0:
        if (a[1] + a[2]) % 2 != 0 or (a[1] + a[2]) > a[0]:
            ans = 'No'
            break
    else:
        if (a[1] + a[2]) % 2 == 0 or (a[1] + a[2]) > a[0]:
            ans = 'No'
            break

print(ans)

Measured memory_bytes: 27300
n = int(input())
ans = []
start = ("a", 1, ord("a"))
stack = []
stack.append(start)
num = ord("a")
while stack:
    v, nagasa, mx = stack.pop()
    if nagasa == n:
        ans.append(v)
        continue
    for i in range(num, mx + 2):
        tuika = chr(i)
        mx = max(i, mx)
        stack.append((v + tuika, nagasa + 1, mx))
print(*ans[::-1], sep="\n")


Measured memory_bytes: 14520
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;
vi a(200000);

bool solve(ll m)
{
	ll cnt=0;
	for(ll i=0;i<n;i++){
		cnt+=((a[i]+m-1)/m);
	}
	cnt-=n;
	return (cnt<=k);
}

int main(){
  ll ans=0;
  cin >> n >> k;
  //vi a(n);
  REP(i,n) cin>>a[i];



	//2分岐探索
	ll ok=1000000000;//解が存在する値
	ll ng=-1;//解が存在しない値
	while(abs(ok-ng)>1)
	{
	ll mid=(ok+ng)/2;
	if (mid==0){
		ok=1;
		break;
	}
	if (solve(mid))//これを満たす最小のmidがokになる
	{
		ok=mid;
	}
	else
	{
		ng=mid;
	}
	}
	//okの値を使う
  ans=ok;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ( A+B > C+D ) {
    cout << "Left" << endl;
  }
  // ここにプログラムを追記
  else if ( A+B == C+D ) {
    cout << "Balanced" << endl;
  }
    else if ( A+B < C+D ) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var n = Integer.parseInt(br.readLine());
      final var k = Integer.parseInt(br.readLine());
      final var x = Integer.parseInt(br.readLine());
      final var y = Integer.parseInt(br.readLine());

      if (n <= k) {
        System.out.println(x * n);
      } else {
        System.out.println(x * k + y * (n - k));
      }
    }
  }
}


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

typedef long long ll;

ll A, B, N;

ll f(ll x) {
    return ((A * x) / B) - A * (x / B);
}

void solve() {
    cin >> A >> B >> N;
    ll x;
    if (N < B) {
        x = N;
    } else {
        x = B - 1;
    }
    cout << f(x) << '\n';
}

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

    solve();
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
    cout << "Yes";
  }
  else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){
    cout << "Yes";
  }
  else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
// glory be to the sky
#include<cstdio>
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	ll mod = (ll) 1e9 + 7;
	ll power = 1;
	for (int i = 1; i <= N; i++) {
		power = (power % mod * (ll) i % mod) % mod;
	}
	cout << power << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int MAXN = 100005;

int n, x, y, z, a[MAXN], b[MAXN], c[MAXN], bit[MAXN], tot;
int ao[MAXN], bo[MAXN], co[MAXN], ord[MAXN], cnt[MAXN];
LL bits[MAXN], sum, ans;

inline bool cmpa(const int &p, const int &q){
	return a[p] > a[q];
}
inline bool cmpb(const int &p, const int &q){
	return b[p] > b[q];
}
inline bool cmpc(const int &p, const int &q){
	return c[p] > c[q];
}
inline void update(int p, int v){
	for(; p <= n; p += p & -p)
		bit[p] += v;
}
inline void updates(int p, int v){
	for(; p <= n; p += p & -p)
		bits[p] += v;
}
void insert(int p){
	if(!(cnt[p] ++)){
		sum += a[p], ++ tot;
		update(ord[p], 1);
		updates(ord[p], b[p]);
	}
}
void remove(int p){
	if(!(-- cnt[p])){
		sum -= a[p], -- tot;
		update(ord[p], -1);
		updates(ord[p], -b[p]);
	}
}
LL getAns(){
	int i, j, c = 0; LL s = 0LL;
	for(i = 1 << 16, j = 0; i; i >>= 1)
		if(i + j <= n && c + bit[i + j] <= z)
			j += i, s += bits[j], c += bit[j];
	return s;
}
int main(){
	int i, j;
	scanf("%d%d%d", &x, &y, &z);
	n = x + y + z;
	for(i = 1; i <= n; ++ i){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
		sum += b[i], a[i] -= b[i], c[i] -= b[i];
		b[i] = c[i] - a[i];
		ao[i] = bo[i] = co[i] = i;
	} sort(ao + 1, ao + 1 + n, cmpa);
	sort(bo + 1, bo + 1 + n, cmpb);
	for(i = 1; i <= n; ++ i)
		ord[bo[i]] = i;
	sort(co + 1, co + 1 + n, cmpc);
	for(i = 1; i <= x + z; ++ i)
		insert(co[i]);
	ans = max(ans, sum + getAns());
	for(i = 1, j = x + z; i <= x + z; ++ i){
		insert(ao[i]);
		while(tot > x + z)
			remove(co[j --]);
		ans = max(ans, sum + getAns());
	} cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4480