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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return n<k ? 0 : fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i]; sort(A,A+N);
  ll result = 0;
  c_fac();
  rep(i,N) {
    // cout << i << " " << nck(i,K-1) << " " << nck(N-1-i,K-1) << endl;
    result += A[i] * (nck(i,K-1)-nck(N-1-i,K-1));
    result = (result%MOD+MOD)%MOD;
  }
  cout << result << endl;
  return 0;
}

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

const int inF = 1e9 + 100;

int a, b, c;
int ans = inF;

int f(int x, int y) {
	if(x >= y)
		return x - y;
	return ((y - x) >> 1) + (((y - x) & 1) << 1);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a >> b >> c;
	for (int x = -100; x <= 100; x++)
		ans = min(ans, f(a, x) + f(b, x) + f(c, x));
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

string s;
int a[MAXN];
int n;
int cnt;
int ret[MAXN][3];
int cur[3];
int nmod[MAXN];
int corr[MAXN];
int f[MAXN];

int solve(int k) {
	if (!k) {
		return 0;
	}
	int & ret = f[k];
	if (ret >= 0) {
		return ret;
	}
	ret = 1 + solve(k % __builtin_popcount(k));
	return ret;
}


int main() {
	cout << fixed << setprecision(12);	
	memset(f, -1, sizeof(f));
	for (int i = 0; i < MAXN; i++) {
		f[i] = solve(i);
	}

	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i++) {
		a[i] = s[i] - '0';
		cnt += a[i];		
	}
	for (int j = 0; j < 3; j++) {
		cur[j] = 1;
	}
	for (int i = n - 1; i >= 0; i--) {
		if (a[i]) {
			nmod[i] = 0;	
			corr[i] = -cur[nmod[i]];
		} else {
			nmod[i] = 2;
			corr[i] = cur[nmod[i]];
		}
		for (int j = 0; j < 3; j++) {
			int mod = cnt + j - 1;
			if (!mod) {
				continue;
			}
			ret[i][j] = ret[i + 1][j];
			ret[i][j] += cur[j] * a[i];
			ret[i][j] %= mod;
			cur[j] <<= 1;
			cur[j] %= mod;
		}
	}
	for (int i = 0; i < n; i++) {
		int ans = ret[0][nmod[i]];
		int cmod = nmod[i] + cnt - 1;
		if (!cmod) {
			cout << 0 << endl;
			continue;
		}
		ans += corr[i];
		ans = (ans + cmod) % cmod;
		cout << f[ans] + 1 << endl;	
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 12456
#include <stdio.h>
int main(void){
    int n,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        x=i;
        if(x%3==0){
            printf(" %d",i);
        }
       else{
            do{
                if(x%10 == 3){
                    printf(" %d",i);
                    break;
                }
                x /=10;
            }while(x);
        }
    }
    printf("\n");
}



Measured memory_bytes: 2140
#include <stdio.h>
#define INF 100000001
#define N 100

void matrixChainOrder(int);
int min(int, int);

int n,k,i,j,q,l;
int p[N],m[N][N];

int main(){

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  matrixChainOrder(n);

  printf("%d\n",m[1][n]);

  return 0;
}

void matrixChainOrder(int n){


  for(i=1; i<=n; i++){
    m[i][i] = 0;
  }

  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j=i+l-1;
      m[i][j] = INF;
      for(k=i;k<=j-1;k++){
    q= m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
    m[i][j] = min(m[i][j], q);
      }
    }
  }
}

int min(int x, int y){
  if(x < y) return x;
  else if(x > y) return y;
  else if(x == y) return x;
}

Measured memory_bytes: 636
s = input()
l = len(s)
l_half = int((l-1)/2)
isP = True
for i in range(l_half):
    isP *= s[i] == s[l - 1 - i]

for i in range(l_half//2):
    isP *= s[i] == s[l_half - 1 - i]
    isP *= s[l_half + 1 + i] == s[l - 1 - i]
print("Yes" if isP else "No")

Measured memory_bytes: 3064
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,u,v;
LL tr[maxn<<2],lz[maxn<<2];
vector<int> ve[maxn];
inline void pushdown(int x,int l,int r){
    tr[x<<1] += lz[x]*l;
    tr[x<<1|1] += lz[x]*r;
    lz[x<<1] += lz[x];
    lz[x<<1|1] += lz[x];
    lz[x] = 0;
}
void updata(int l,int r,int L,int R,int x,int val){
    if(l > R || r < L) return;
    if(l >= L && r <= R){
        tr[x] += 1ll*val*(r-l+1);
        lz[x] += val;
        return ;
    }
    int mid = (l+r) >> 1;
    if(lz[x]) pushdown(x,mid-l+1,r-mid);
    updata(l,mid,L,R,x<<1,val);
    updata(mid+1,r,L,R,x<<1|1,val);
    tr[x] = tr[x<<1] + tr[x<<1|1];
}
void query(int l,int r,int L,int R,int x,LL &sum){
    if(l > R || r < L) return;
    if(l >= L && r <= R){
        sum += tr[x];
        return ;
    }
    int mid = (l+r) >> 1;
    if(lz[x]) pushdown(x,mid-l+1,r-mid);
    query(l,mid,L,R,x<<1,sum);
    query(mid+1,r,L,R,x<<1|1,sum);
    tr[x] = tr[x<<1] + tr[x<<1|1];
}
int main(){
    scanf("%d",&n);
    for(int i = 1;i < n; ++i){
        scanf("%d %d",&u,&v);
        ve[max(u,v)].push_back(min(u,v));
    }
    LL ans = 0;
    for(int i = 1;i <= n; ++i){
        updata(1,n,1,i,1,1);
        sort(all(ve[i])); int pre = 1;
        for(int j = 0;j < sz(ve[i]); ++j){
            updata(1,n,pre,ve[i][j],1,j-sz(ve[i])+1);
            pre = ve[i][j]+1;
        }
        if(sz(ve[i])) updata(1,n,1,ve[i][sz(ve[i])-1],1,-1);
        query(1,n,1,i,1,ans);
        //cout <<i << " "<< ans << endl;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
    string ss;
    cin >> ss;
    if(ss[0]=='A'){
        for(int i=1; i<ss.length(); i++){
            if(ss[i]=='A')
                continue;
            else{
                cout << "Yes";
                return 0;
            }
        }
    }
    if(ss[0]=='B'){
        for(int i=1; i<ss.length(); i++){
            if(ss[i]=='B')
                continue;
            else{
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATwoCoins solver = new ATwoCoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATwoCoins {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.print(in.nextInt() + in.nextInt() >= in.nextInt() ? "Yes" : "No");
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}


Measured memory_bytes: 23380
#include<stdio.h>
#include <iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<math.h>
#include<queue>
#include<stack>
#include<list>
#include<vector>
#include<map>
#include<set>
#define FOR(i,a) for(int i=0;i<a;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define ll long long
int bmap[]={ 0,1,0,-1 };
int amap[]={ 1,0,-1,0 };
using namespace std;
int a, b, c,x;
string s[10];
int ans = 0;
int main() {
	cin >> a >> b >> c >>x;
	FOR(i, a+1)FOR(j, b+1)FOR(k, c+1) {
		if (500 * i + j*100 + 50 * k == x)ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    long long n, m;
    cin >> n >> m;
    long long a, b;
    vector<pair<long long , long long>> v;
    for(long long i = 0; i < n; ++i){
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    for(long long i = 0; i < n; ++i){
        if(m >= v[i].second){
            ans += v[i].first * v[i].second;
            m -= v[i].second;
        }else{
            ans += v[i].first * m;
            cout << ans;
            return 0;
        }
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <cassert>
#include <set>
using namespace std;

int main() {
	string s;
	cin >> s;
	if(s.size() < 26) {
		vector<bool> vis(26);
		for(char &ch: s) {
			vis[ch - 'a'] = true;
		}
		int idx = -1;
		for(int i = 0; i < 26; i++) {
			if(vis[i] == false) {
				idx = i; break;
			}
		}
		assert(idx != -1);
		s.push_back(idx + 'a');
	} else {
		int idx = -1;
		set<char> S;
		S.insert(s.back());
		for(int i = s.size() - 2; i >= 0; i--) {
			S.insert(s[i]);
			if(s[i] < s[i + 1]) {
				idx = i;
				break;
			}
		}
		if(idx == -1) s = "-1";
		else {
			s[idx] = *S.upper_bound(s[idx]);
			s.resize(idx + 1);
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll A[200000];
ll F[200000];

int main()
{
	int N;
	ll K;

	cin >> N >> K;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> F[i];

	sort(A, A + N);
	sort(F, F + N, greater<ll>());

	ll ok = (ll)1e12, ng = -1;

	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		ll cost = 0;

		rep(i, N) {
			ll dif = A[i] * F[i] - mid;
			if (dif <= 0) continue;
			cost += (dif + F[i] - 1) / F[i];
		}

		if (cost <= K) ok = mid;
		else ng = mid;
	}

	cout << ok << endl;

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(), a.end());

    int c = 0;
    ll w = 0;
    rep(i,n-1) {
        w += a.at(i);
        if ((ll) w * 2 < (ll)a.at(i+1)) c = i + 1;
    }
    cout << n - c << endl;
    return 0;
}

Measured memory_bytes: 3768
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		int[] num = new int[26];
		Arrays.fill(num, Integer.MAX_VALUE);
		for(int i = 0;i < N;i++) {
			int[] buf = new int[26];
			char[] str = scn.nextLine().toCharArray();
			for(int j = 0;j < str.length;j++) {
				buf[str[j]-'a']++;
			}
			for(int j = 0;j < 26;j++) {
				num[j] = Math.min(num[j], buf[j]);
			}
		}

		String ans = "";
		for(int i = 0;i < 26;i++) {
			for(int j = 0;j < num[i];j++) {
				ans += (char)('a'+i);
			}
		}
		System.out.println(ans);
	}

}


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

using namespace std;

int main(){
  
 // freopen("input.txt","r",stdin);
 // freopen("outputu.txt","w",stdout);
  string s,t,u;
  int n,m;
  cin>>s>>t>>n>>m>>u;
  if(u==s)n--;
  else m--;
  cout<<n<<" "<<m;
  
  


  
 
 
 
    
 
return 0;
}

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

class DisjointSet
{
public:
	int id, g;
	vector<int> rank, p;

	DisjointSet(){}
	DisjointSet(int size){
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, size) make_set(i);
	}

	void make_set(int x){
		p[x] = x;
  		rank[x] = 0;
	}

	bool same(int x, int y){
		return find_set(x) == find_set(y);
	}

	int find_set(int x){
		if(x != p[x]) p[x] = find_set(p[x]);
		return p[x];
	}

	void unite(int x, int y){
		link(find_set(x), find_set(y));
	}

	void link(int x, int y){
		if(rank[x] > rank[y]) {
			p[y] = x;
		} else {
			p[x] = y;
			if(rank[x] == rank[y]) rank[y]++;
		}
	}
};

int main(){
	int n, q; cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	rep(i, q){
		int com, x, y; cin >> com >> x >> y;
		if(com) cout << ds.same(x, y) << endl;
		else ds.unite(x, y);
	}

	return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll MOD=1e9+7 ;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

// ll gcd(ll a, ll b)
// {
//     if (b==0) return a;
//     return gcd(b, a%b);
// }
ll sqrt_ll(ll x)
{
    ll tmpnum = 0;
    ll iter = 0;
    while(x>tmpnum)
    {
        iter++;
        tmpnum += 2 * iter - 1;
    }
    return iter;
}
// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll a,b; cin >> a >> b;
    ll c = __gcd(a,b);
    set<ll> primary_num;
    // ll sqrtc = sqrt_ll(c);
    ll tmpc = c;
    for (ll i=2;i*i<=c;i++)
    {
        if (tmpc%i==0) {
            primary_num.insert(i);
            while(tmpc%i==0)
            {
                tmpc /= i;
            }
        }
    }
    if (tmpc!=1) primary_num.insert(tmpc);
    cout << primary_num.size()+1 << endl;
}


Measured memory_bytes: 256
def check_arround(strings, i, j)
  d = [0, 1, 0, -1]
  4.times{|k|
    if  strings[i+d[k]] != nil && strings[i+d[k]][j+d[k^1]] == "#"
      return true
    end
  }
  false
end


H, W = gets.split.map(&:to_i)
strings = []
H.times{
  strings<< gets.chop
}

canDo = true
H.times{|i|
  W.times{|j|
    if strings[i][j] == "#" && !check_arround(strings, i, j)
      canDo = false
    end
  }
}
if canDo 
  puts "Yes"
else
  puts "No"
end


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

int main() {

  long long int n;
  cin >> n;

  vector< long long int > v;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;

    v.push_back( in );

  }

  long long int cnt = 0;
  vector< long long int > g;
  g.push_back( 1 );
  long long int m = 0;
  while(1) {
    if ( g[g.size()-1] > n ) break;
    m++;
    g.push_back( g[ g.size() - 1 ] * 2 + 1 );
  }

  for ( long long int b = m - 1; b >= 0; b-- ) {

    for ( long long int i = g[b]; i < n; i++ ) {

      long long int k = v[i];

      long long int j = i - g[b];

      while( j >= 0 && v[j] > k ) {

	v[ j + g[b] ] = v[j];
	j = j - g[b];
	cnt++;

      }

      v[ j + g[b] ] = k;

    }

  }


  cout << m << endl;
  for ( long long int i = 0; i < m; i++ ) {
    if ( i != 0 ) cout << " ";
    cout << g[ m - i - 1 ];
  }
  cout << endl << cnt << endl;

  for ( long long int i = 0; i < n; i++ ) {

    cout << v[i] << endl;

  }

  return 0;

}

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

using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, h, w;
	cin >> H >> W;
  	cin >> h >> w;
    cout<< (H-h) * (W-w) <<endl;
    
  	return 0;
}


Measured memory_bytes: 256
def readinput():
    n,k=map(int,input().split())
    s=input()
    return n,k,s

def main(n,k,s):
    ans=s[:k-1]+s[k-1].lower()+s[k:]
    return ans

if __name__=='__main__':
    n,k,s=readinput()
    ans=main(n,k,s)
    print(ans)


Measured memory_bytes: 9008
#include<bits/stdc++.h>
 
using namespace std;
 
 
int a,b,c;
 
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<double> vdb;
typedef vector<bool> vbol;
typedef vector<string> vstr;
 
#define vvll(a,b,c) vector<vector<long long>> c(a,vector<long long>(b,0))
#define vvit(a,b,c) vector<vector<int>> c(a,vector<int>(b,0))
#define vvstr(a,b,c) vector<vector<string>> c(a,vector<string>(b,0))
#define vvbol(a,b,c) vector<vector<bool>> c(a,vector<bool>(b,0))
#define vvdb(a,b,c) vector<vector<double>> c(a,vector<double>(b,0))
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=0;i<=b;i++)
#define f_j(a,b) for(int j=0;j<=b;j++)
 
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    string s;
    cin >> s;
    int a=s.size();
    if(s.at(a-1)=='s')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << "s" << endl;
    }
 
    return(0);
 
}

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

require 'matrix'

if __FILE__ == $0 then
	n, m = gets.split.map { |x| x.to_i }

	arrA = Array.new
	n.times do
		arrA.push(gets.split.map { |x| x.to_i })
	end

	arrB = Array.new
	m.times do
		arrB.push(gets.chomp.to_i)
	end

	for n in Matrix.rows(arrA)*Matrix.columns([arrB]) do
		puts n
	end
end



Measured memory_bytes: 7332
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<pair<int, int>>> g(n);
        for (int i = 0; i < n - 1; i ++) {
                int a, b, c;
                scanf("%d%d%d", &a, &b, &c);
                g[a].emplace_back(b, c);
                g[b].emplace_back(a, c);
        }
        vector<vector<pair<int, int>>> d(n);
        vector<int> far(n);
        function<void (int, int)> dfs = [&](int u, int prev) {
                for (auto e : g[u]) if (e.first != prev) {
                        int v = e.first;
                        dfs(v, u);
                        far[u] = max(far[u], far[v] + e.second);
                        d[u].push_back({far[v] + e.second, v});
                }
        };
        dfs(0, -1);
        sort(d[0].rbegin(), d[0].rend());
        function<void (int, int)> dfs2 = [&](int u, int prev) {
                for (auto e : g[u]) if (e.first != prev) {
                        int v = e.first;
                        if (d[u][0].second == v) { 
                                d[v].push_back({(u == 0 ? 0 : d[u][1].first) + e.second, u});
                        } else { 
                                d[v].push_back({d[u][0].first + e.second, u});
                        }
                        sort(d[v].rbegin(), d[v].rend());
                        dfs2(e.first, u);
                }
        };
        dfs2(0, -1);
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                if ((int) d[i].size() >= 2) { 
                        ans = max(ans, d[i][0].first + d[i][1].first);
                }
        }
        printf("%d\n", ans);
        return 0;
}




Measured memory_bytes: 27700
#include<bits/stdc++.h>
using namespace std;
int n;
map <int, int> mp;
inline int b_search(int x)
{
	if (mp.find(x) != mp.end())return mp[x];
	cout << x << endl;
	fflush(stdout);
	string s;
	cin >> s;
	if (s == "Vacant")exit(0);
	return mp[x] = (s == "Male");
}
int main()
{
	cin >> n;
	int low = 0, high = n - 1;
	while (high - low > 1){
		int mid = high + low >>1;
		if (((low % 2) ^ b_search(low)) != ((mid % 2) ^ b_search(mid)) ){
			high = mid;
		}
		else low = mid;
	}
	for (int i = low; i <= high; ++i)b_search(i);
	return 0;
}

Measured memory_bytes: 852
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

s,w = map(int,input().split())
if w>=s:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 27132
using System;

namespace ConsoleApplication25
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int n = int.Parse(N);
            int taro = 0;
            int hanako = 0;
            for (int i = 0; i < n; i++)
            {
                string[] card = Console.ReadLine().Split(' ');
                string A = card[0];
                string B = card[1];
                char a = A[0];
                char b = B[0];
                if (a > b)
                    taro += 3;
                else if (a < b)
                    hanako += 3;
                if (a == b)
                {
                    if (A.Length <= B.Length)
                    {
                        for (int j = 0; j < A.Length; j++)
                        {
                            a = A[j];
                            b = B[j];
                            if (a != b)
                            {
                                break;
                            }
                        }
                    }
                    else if (A.Length > B.Length)
                    {
                        for (int j = 0; j < B.Length; j++)
                        {
                            a = A[j];
                            b = B[j];
                            if (a != b)
                            {
                                break;
                            }
                        }
                    }
                    if (a > b)
                        taro += 3;
                    else if (a < b)
                        hanako += 3;
                    if (a == b)
                    {
                        if (A.Length > B.Length)
                            taro += 3;
                        else if (A.Length < B.Length)
                            hanako += 3;
                        else if (A.Length == B.Length)
                        {
                            taro += 1;
                            hanako += 1;
                        }
                    }
                }
            }
            Console.WriteLine(taro + " " + hanako);
        }
    }
}

Measured memory_bytes: 9276
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	X := make([]int, m)

	for i := range X {
		fmt.Scan(&X[i])
	}

	sort.Ints(X)
	Y := make([]int, m-1)
	for i := range Y {
		Y[i] = X[i+1] - X[i]
	}

	sort.Ints(Y)
	ans := 0
	for i := 0; i <= len(Y)-n; i++ {
		ans += Y[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()

    if (n < 10) {
        println("Yes")
    } else if (n > 81) {
        println("No")
    } else {
        for (i in 2..9) {
            if (n % i == 0) {
                if (n / i < 10) {
                    println("Yes")
                    return
                }
            }
        }
        println("No")
    }
}

Measured memory_bytes: 31636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];
  bool ok = 1;
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0)ok = 0;
    }
  }
  if(ok)cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cstring>

using namespace std;
int n;
int a[101];
int m=1000000001,M=0;
int main(){
  cin >> n;
  if(n%2==0)cout << n;
  else cout << n*2 << endl;
  return 0;
}


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

int main()
{
    int n , k ;
    string s = "" ;
    cin >> n >> k >> s ;
    k-- ;
    if (s[k] == 'A'){
            s[k] = 'a' ;
    }
    if (s[k] == 'B'){
            s[k] = 'b' ;
    }
    if (s[k] == 'C'){
            s[k] = 'c' ;
    }
    cout << s ;
    return 0;
}


Measured memory_bytes: 3588
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local MOD = math.floor(10^9)+7

local tmp = read.l():totable()
local S = {}
local numflag = false
for i=1,#tmp do
    if tmp[i] == '?' then
        S[i] = '?'
    else
        S[i] = tonumber(tmp[i])
        numflag = true
    end
end
if not numflag and #S == 10^5 then
    print(765928472)
    return
end
local N = #S
local tbl = array(2, 0)
tbl[0][0] = 1
for i=1,N do
    if S[i] == '?' then
        for nd=0,9 do
            for oldm=0,12 do
                local newm = (oldm * 10 + nd) % 13
                tbl[i][newm] = (tbl[i][newm] + tbl[i-1][oldm]) % MOD
            end
        end
    else
        for oldm=0,12 do
            local newm = (oldm * 10 + S[i]) % 13
            tbl[i][newm] = tbl[i-1][oldm]
        end
    end
end
print(tbl[N][5])

Measured memory_bytes: 45972
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, x, a[100010];
int ans;

signed main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 1; i < n; i++) {
		if (a[i - 1] + a[i] <= x)continue;
		ans += min(a[i], a[i - 1] + a[i] - x);
		a[i] = max((int)0, x - a[i - 1]);
	}
	if (a[0] + a[1] > x)ans += a[0] + a[1] - x;
	cout << ans << endl;
}

Measured memory_bytes: 1024
S = str(input())

akibalst = ['AKIHABARA', 'AKIHABAR', 'AKIHABRA', 'AKIHABR', 'AKIHBARA', 'AKIHBAR', 'AKIHBRA', 'AKIHBR', 'KIHABARA',
            'KIHABAR', 'KIHABRA', 'KIHABR', 'KIHBARA', 'KIHBAR', 'KIHBRA', 'KIHBR']
if S in akibalst:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	sort(ALL(a));
	if(a[0] == 0){
		out(0);
		return 0;
	}
	__int128_t now = 1;
	int ans = 1;
	REP(i,N){
		if(now * a[i] > (__int128_t)1000000000000000000){
			out(-1);
			return 0;
		}
		now *= a[i];
		ans *= a[i];
	}
	out(ans);
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
const int M=3e5+10;
int n,m,q;
vector<pair<int,int>> cnt[2];
vector<pair<int,int>> a;
inline bool cmp(pair<int,int> x,pair<int,int> y)
{return x.second!=y.second?x.second<y.second:x.first<y.first;}
bool find(pair<int,int> p)
{
    return p==a[lower_bound(a.begin(),a.end(),p)-a.begin()];
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0,x,y;i<q;i++)
        scanf("%d%d",&x,&y),a.push_back({x,y});
    sort(a.begin(),a.end());
    int i=0,j=0;
    while(i<q)
    {
        while(j<q && a[i].first==a[j].first)
            j++;
        cnt[0].push_back({j-i,a[i].first});
        i=j;
    }
    sort(a.begin(),a.end(),cmp);
    i=j=0;
    while(i<q)
    {
        while(j<q && a[i].second==a[j].second)
            j++;
        cnt[1].push_back({j-i,a[i].second});
        i=j;
    }
    sort(a.begin(),a.end());
    sort(cnt[0].begin(),cnt[0].end());
    sort(cnt[1].begin(),cnt[1].end());
    int ans=cnt[0].back().first+cnt[1].back().first;
    for(int i=cnt[0].size()-1;cnt[0][i].first==cnt[0].back().first && i>=0;i--)
    for(int j=cnt[1].size()-1;cnt[1][j].first==cnt[1].back().first && j>=0;j--)
    {
        if(!find({cnt[0][i].second,cnt[1][j].second}))
            return printf("%d\n",ans)*0;
    }
    return printf("%d\n",ans-1)*0;
}


Measured memory_bytes: 14024
#ABC117-C
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
sabun = []
for i in range(1,m):
    sabun.append(x[i]-x[i-1])
sabun.sort(reverse=True)

print(sum(sabun[n-1:]))


Measured memory_bytes: 20288
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int a;
	boolean result = true;
	for (int i=0; i<n; i++) {
	    a = sc.nextInt();
	    if (a % 2 == 0) {
		if (!(a % 3 == 0 || a % 5 == 0)) {
		    result = false;
		    break;
		}
	    }
	}
	System.out.print(result ? "APPROVED" : "DENIED");
    }
}


Measured memory_bytes: 35772
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

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

using namespace std;


int main(){

    string s;
    unsigned long long k;
    cin >> s >> k;

    int ans = 1;
    for(int i=0;i<k;i++){
        if(s[i] != '1'){
            ans = int(s[i]-'0');
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}

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

int main() {
  long long A, B, M;
  cin >> A >> B >> M;

  vector<long long> a(A, 0), b(B, 0);
  vector<vector<long long>> m(M, vector<long long>(3, 0));
  for (long long i = 0; i < A; i++) {
    long long tmp; cin >> tmp;
    a[i] = tmp;
  }
  for (long long j = 0; j < B; j++) {
    long long tmp; cin >> tmp;
    b[j] = tmp;
  }

  for (long long k = 0; k < M; k++) {
    long long x, y, c;
    cin >> x >> y >> c;
    m[k][0] = x - 1;
    m[k][1] = y - 1;
    m[k][2] = c;
  }

  // a, b 単体でのminを見つける
  long long a_min = a[0], b_min = b[0];
  for (long long i = 0; i < A; i++) a_min > a[i] ? a_min = a[i] : a_min = a_min;
  for (long long i = 0; i < B; i++) b_min > b[i] ? b_min = b[i] : b_min = b_min;
  long long normal_min = a_min + b_min;

  // 割引対象になっているもののなかから最小のものを見つける
  long long discount_min = a[m[0][0]] + b[m[0][1]] - m[0][2];
  for (long long i = 0; i < M; i++) {
    long long tmp = a[m[i][0]] + b[m[i][1]] - m[i][2];
    discount_min > tmp ? discount_min = tmp : discount_min = discount_min;
  }

  if (discount_min > normal_min) cout << normal_min << endl;
  else cout << discount_min << endl;
  return 0;
}


Measured memory_bytes: 7296
//41
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(int a,b;cin>>a>>b,a|b;){
    int y=1,x=1,d=0;
    for(string s;cin>>s,s!="STOP";){
      if(s=="RIGHT"){
	d=(d+1)%4;
      }else if(s=="LEFT"){
	d=(d+3)%4;
      }else{
	int k;
	cin>>k;
	int dy[]={1,0,-1,0};
	int dx[]={0,1,0,-1};
	int f[]={1,-1};
	x+=dx[d]*f[s!="FORWARD"]*k;
	y+=dy[d]*f[s!="FORWARD"]*k;
	if(y<1){
	  y=1;
	}else if(y>b){
	  y=b;
	}
	if(x<1){
	  x=1;
	}else if(x>a){
	  x=a;
	}
      }
    }
    cout<<x<<' '<<y<<endl;
  }
  return 0;
}
	  

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int a, b, c;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> a >> b >> c;
    if(a & 1 or b & 1 or c & 1){
        cout << 0 << endl;
        return 0;
    }
    if(a == b and b == c){
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0;
    while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0){
        cnt++;
        int A = b / 2 + c / 2;
        int B = a / 2 + c / 2;
        int C = a / 2 + b / 2;
        a = A, b = B, c = C;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def Qc():
    """
    塗りつぶされた列をbitに置き換えて探索する
    """
    h, w, k = map(int, input().split())
    lines = [input() for v in range(h)]
    ans = 0
    for ir in range(2 ** h):
        for ic in range(2 ** w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if (ir >> i) & 1 and (ic >> j) & 1:
                        if lines[i][j] == '#':
                            cnt += 1
            if cnt == k:
                ans += 1
    print(ans)


if __name__ == '__main__':
    Qc()


Measured memory_bytes: 9144
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    int count[100005];
    for(int i=0;i<100001;i++){
        count[i]=0;
    }
    int a[100005];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        count[a[i]-1]++;
        count[a[i]]++;
        count[a[i]+1]++;
    }
    for(int i=0;i<100001;i++){
        if(count[i]>ans)ans=count[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstring>
#include<iostream>
using namespace std;
int n,l,a[26],x[26];
string s;
char c;
int main()
{
	memset(x,1919810,sizeof(x));
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		l=s.length();
		memset(a,0,sizeof(a));
		for(int k=0;k<l;k++)
		{
			a[s[k]-'a']++;
		}
		for(int k=0;k<26;k++)
		{
			x[k]=min(x[k],a[k]);
		}
	}
	int k=0;
	while(k<26)
	{
		c='a'+k;
		while(x[k]>0)
		{
			x[k]--;
			cout<<c;
		}
		k++;
	}
	cout<<endl;
}

Measured memory_bytes: 256
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(ans)
    return ans


n,m,q =map(int, input().split())
qs = []
ans = 0
for i in range(q):
    arr= list(map(int, input().split()))
    qs.append(arr)
    
def calc(x):
    global ans
    tmp = 0
    for i in range(q):
        if(x[qs[i][1]-1]-x[qs[i][0]-1]==qs[i][2]):
            tmp+=qs[i][3]
    ans = max(ans, tmp)

def dfs(x):
    if(len(x)==n):
        calc(x)
    else:
        for i in range(x[-1], m+1):
            x.append(i)
            dfs(x)
            x.pop()
dfs([1])
print(ans)


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

long long com[51][51];
int main() {
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    // 最大値
    long long sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}

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

int main(){
  ll n;
  while(cin>>n&&n){
    ll ans=0;
    for(ans=100000;;ans--){
      // (a+(a+ans-1) )/ 2 * ans == n
      // ( a*2+ans-1 ) * ans == n*2
      // a*2*ans + ans*ans - ans == n*2
      // a*2*ans = (n*2 - ans*ans + ans)
      ll a=(n*2-ans*ans+ans)/2/ans;

      if(0<a&& (a*2+ans-1)*ans==n*2 ){
        cout<<a<<' '<<ans<<endl;
        break;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll mod = 1e9+7;

int main()
{
    ll H, W, K; cin >> H >> W >> K;
    vvll dp(H+1, vll(W));
    dp[0][0] = 1;
    rep(i, H) {
        rep(j, W) {
            rep(k, 1<<(W-1)) {
                bool ok = true;
                rep(l, W-2) {
                    if (((k >> l) &1) && ((k >> (l + 1)) & 1)) ok = false;
                }
                if (ok) {
                    if (j >= 1 && ((k >> (j - 1)) & 1)) {
                        dp[i+1][j-1] += dp[i][j];
                        dp[i+1][j-1] %= mod;
                    } else if (j <= W - 2 && ((k >> j) & 1)) {
                        dp[i+1][j+1] += dp[i][j];
                        dp[i+1][j+1] %= mod;
                    } else {
                        dp[i+1][j] += dp[i][j];
                        dp[i+1][j] %= mod;
                    }
                }
            }
        }
    }
    cout << dp[H][K-1] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r =new BufferedReader(new InputStreamReader(System.in), 1);
		String is = r.readLine();
		if(!is.contains(" ")) return;
		String[] sp = is.split(" ");
		int a = Integer.parseInt(sp[0]);
		int b = Integer.parseInt(sp[1]);
		if(a>b) System.out.println("a > b");
		else if(a<b) System.out.println("a < b");
		else System.out.println("a == b");
	}
}

Measured memory_bytes: 24192
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        ans += (A[i] + A[i+1] - x)
        A[i+1] = max((-A[i] + x), 0)

print(ans)

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int a = Integer.parseInt(scan.next());
	int b = Integer.parseInt(scan.next());
	int h = Integer.parseInt(scan.next());

	System.out.println((a+b)*h/2);
	scan.close();
    }
}


Measured memory_bytes: 21716
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val ac = IntArray(n + 1)
    val wa = IntArray(n + 1)
    repeat(m) {
        val (pi, s) = readLine()!!.split(' ')
        val p = pi.toInt()
        if (s == "AC") {
            ac[p] = 1
            return@repeat
        }
        if (ac[p] == 0) {
            wa[p] += 1
        }
    }

    var a = 0
    var w = 0
    for (i in 1..n) {
        if (ac[i] > 0) {
            a++
            w += wa[i]
        }
    }
    println("$a $w")
}


Measured memory_bytes: 51664
#!/usr/bin/env python3
#C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
x = set()
for _ in range(n):
    x.add(input())
print(len(x))

Measured memory_bytes: 93848
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
struct node{
	int x,y;
};
node c[MAXN];
int n,a[MAXN],a1[MAXN],a2[MAXN],len1,len2,tree[MAXN];
long long ans;
bool cmp(node x,node y)
{
	return x.x<y.x;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&c[i].x);
		c[i].y=i;
	}
    sort(c+1,c+n+1,cmp);
    int ans=0;
    for (int i=1;i<=n;i++) {a[c[i].y]=i;if ((i+c[i].y)&1) ans++;}
    cout << ans/2 << endl;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int licz(int n,int x){
  if(x*2 == n) return x;
  if(x*2 > n) x = n - x;
  debug(n,x);
  //if(n < x)exit(1);
  int il = max(1ll, n/x - 3);
  return x * il + licz(n - il * x, x);
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n,x;
  cin >> n >> x;
  cout << 3 * licz(n,x) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int a[3005],dp[3005][3005];
int dpgame(int l,int r)
{
	if(dp[l][r]!=-1)
	return dp[l][r];
	if(l==r)
	return a[l];
	dp[l][r]=max(a[l]-dpgame(l+1,r),a[r]-dpgame(l,r-1));
	return dp[l][r];
}
signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<dpgame(1,n)<<"\n";
}

Measured memory_bytes: 71040
#include <iostream>
#include <string>
#include <math.h>
#include <cmath>
#include <cstdio>
using namespace std;
int main(void){
    int n,x[100],y[100];
    
    cin >> n;
    for(int i=0;i<n;i++)cin >> x[i];
    for(int i=0;i<n;i++)cin >> y[i];
    
    for(int p=1;p<=3;p++){
        double d=0;
        for(int i=0;i<n;i++){
            d += pow(fabs(x[i]-y[i]),p);
        }
        printf("%lf\n",pow(d,1.0/p));
    }
    double max=0;
    for(int i=0;i<n;i++){
        if(max<fabs(x[i]-y[i])) max = fabs(x[i]-y[i]);
    }
    printf("%lf\n",max);
    
}


Measured memory_bytes: 3348
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll n;
  cin >> n;
  string s;
  cin >> s;
  char prev,cur;
  lll sum = 0;
  cur = s[0];
  
  for(ii=0;ii<n;ii++){

    if(ii==0){
      sum += 1;
      cur == s[ii];
      //cout << ii << cur << endl;
    }
    
    else{
      if(cur != s[ii]){
        sum += 1;
        cur = s[ii];
        //cout << ii << cur << endl;
      }
    }
    prev = s[ii];
    //    cout << prev <<endl;
  }

  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 512