akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100005
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N;
    cin >> N;
    ll k;
    ll i, j, p=1;
    
    for(k=1; k*(k-1)/2<N; k++);
    
    if(N!=k*(k-1)/2) {
        pNo;
        return 0;
    }
    
    pYe;
    prin(k);
    set<ll> se[k];
    
    for(i=0; i<k; i++) {
        for(j=i+1; j<k; j++) {
            se[i].insert(p);
            se[j].insert(p);
            p++;
        }
    }
    
    for(i=0; i<k; i++) {
        cout << se[i].size() << " ";
        for(auto itr=se[i].begin(); itr!=se[i].end(); itr++) {
            cout << *itr << " ";
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, c;
    cin >> n >> m >> c;
    int b[100];
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    int a[100][100];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }
    int count = 0;
    for(int i=0; i<n; i++){
        int sum = c;
        for(int j=0; j<m; j++){
            sum += a[i][j]*b[j];
        }
        if(sum>0) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	int n, a[105], ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(i % 2 == 1){
			if(a[i] % 2 == 1) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3580
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  string s;
  cin >> s;
  vl r(s.size(), 0), l(s.size(), 0);
  vl ans(s.size(), 0);
  int i = 0, tmp = 0;
  while (i < s.size() - 1) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      ans[i] += (tmp / 2) + 1;
      ans[i + 1] += (tmp / 2) + (tmp & 1) + 1;
      i += 2;
      tmp = 0;
    } else if (s[i] == 'R') {
      tmp++;
      i++;
    } else {
      tmp = 0;
      i++;
    }
  }
  i = s.size() - 1, tmp = 0;
  while (i >= 1) {
    if (s[i] == 'L' && s[i - 1] == 'R') {
      ans[i] += (tmp / 2);
      ans[i - 1] += (tmp / 2) + (tmp & 1);
      i -= 2;
      tmp = 0;
    } else if (s[i] == 'L') {
      tmp++;
      i--;
    } else {
      tmp = 0;
      i--;
    }
  }
  rep(j, s.size()) {
    cout << ans[j];
    if (j != s.size() - 1)
      cout << " ";
    else
      cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
bool dp[81][81][25610];
inline bool ok(int n) { return 0 <= n && n < 25610; }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    vector<vector<int>> b = a;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> b[i][j];
        }
    }
    int bs = 12805;
    dp[0][0][bs + a[0][0] - b[0][0]] = 1;
    dp[0][0][bs + b[0][0] - a[0][0]] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 && j == 0) {
                continue;
            }
            for (int k = 0; k < 25610; k++) {
                if (j > 0) {
                    if (ok(k + b[i][j] - a[i][j])) {
                        dp[i][j][k] |= dp[i][j - 1][k + b[i][j] - a[i][j]];
                    }
                    if (ok(k + a[i][j] - b[i][j])) {
                        dp[i][j][k] |= dp[i][j - 1][k + a[i][j] - b[i][j]];
                    }
                }
                if (i > 0) {
                    if (ok(k + b[i][j] - a[i][j])) {
                        dp[i][j][k] |= dp[i - 1][j][k + b[i][j] - a[i][j]];
                    }
                    if (ok(k + a[i][j] - b[i][j])) {
                        dp[i][j][k] |= dp[i - 1][j][k + a[i][j] - b[i][j]];
                    }
                }
            }
        }
    }
    int mi = INF;
    for (int i = 0; i < 25610; i++) {
        if (dp[h - 1][w - 1][i]) {
            chmin(mi, abs(bs - i));
        }
    }
    cout << mi << endl;
}

Measured memory_bytes: 164096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int N, M, A[1024], c[1024];
  scanf("%d%d", &N, &M);
  memset(c, 0, sizeof(c));

  rep(i, N) scanf("%d", A+i);
  rep(i, M){
    int B;
    scanf("%d", &B);
    int p = 0;
    rep(j, N) if(B >= A[j]){ p = j; break;}
    c[p]++;
  }
  //      cout << "ok\n";      
  int res =0;
  rep(i, N) if(c[res] <= c[i]) res = i;
  printf("%d\n", res+1);
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

const string YES = "Yes";
const string NO = "No";

void solve(long long x, long long y)
{
    if (x == 2 || y == 2)
    {
        cout << NO << endl;
        return;
    }
    bool groupX = false, groupY = false;
    if (x == 4 || x == 6 || x == 9 || x == 11)
    {
        groupX = true;
    }
    else
    {
        groupX = false;
    }

    if (y == 4 || y == 6 || y == 9 || y == 11)
    {
        groupY = true;
    }
    else
    {
        groupY = false;
    }

    if (groupX == groupY)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    long long x;
    scanf("%lld", &x);
    long long y;
    scanf("%lld", &y);
    solve(x, y);
    return 0;
}


Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

s = []
t = []
n = inp[0]
n.times do
  a,b = inp
  s << a
  t << b
end
s.sort!
t.sort!
ans = 0
a,b = s,t
if(n.even?)
  ans = (a[n/2-1]+a[n/2]) - (b[n/2-1]+b[n/2])
else
  ans = a[n/2] - b[n/2]
end
p 1+ans.abs


Measured memory_bytes: 20488
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main(int, char**)
{
	long N;
	cin >> N;
	vector<string> s(N);
	unordered_map<string, long> dict;
	for (long i = 0; i < N; ++i)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		++dict[s[i]];
	}
	long counter = 0;
	for (long i = 0; i < N; ++i)
	{
		counter += --dict[s[i]];
	}
	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 17700
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    long long int m=0;
    for(int n=0; n<N; n++) {
        cin >> A[n];
        if(n%2==0) {
            m+=A[n];
        } else {
            m-=A[n];
        }
    }
    
    cout << m << " ";
    for(int n=0; n<N-1; n++) {
        m = 2*A[n]-m;
        cout << m << " ";
    }
    cout << endl;
    

    return 0;
    
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
  int N, M, x, y;
  cin >> N >> M;
  vector<int> b(N), n(N,1);
  b[0] = 1;
  for (int i = 0; i < M; i++) {
    cin >> x >> y;
    b[y-1] = b[y-1] || b[x-1];
    --n[x-1], ++n[y-1];
    if (!n[x-1]) b[x-1] = 0;
  }
  cout << accumulate(begin(b),end(b),0) << endl;
}


Measured memory_bytes: 4020
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  ll ma = a[0];
  rrep(i, 1, n) {
    if (a[i] <= ma) {
      ans += ma - a[i];
    } else
      ma = a[i];
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5192
#include<stdio.h>

int main()
{
    int i;
    long long n;
    long long ans = 0;
    scanf("%lld", &n);
    if(n % 2 == 0){
        n /= 2;
        while(1){
            if(n == 0) break;
            n /= 5;
            ans += n;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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


int main(){
  int A ,B , C ; 
  cin >> A >> B >> C ; 
  int T = A ; 
  
  for(int i = 1 ; i <= 10000 ; i++ ){
    if(T%B == C){
      cout << "YES" << endl ; 
      return 0 ; 
    }
    //cout << T << endl ; 
    T = T + A   ; 
  }
  
  cout << "NO"  << endl ; 
}

Measured memory_bytes: 3640
n, t = map(int, input().split())
ab = sorted(list(map(int, input().split())) for _ in range(n))
dp = [-1] * (t - 1) + [0]
ret = 0
for i in range(n):
    a, b = ab[i]
    newdp = dp[:]
    for j in range(t):
        if dp[j] >= 0:
            ret = max(ret, dp[j] + b)
            if j - a >= 0:
                newdp[j - a] = max(newdp[j - a], dp[j] + b)
    dp = newdp
print(ret)


Measured memory_bytes: 74704
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s, w;
    cin >> w;
    int ans = 0;
    while(cin >> s) {
        if (s == "END_OF_TEXT") break;
        transform(s.begin(), s.end(), s.begin(), ::tolower); 
        if(s == w) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[3][3];
  rep(i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  bool ok[3][3] = {};
  rep(i, n) {
    int b;
    cin >> b;
    rep(j, 3) rep(k, 3) {
      if (a[j][k] == b)
        ok[j][k] = true;
    }
  }
  rep(i, 3) {
    if (ok[i][0] && ok[i][1] && ok[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i, 3) {
    if (ok[0][i] && ok[1][i] && ok[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (ok[1][1] && (ok[0][0] && ok[2][2] || ok[0][2] && ok[2][0])) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    int x,y;
    cin>>x>>y;
    int d=y-2*x;

    if(!(d%2 or d<0))
    {
        d/=2;
        if(x-d>=0)
        {
            cout<<"Yes";return 0;
        }
    }
    cout<<"No";
    return 0;

    return 0;
}




Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
	int total;
	int sum = 0;
	int a;
	
	for(;;){
		total = 0;
		sum = 0;
		scanf("%d",&total);
		if(total == 0){
			break;
		}
		
		for(int i = 0; i < 9; i++){
			scanf("%d",&a);
			sum += a;
		}
		
		printf("%d\n",total - sum);
	}
	return 0;
}

Measured memory_bytes: 0
S = input()

a = 0
b = 0
c = 0

for si in S:
    if si == 'a':
        a += 1
    elif si == 'b':
        b += 1
    else:
        c += 1


if max(a, b, c) - min(a, b, c) <= 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
// AOJ 2522: Register Phase
// 2017.10.5 bal4u@uu

#include <stdio.h>
#include <ctype.h>

int main()
{
	int f;
	char buf[25], *p;

	scanf("%s", buf);
	p = buf, f = 0;
	while (*p) {
		if      (isdigit(*p)) f |= 1;
		else if (isupper(*p)) f |= 2;
		else if (islower(*p)) f |= 4;
		p++;
	}
	puts(p-buf >= 6 && f == 7 ? "VALID" : "INVALID");
	return 0;
}

Measured memory_bytes: 1704
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
	struct node *oya, *ko[2];
	int val;
}node;

int push(node *v,node *oya, int dir, int val){
    if(v){
		int d = (*v).val<val;
		push((*v).ko[d], v, d, val);
	}
    else{
		v=(node*)calloc(1, sizeof(node));
		(*v).oya = oya;
		(*v).val = val;
		(*oya).ko[dir] = v;
	}
}

node*find(node *v, int val){
	if(!v)              return 0;
	if((*v).val==val)   return v;
	int d = (*v).val<val;
	return find((*v).ko[d],val);
}
node*nxt(node*v){
	if((*v).ko[0])  return nxt((*v).ko[0]);
	if((*v).ko[1])  return nxt((*v).ko[1]);
	return v;
}

void del(node*v){
	if(!v)  return;
	if((*v).ko[0]){
		if((*v).ko[1]){
			node*nnn=nxt((*v).ko[1]);
			(*v).val=(*nnn).val;
			del(nnn);
		}
        else{
			if((*(*v).oya).ko[0] == v)  (*(*v).oya).ko[0]=(*v).ko[0];
			else                        (*(*v).oya).ko[1]=(*v).ko[0];
			(*(*v).ko[0]).oya=(*v).oya;
			free(v);
		}
	}
    else{
		if((*v).ko[1]){
			if((*(*v).oya).ko[0]==v)    (*(*v).oya).ko[0]=(*v).ko[1];
			else                        (*(*v).oya).ko[1]=(*v).ko[1];
			(*(*v).ko[1]).oya=(*v).oya;
			free(v);
		}
        else{
			if((*(*v).oya).ko[0]==v)    (*(*v).oya).ko[0]=0;
			else                        (*(*v).oya).ko[1]=0;
			free(v);
		}
	}
}

void f(node *v, int mode){
	if(!v)      return;
	if(mode==0) printf(" %d",(*v).val);
	f((*v).ko[0],mode);
	if(mode==1) printf(" %d",(*v).val);
	f((*v).ko[1],mode);
}


node root;
int main(){
	int n;
	scanf("%d", &n);
	while(n--){
		char s[10];
		scanf("%s", s);
		if(s[0] == 'p'){
			f(root.ko[0], 1);
			puts("");
			f(root.ko[0], 0);
			puts("");
		}
        else if(s[0] == 'i'){
			int t;
			scanf("%d",&t);
			push(root.ko[0], &root,0,t);
		}
        else if(s[0] == 'f'){
			int t;
			scanf("%d",&t);
			puts(find(root.ko[0],t) ? "yes" : "no");
		}
        else if(s[0] == 'd'){
			int t;
			scanf("%d",&t);
			del(find(root.ko[0],t));
		}
	}
}



Measured memory_bytes: 20464
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
 ll n;
 string s;
 cin>>n>>s;
 if(n%2!=0) cout<<"No";
 else
 {
     ll temp=n/2;
     bool f=true;
     for(int i=0;i<n/2;i++)
     {
         if(s[i]!=s[temp+i])
         {
             f=false;
             break;
         }
     }
     if(f)
        cout<<"Yes";
     else cout<<"No";
 }
 return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const [N, A, B] = lines[0].split(' ').map(BigInt)
const ans = N / (A + B) * A + (N % (A + B) < A ? (N % (A + B)) : A)
console.log(ans.toString())

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

int main(){
    
    int a,b;

    cin >> a>>b;

    if(a>b){
        cout << "a > b"<< endl;
    }else if(a<b){
        cout << "a < b"<< endl;
    }else{
        cout << "a == b"<< endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int x,t;
    cin >> x >> t;
    if (x-t >= 0) {
        cout << x-t << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

const int MAXN = 1e5+10;
int a[MAXN];
int b[MAXN];
int n,k;
int fac[31];

void init()
{
    for(int i = 0; i < 31; ++i)
        fac[i] = 1<<i;
}

int main()
{
    init();
    scanf("%d %d",&n,&k);
    long long res = 0;
    for(int i = 0; i < n; ++i)
    {
        scanf("%d %d",&a[i],&b[i]);
        if((a[i]&k)==a[i]) res += b[i];
    }
    for(int i = 30; i >= 0; --i)
    {
        if(k&fac[i])
        {
            int tmp = (k^fac[i])|(fac[i]-1);
            //printf("%d\n",tmp);
            long long ans = 0;
            for(int j = 0; j < n; ++j)
                if((a[j]&tmp)==a[j]) ans += b[j];
            res = max(res,ans);
        }
    }
    printf("%lld\n",res);
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

	int n, m;
	cin >> n >> m;

	int sum = 0;
	multiset<int> S;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		S.insert(x);
		sum += x;
	}

	vii q(m);
	for (int i = 0; i < m; i++) {
		cin >> q[i].se >> q[i].fi;
	}

	sort(q.rbegin(), q.rend());

	for (int i = 0; i < m; i++) {
		int b = q[i].se, c = q[i].fi;
		for (int j = 0; j < b; j++) {
			if (*S.begin() < c) {
				sum -= *S.begin();
				sum += c;
				S.erase(S.begin());
				S.insert(c);
			} else {
				break;
			}
		}
	}

	cout << sum << "\n";
    return 0;
}


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

void initializeDice( int* d )
{
    d[0] = 1;
    d[1] = 2;
    d[2] = 4;
    d[3] = 5;
    d[4] = 3;
    d[5] = 6;
}

void changePosition( int* d, int a, int b )
{
    int temp = d[a];
    d[a] = d[b];
    d[b] = temp;
}

int moveDice( int* d, string s )
{
    if( s == "North" )
    {
        changePosition( d, 0, 3 );
        changePosition( d, 0, 1 );
        changePosition( d, 1, 5 );
    }
    else if( s == "East" )
    {
        changePosition( d, 0, 4 );
        changePosition( d, 0, 2 );
        changePosition( d, 2, 5 );
    }
    else if( s == "West" )
    {
        changePosition( d, 0, 2 );
        changePosition( d, 0, 4 );
        changePosition( d, 4, 5 );
    }
    else if( s == "South" )
    {
        changePosition( d, 0, 1 );
        changePosition( d, 0, 3 );
        changePosition( d, 5, 3 );
    }
    else if( s == "Right" )
    {
        changePosition( d, 1, 2 );
        changePosition( d, 3, 1 );
        changePosition( d, 1, 4 );
    }
    else
    {
        changePosition( d, 1, 4 );
        changePosition( d, 3, 1 );
        changePosition( d, 1, 2 );
 
    }
    return d[0];
}

int main()
{
    int n;
    int dice[6];
    string str;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        initializeDice(dice);

        int sum = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> str;
            sum += moveDice( dice, str );
        }
        cout << sum + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int n[5],k[15],m[15],i,y=0;
  char c[7][11]={"null","one pair","two pair","three card","four card","full house","straight"};
  while (scanf("%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4])!=EOF) {
  for (i=0;i<15;i++) { m[i]=0; k[i]=0;}
  for (i=0;i<5;i++) k[n[i]]++;
  for (i=1;i<14;i++) if (k[i]>0) m[k[i]]++;
  y=0; k[14]=k[1];
  if (m[2]>0) y=m[2];
  if (m[3]==1) if (m[2]==1) y=5; else y=3;
  if (m[4]==1) y=4;
  for (i=1;i<11;i++) if (k[i]==1 && k[i+1]==1 && k[i+2]==1 && k[i+3]==1 && k[i+4]==1) y=6; 
  cout << c[y] << endl;
  }
  return 0;
}

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

using namespace std;

int main(void)
{
	long int k, len, a1, a2;
	long int t = 0;
	bool flag = false;
	string s;

	a1 = a2 = 0;

	cin >> s;
	cin >> k;

	len = s.length();

	for (int i = 1; i < len; i++)
	{
		if (s[i - 1] != s[i])
		{
			flag = true;
		}
	}

	if (!flag)
	{
		cout << len*k / 2;
		return 0;
	}

	for (int i = 0; i < len-1; i++)
	{
		if (s[i] == s[i+1])
		{
			a1++;
			i++;
		}
	}

	s += s;
	len = s.length();

	for (int i = 0; i < len-1; i++)
	{
		if (s[i] == s[i+1])
		{
			a2++;
			i++;
		}
	}

	t = a1 + (a2 - a1) * (k-1);

	cout << t;



	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;

class Program
 {
    static void Main(string[] args)
    {
        string nyuryoku;
        string[] temp = new string[3];
        double S,L,h,length1,length2,angle,result1;
        nyuryoku = Console.ReadLine();
        temp = nyuryoku.Split(' ');
        length1 = double.Parse(temp[0]);
        length2 = double.Parse(temp[1]);
        angle = double.Parse(temp[2]);
        result1 = length1 * Math.Sin(angle * (Math.PI / 180)) ;
        S = result1 * length2 / 2.0;
        L =length1 + length2 + Math.Sqrt(Math.Pow(result1,2) + Math.Pow(length2 - length1*Math.Cos(angle * (Math.PI / 180)),2));
        h = length2 * Math.Sin(angle * (Math.PI / 180));
     
        Console.WriteLine("{0:f5} {1:f5} {2:f5}",S,L,h);
    }
 }



Measured memory_bytes: 17856
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

bool isPrime[250000];
void getPrime() {
	isPrime[0] = isPrime[1] = false;
	REP(i, 2, 250000) isPrime[i] = true;

	for (int i = 2; i*i < 250000; i++) {
		for (int j = 2 * i; j < 250000; j += i) {
			isPrime[j] = false;
		}
	}
	return;
}
int main() {
	int n;
	getPrime();

	while (cin >> n, n) {
		int cnt = 0;
		REP(i, n + 1, 2 * n + 1) {
			if (isPrime[i]) cnt++;
		}

		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int k=0;
  for(int i=0;i<n;i++){
    if((i+1)%2 == 1){
      if(s.at(i) == 'L'){
        k =-1;
        break;
      }
    }
    else{
      if(s.at(i) == 'R'){
        k = -1;
        break;
      }
    }
  }
  if(k == -1){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: u64,
        edges: [(usize, usize); n - 1]
    };

    let mut vertex_count = 0_u64;
    for c in 1..=n {
        vertex_count += c * (n - c + 1);
    }
    let mut edge_count = 0_u64;
    for (u, v) in edges {
        let l = u.min(v);
        let r = u.max(v);
        edge_count += l as u64 * (n - r as u64 + 1) as u64;
    }
    let res = vertex_count - edge_count;
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 6680
// =====================================================================================
// 
//       Filename:  D.cpp
//        Created:  2017년 08월 06일 21시 56분 56초
//       Compiler:  g++ -O2 -std=c++14
//         Author:  baactree ,  bsj0206@naver.com
//        Company:  Chonnam National University
// 
// =====================================================================================

#include <bits/stdc++.h>
using namespace std;
int h, w;
int n;
int arr[10005];
int mat[100][100];
int idx;
int get_color(){
	while(idx<n&&arr[idx]==0)
		idx++;
	arr[idx]--;
	return idx;
}
int main(){
	scanf("%d%d", &h, &w);
	scanf("%d", &n);
	for(int i=1;i<=n;i++)
		scanf("%d", &arr[i]);
	for(int i=0;i<h;i++){
		if(i&1)
			for(int j=0;j<w;j++)
				mat[i][j]=get_color();
		else
			for(int j=w-1;j>=0;j--)
				mat[i][j]=get_color();
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			printf("%d ", mat[i][j]);
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

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

const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

ll segMin[2 * MAX_SIZE - 1], segAdd[2 * MAX_SIZE - 1];

//区間[a, b)に値xを加算する.
void add(int a, int b, int x, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return; //もし交差しない区間であれば終える.
    
    if (a <= l && r <= b){ //もし今みている区間[l, r)が[a, b)に完全に内包されていれば
        segAdd[k] += x;  //区間[l, r)にkを加算する.
        return;
    }
    
    add(a, b, x, k * 2 + 1, l, (l + r) / 2); //子の区間に(必要があれば)xを加算する.
    add(a, b, x, k * 2 + 2, (l + r) / 2, r); //〃
    
    //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値 である.一様に加算される値は更新しなくて良い.
    segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1], segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}

ll getMin(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE)
{
    if (r <= a || b <= l) return (1e10);
    
    if (a <= l && r <= b) return (segMin[k] + segAdd[k]); //完全に内包されていれば,その区間の最小値を返す.
    
    ll left = getMin(a, b, k * 2 + 1, l, (l + r) / 2); //子の区間の最小値を求める.
    ll right = getMin(a, b, k * 2 + 2, (l + r) / 2, r); //子の区間の最小値を求める
    
    return (min(left, right) + segAdd[k]); //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値 である (大切なので2回書きました!!)
    
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    rep(i,0,q){
        int a, s, t;
        cin>>a>>s>>t;
        if(a) {
            cout <<getMin(s, t+1)<<"\n";
        }
        else{
            int x;
            cin>>x;
            add(s,t+1,x,0,0,MAX_SIZE);
        }
    }
}


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

N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
x.reverse()
y.sort()

if x[0] >= y[0]:
    print("War")
else:
    Z = y[0]
    if X < Z and Z <= Y:
        print("No War")
    else:
        print("War")


Measured memory_bytes: 3060
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $m) = split / /, <STDIN>);
my (@x, @y);
for my $i (0..$m-1) {
  chomp (($x[$i], $y[$i]) = split / /, <STDIN>);
}
my (@pr, @bc);
for my $i (0..$n-1) {
  if ($i==0) {
    $pr[$i] = 1;
  } else {
    $pr[$i] = 0;
  }
  $bc[$i] = 1;
}
for my $j (0..$m-1) {
  $bc[$x[$j]-1]--;
  $bc[$y[$j]-1]++;
  if ($pr[$x[$j]-1]>0) {
    $pr[$x[$j]-1] = ($bc[$x[$j]-1]>0)?1:0;
    $pr[$y[$j]-1] = 1;
  }
}

my $ans = 0;
for my $i (0..$n-1){
  $ans++ if $pr[$i] > 0;
}
say $ans;

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

int main(){

	int h, w;
	cin >> h >> w;

	char a[h][w], b[2*h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < 2*h; i++) {
		if (i != 0)
			cout << '\n';

		for (int j = 0; j < w; j++) {
			b[i][j] = a[i/2][j];
			cout << b[i][j];
		}
	}

	return 0;
}

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

int main(){
	ll a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	double p=0;
	ll mw=a;
	ll ms=0;
	ll w=0;
	ll s=0;
	bool q=false;
	rep(i,0,f/(100*b)+1){
		rep(j,0,f/(100*a)+1){
			w=i*b+j*a;
			if(w*100>=f)break;
			rep(k,0,e*w/c+1){
				rep(l,0,e*w/d+1){
					s=k*c+l*d;
					if((w*100+s)>f) break;
					if((w*100+s)<=f && w!=0){
						 if(w*e>s &&p<s/double(w)) {mw=w;ms=s;p=s/double(w);}
						 if(w*e==s && p<s/double(w)){mw=w;ms=s;p=s/double(w);q=true;break;}
					}
					if(q)break;
				}
				if(q)break;
			}
			if(q)break;
		}
		if(q)break;
	}
	cout<<mw*100+ms<<" "<<ms<<endl;
}

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

int main() {

	int W, a, b;
	cin >> W >> a >> b;
	
	if (a + W < b) {
		cout << b - (a + W) << endl;
	}
	else if (b + W < a) {
		cout << a - (b + W) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		char[] c = N.toCharArray();
		sc.close();
		for (int i = 0; i < 3; i++) {
			if (c[i] == '7') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000

int main()
{
    int H,N;cin >> H >>N;
    vector<pair<int,int>> magic(N);
    int damage,point;
    for (int i=0;i<N;i++)
    {
        cin >> damage >> point;
        magic[i]=make_pair(damage,point);
    }
    vector<vector<int>> dp(N+1,vector<int> (20001,INF));
    dp[0][0]=0;
    for (int i=0;i<N;i++)
    {
        for (int h=0;h<20001;h++)
        {
            if (h>=magic[i].first)
            {
                dp[i+1][h]=min(dp[i][h],dp[i+1][h-magic[i].first]+magic[i].second);
            }
            else
            {
                dp[i+1][h]=dp[i][h];
            }
        }
    }
    int ans=INF;
    for(int i=H;i<20001;i++) ans=min(ans,dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);

#define ull unsigned long long int
#define ll long long int
#define ld double
#define ui unsigned int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second 

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)

void ayush(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll gcd(ll a, ll b) 
{ 
    if (a == 0) return b; 
    return gcd(b % a, a); 
} 

ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
ll mulmod(ll a, ll b, ll mod) 
{ 
    ll res = 0; 
    a = a % mod; 
    while (b > 0) 
    { 
        if (b % 2 == 1) res = (res + a) % mod; 
        a = (a * 2) % mod; 
        b /= 2; 
    }  
    return res % mod; 
} 

int main(){
    ayush();
    fastio;

    ll t; t=1;
    while(t--){
        char x; cin>>x;
        if(x>='A'&&x<='Z') cout<<"A";
        else cout<<"a";
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int h,w,k;cin>>h>>w>>k;
    char a[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    }
    int ans=0;
    for(int row=0;row<(1<<h);row++)
    {
        for(int col=0;col<(1<<w);col++)
        {
            int b=0;
            for(int i=0;i<h;i++)
            {
                for(int j=0;j<w;j++)
                {
                    if((row&(1<<i))==0 && (col&(1<<j))==0 && a[i][j]=='#')
                        b++;
                }
            }
            if(b==k)
                ans++;
        }
    }
    cout<<ans<<nl;
}

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

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


Measured memory_bytes: 3628
N, K = map(int, input().split())
A = list(map(int, input().split()))
k, tmp = 0, K
while tmp > 0:
    tmp //= 2
    k += 1
tight = 0
untight = 0
for j in range(k)[::-1]:
    # print('j = ', j)
    cnt0, cnt1 = 0, 0
    for a in A:
        # print('a = ', a, (a << j) & 1)
        if (a >> j) & 1:
            cnt1 += 1
        else:
            cnt0 += 1
    b = 2**j
    tmp = b * max(cnt0, cnt1)
    if (K >> j) & 1:
        if j == k-1:
            untight = b * cnt1
        else:
            untight = max(tight + b * cnt1, untight + tmp)
        tight += tmp
    else:
        tight += b * cnt1
        untight += tmp
    # print('b =',b, ', cnt0 =', cnt0, ', cnt1=', cnt1)
    # print('tight = ', tight)
    # print('untight = ', untight)
    # print()
ans = max(tight, untight)
for a in A:
    ans += (a >> k) << k
print(ans)

Measured memory_bytes: 69392
#include<stdio.h>

int main(){

    int H;
    int N;
    int i;
    int A;

    scanf("%d",&H);
    scanf("%d",&N);

    for(i=0;i<N;i++){
        scanf("%d",&A);
        H -= A;
        if(H<=0)break;
    }

    if (H <= 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();

		int[] bou=new int[N];
		for(int i=0; i<N; i++) {
			bou[i]=sc.nextInt();
		}
		Arrays.sort(bou);

		int counter=0;
		int wa=0;
		while(counter<K) {
			wa+=bou[N-1-counter];
			counter++;
		}
		System.out.println(wa);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,d,x;cin>>r>>d>>x;
    int x1=0,x2=0;
    x1=x*r-d;
    for (int i = 0; i < 10; i++)
    {
        /* code */
        cout<<x1<<endl;
        x1=x1*r-d;

    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int result = 0;
		for(int i = 1; i <= n; i++) {
			int sum = 0;
			int nn = i;
			while(nn >= 1) {
				sum += nn % 10;
				nn /= 10;
			}
			if(a <= sum && sum <= b) {
				result += i;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstring>
using namespace std;
#define int long long
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
constexpr int MOD = 1000000007;
int dp[100002];
bool danger[100002];
signed main() {
  memset(danger, 0, sizeof(danger));
  memset(dp, 0, sizeof(dp));

  int N, M; cin >> N >> M;
  REP(i,M) {
    int a; cin >> a;
    danger[a] = true;
  }
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    if (danger[i]) continue;
    (dp[i + 1] += dp[i]) %= MOD;
    (dp[i + 2] += dp[i]) %= MOD;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 1152
sa = list(input() + 'A')
sb = list(input() + 'B')
sc = list(input() + 'C')


def f(s):
    c = s.pop(0)
    if c.isupper():
        print(c)
        return
    if c == 'a':
        f(sa)
    elif c == 'b':
        f(sb)
    else:
        f(sc)


f(sa)


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

int sumOfDigits(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int answer = 0;
    for (int i = 1; i < N + 1; ++i)
    {
        int compare = sumOfDigits(i);
        if (compare >= A && compare <= B)
        {
            answer += i;
        }
        compare = 0;
    }
    cout << answer << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int K = nextInt();
  string s; cin >> s;

  deque< pair<int,int> > v;

  int dig = s[0];
  int len = 1;
  for (int i = 1; i < N; i++) {
    if (dig != s[i]) {
      v.push_back({dig-'0', len});
      len = 0;
      dig = s[i];
    }
    len++;
  }
  v.push_back({dig-'0', len});
  if (v[0].first == 0) v.push_front({1, 0});

  int SZ = v.size();
  REP(i, 2*K+1) v.push_back({0, 0});

  int ans = 0;

  int cur = 0;
  for (int i = 0; i < SZ && i < 2*K+1; i++) {
    cur += v[i].second;
  }
  chmax(ans, cur);

  int i = 0;
  int j = 2*K+1;
  while (j < SZ) {
    cur -= v[i].second;
    cur -= v[i+1].second;
    cur += v[j].second;
    cur += v[j+1].second;
    i += 2;
    j += 2;
    chmax(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;

inline int abs(int a){
	return a<0?-a:a;
}

inline int max(int a,int b){
	return a<b?b:a;
}

int a[2001];
int main()
{
	srand((unsigned)time(NULL));
	for(int i=0;i<10;i++)
    	int x=random(1,100);
    int n,z,w;
    scanf("%d%d%d",&n,&z,&w);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if (n!=1) printf("%d",max(abs(a[n]-w),abs(a[n-1]-a[n])));
    else printf("%d",abs(a[n]-w));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int yaku=0;
        int so=i;
        if(so%2==1){
            for(int j=1;j<=i;j++){
                if(so%j==0)yaku++;
            }
            if(yaku==8)ans++;
        }
    }
    cout << ans;
 }


Measured memory_bytes: 256
def main():
  h,w,a,b=map(int,input().split())
  
  ans=[]
  ans+=["0"*a + "1"*(w-a) + "\n"]*b
  ans+=["1"*a + "0"*(w-a) + "\n"]*(h-b)
  print("".join(ans)[:-1])
  
if __name__=="__main__":
  main()

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

vector<int> cal(int D, vector<vector<int>> s, vector<int> t, vector<int> c, vector<int> v) {
    vector<int> last(26);
    for(int i = 0; i < D; i++) {
        if(i == 0)
            v[i] = s[i][t[i]-1];
        else
            v[i] = v[i-1] + s[i][t[i]-1];
        
        last[t[i]-1] = i+1;
        rep(j,26) {
            v[i] -= c[j] * (i+1 - last[j]);
        }
    }
    
    return v;
}

int main() {
    int D;
    cin >> D;
    
    vector<int> c(26);
    rep(i,26) {
        cin >> c[i];
    }
    
    vector<vector<int>> s(D, vector<int>(26));
    rep(i,D) {
        rep(j,26) {
            cin >> s[i][j];
        }
    }
    
    
    vector<int> t(D);
    rep(i,D) {
        t[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }

    int m = 1;
    
    vector<int> d(m), q(m);
    rep(i,m) {
        d[i] = 1 + (int)(rand()*(D-1+1.0)/(1.0+RAND_MAX));
        q[i] = 1 + (int)(rand()*(26-1+1.0)/(1.0+RAND_MAX));
    }
    
    //計算開始
    vector<int> v(D);
    v = cal(D,s,t,c,v);
    
    rep(i,m) {
        int old = t[d[i]-1];
        t[d[i]-1] = q[i];
        vector<int> nv = cal(D,s,t,c,v);
        
        //cout << nv.back() << endl;
        if(v.back() > nv.back())
            t[d[i]-1] = old;
        else
            v = nv;
    }

    rep(i,D) {
        cout << t[i] << endl;
    }
    
    
    return 0;
}




Measured memory_bytes: 3724
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b = inpm()
    for i in range(1,10000):
        if int(i*0.08)==a and int(i*0.1)==b:
            print(i)
            return
    print(-1)
    
if __name__ == "__main__":
    main()

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


int N, K; string S;
//-----------------------------------------------------------------
inline char getrev(char c, int m) {
	int cc = c - 'A';
	if (m % 2 == 1) cc = 1 - cc;
	return char('A' + cc);
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> K >> S;

	deque<char> deq;
	string ans = "";
	rep(i, 0, N) deq.push_back(S[i]);
	int cnt = 0, rev = 0, done = 0;
	while (deq.size()) {
		// 右側を詰める
		while (deq.size()) {
			if (getrev(deq.back(), rev) == getrev('A', done)) {
				deq.pop_back();
				ans = getrev('A', done) + ans;
				done++;
			} else {
				break;
			}
		}
		if (deq.size() == 0) break;

		// 変換
		if (getrev(deq.front(), rev) == 'A') {
			// パターン1
			cnt++;
			char c = deq.front(); deq.pop_front();
			deq.push_front(getrev(c, 1));
		} else {
			// パターン2
			cnt++;
			deq.pop_front();
			rev++;
			ans = getrev('A', done) + ans;
			done++;
		}

		if (cnt == K) break;
	}

	if (deq.size()) {
		while (deq.size()) {
			ans = getrev(deq.back(), rev) + ans;
			deq.pop_back();
		}
		cout << ans << endl;
		return 0;
	}

	int d = K - cnt;
	if (N % 2 && d % 2) ans[0] = 'B';
	cout << ans << endl;
}

Measured memory_bytes: 1376
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            string output = (a*b% 2 == 1) ? "Odd" : "Even";
            Console.WriteLine(output);
        }
    }
}


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


int main() {
  int K, S;
  cin >> K >> S;
  int cnt = 0;

  for (int x = 0; x < K + 1; x++) {
    for (int y = 0; y < K + 1; y++) {
      int z = S - x - y;
      if ( z >= 0 && z <= K) {
        cnt++;
      }
    }
  }

  cout << cnt;
  return 0;
}


Measured memory_bytes: 256