akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main(){
  int a, b, c, k; 
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while (b <= a) b *= 2, cnt++;
  while (c <= b) c *= 2, cnt++;
  if (cnt <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, k, c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vl l, r;
    ll cur=0;
    forr(i, k)
    {
        while(s[cur]=='x')
        cur++;
        l.pb(cur), cur++;
        forr(j, c)
        cur++;
    }
    cur=0;
    reverse(all(s));
    forr(i, k)
    {
        while(s[cur]=='x')
        cur++;
        r.pb(n-1-cur), cur++;
        forr(j, c)
        cur++;
    }
    sort(all(r));
  
    forr(i, k)
    {
        if(l[i]==r[i])
        cout<<l[i]+1<<endl;
    }
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}


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

struct barrett {
  unsigned int _m;
  uint64_t im;
  barrett(unsigned int m):_m(m), im(uint64_t(-1)/m + 1) {}
  unsigned int umod() const {return _m;}
  unsigned int mul(unsigned int a, unsigned int b) const {
    uint64_t z = a;
    z *= b;
    uint64_t x = uint64_t(((unsigned __int128)(z)*im) >> 64);
    unsigned int v = (unsigned int)(z-x*_m);
    if(_m <= v) v += _m;
    return v;
  }
};

constexpr int64_t safe_mod(int64_t x, int64_t m) {
	x %= m;
	if(x < 0) x += m;
	return x;
}

constexpr pair<int64_t, int64_t> inv_gcd(int64_t a, int64_t b) {
	a = safe_mod(a, b);
	if(a == 0) return {b, 0};
	int64_t s = b, t = a;
	int64_t m0 = 0, m1 = 1;
	while(t) {
		int64_t u = s/t;
		s -= t*u;
		m0 -= m1*u;
		int64_t tmp = s;
		s = t;
		t = tmp;
		tmp = m0;
		m0 = m1;
		m1 = tmp;
	}
	if(m0 < 0) m0 += b/s;
	return {s, m0};
}

int64_t pow_mod(int64_t x, int64_t n, int m) {
  if(m == 1) return 0;
  barrett bt((unsigned int)(m));
  unsigned int r = 1, y = (unsigned int)(safe_mod(x, m));
  while(n) {
    if(n&1) r = bt.mul(r, y);
    y = bt.mul(y, y);
    n >>= 1;
  }
  return r;
}

int64_t inv_mod(int64_t x, int64_t m) {
  pair<int64_t, int64_t> z = inv_gcd(x, m);
  assert(z.first == 1);
  return z.second;
}

//(y, z) answer mod z = y, 無理な時は(-1, -1)
pair<int64_t, int64_t> crt(const vector<int64_t> &r, const vector<int64_t> &m) {
  int n = int(r.size());
  int64_t r0 = 0, m0 = 1;
  for(int i = 0; i < n; i++) {
    assert(1 <= m[i]);
    int64_t r1 = safe_mod(r[i], m[i]), m1 = m[i];
    if(m0 < m1) {
      swap(r0, r1);
      swap(m0, m1);
    }
    if(m0 % m1 == 0) {
      if(r0 % m1 != r1) return {-1, -1};
      continue;
    }
    int64_t g, im;
    tie(g, im) = inv_gcd(m0, m1);
    int64_t u1 = (m1/g);
    if((r1-r0)%g) return {-1, -1};
    int64_t x = (r1-r0)/g%u1 * im % u1;
    r0 += x*m0;
    m0 *= u1;
    if(r0 < 0) r0 += m0;
  }
  return {r0, m0};
}

//[0, n) (a*i+b)/m
int64_t floor_sum(int64_t n, int64_t m, int64_t a, int64_t b) {
  int64_t ans = 0;
  if(a >= m) {
    ans += ((n-1)*n>>1)*(a/m);
    a %= m;
  }
  if(b >= m) {
    ans += n*(b/m);
    b %= m;
  }
  int64_t y_max = (a*n+b)/m, x_max = y_max*m-b;
  if(y_max == 0) return ans;
  ans += (n - (x_max+a-1)/a) * y_max;
  ans += floor_sum(y_max, a, m, (a - x_max%a)%a);
  return ans;
}

int t;

int main() {
	scanf("%d", &t);
	while(t--) {
		int n, m, a, b;
		scanf("%d%d%d%d", &n, &m, &a, &b);
		printf("%lld\n", floor_sum(n, m, a, b));
	}
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=998244353;
int ad(int x,int y){return (x+y)>=mod?x+y-mod:x+y;}
void inc(int &x,int y){x=ad(x,y);}
int mul(int x,int y){return (ll)x*y%mod;}
void inc2(int &x,int y){x=mul(x,y);}
int qm(int x,int y=mod-2){int ret=1;while(y){if(y&1) ret=mul(x,ret);x=mul(x,x);y>>=1;}return ret;}
}
//using namespace Modulo;
namespace Miracle{
const int N=1e5+5;
int du[N],n;
vector<int>to[N];
int fa[N],ans;
bool vis[N],has[N];
void dfs(int x){
    for(solid y:to[x]){
        if(y==fa[x]) continue;
        fa[y]=x;
        dfs(y);
    }
}
int main(){
    rd(n);int x,y;
    int rt=0;
    for(reg i=1;i<n;++i){
        rd(x);rd(y);++x;++y;
        to[x].pb(y);to[y].pb(x);
        ++du[x];++du[y];
        if(du[x]>2) rt=x;
        if(du[y]>2) rt=y;
    }
    if(!rt) printf("1");
    else{
        dfs(rt);
        for(reg i=1;i<=n;++i){
            if(du[i]==1){
                // cout<<" ii "<<i<<endl;
                int x=i;
                while(du[fa[x]]<=2) x=fa[x];
                // cout<<" xx "<<x<<endl;
                if(!has[fa[x]]){
                    has[fa[x]]=1;
                }else{
                    if(!vis[x]){
                        vis[x]=1;
                        ++ans;
                    }
                }
            }
        }
        ot(ans);
    }
    return 0;
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
*/

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

int ans,alen,blen,a[5004],b[5004],dp[3][5003];

int main(){
	scanf("%d%d",&alen,&blen);

	for(int i = 1;i <= alen;i++)scanf("%d",&a[i]);
	for(int i = 1;i <= blen;i++)scanf("%d",&b[i]);

	for(int i = 1;i <= blen;i++){
		for(int j = 1;j <= alen;j++){
			dp[i%2][j] = dp[i%2][j-1];
			if(b[i] == a[j]){
				dp[i%2][j] = max(dp[i%2][j],dp[(i-1)%2][j-1]+1);
			}
			ans = max(dp[i%2][j],ans);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1272
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int max =0;

		if(getmax(a,b)==a){
			if (getmax(a,c)==a){
				max = a;
			}else{
				max = c;
			}

		}else{
			if (getmax(b,c)==b){
				max = b;
			}else{
				max = c;
			}
		}
		System.out.println(a+b+c-max);
	}

	public static int getmax(int n1,int n2){
		if(n1>n2){
			return n1;

		}else{
			return n2;
		}
	}
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);

  int ans = 0;
  for(int i=0; i*4<=n; i++)
    if((n-i*4) % 7 == 0){
      ans = 1;
      break;
    }

  printf("%s\n", ans ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 1648
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n; std::cin >> n;
    char prv='$';
    std::set<std::string>set;
    for(int i=0;i<n;i++){
        std::string s; std::cin >> s;
        if(prv!='$'&&prv!=s.front()||set.count(s)){
            std::cout << "No" << std::endl;
            exit(0);
        }
        set.insert(s);
        prv=s.back();
    }
    std::cout << "Yes" << std::endl;
}

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

int main() {
	int D, E;
	while (cin >> D >> E, D || E) {
		double mini = INF;
		REP(x, 0, D) {
			int y = D - x;
			
			mini = min(mini, abs(sqrt(y*y + x*x) - E));
		}

		cout << mini << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    VI a(3);
    REP(i,3) cin >> a[i];
    if (a[0] < a[1] && a[1] < a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K;
            string tmp;

            tmp = Console.ReadLine();
            string[] afterSplit = tmp.Split();
            N = int.Parse(afterSplit[0]);
            K = int.Parse(afterSplit[1]);

            int[] p = new int[N];
            tmp = Console.ReadLine();
            string[] priceString = tmp.Split();
            for (int i = 0; i < N; i++)
            {
                p[i] = int.Parse(priceString[i]);
            }

            Array.Sort(p);

            int answer = 0;
            for (int i = 0; i < K; i++)
            {
                answer += p[i];
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	int mx = 0;
	mx = max(mx, a * 10 + b + c);
	mx = max(mx, a + b * 10 + c);
	mx = max(mx, a + b + c * 10);
	cout << mx << endl;
	return 0;
}



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

int main() {
	int N;
	cin >> N;
	int64_t ans = N / 2;
	for (int i = 0, j = N;i < j;ans = i + (j - i) / 2) { // 二分探索アルゴリズム
		if (ans * ans <= N) i = ans + 1; // iは求める値の範囲の下限
		else j = ans - 1; // jは求める値の範囲の上限
	}
	if (ans * ans > N) ans --; // この二分探索アルゴリズムだと最終的に1だけ多いことがあるので
	cout << ans * ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

N以下の平方数のうち最大のものの平方根をMとする
この時、1～Mまでは二乗してもN以下であり、M+1～Nまでは二乗するとNより大きい
これを利用すると、二分探索を用いてMを特定することができる
後はM^2を出力すればいい
オーダーはO(logN)であり、高速に振舞う

あ、計算の都合上時々ansは10^9*10^9==10^18<=2^60まで扱うので64bitの整数を使わないとオーバーフローするよ
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int x; cin >> x;
	if (x==7 || x==5 || x==3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

struct StAnsHist
{
  StAnsHist() : m_nProblmNo(0), m_sJudge("") { }

  int    m_nProblmNo;
  string m_sJudge;
};

void fnInput(int& rnProblmSiz, vector<StAnsHist>& rvoAnsHist)
{
  int nSubmitSiz;
  cin >> rnProblmSiz >> nSubmitSiz;
  rvoAnsHist.resize(nSubmitSiz);

  for(StAnsHist& roAnsHist : rvoAnsHist)
    cin >> roAnsHist.m_nProblmNo >> roAnsHist.m_sJudge;
}
  
void fnAnserCheck(int nProblmSiz, const vector<StAnsHist>& cnrvoAnsHist, 
                  int& rnRightAns, int& rnPenalty)
{
  vector<int> vnWACnt(nProblmSiz + 1);
  set<int> stRightAns;

  rnRightAns = 0;
  rnPenalty = 0;

  for (StAnsHist oAnsHist : cnrvoAnsHist)
  {
    if (oAnsHist.m_sJudge == "AC")
      stRightAns.insert( oAnsHist.m_nProblmNo );
    else
      if (!stRightAns.count( oAnsHist.m_nProblmNo ))
        vnWACnt[ oAnsHist.m_nProblmNo ]++;
  }

  rnRightAns = stRightAns.size();

  for (int nRightAns : stRightAns)
    rnPenalty += vnWACnt[nRightAns]; 
}
  
int main()
{
  int nProblmSiz;
  vector<StAnsHist> voAnsHist;
  fnInput(nProblmSiz, voAnsHist);

  int nRightAns, nPenalty;
  fnAnserCheck(nProblmSiz, voAnsHist, nRightAns, nPenalty);

  cout << nRightAns << " " << nPenalty;
  return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>


int main (void)
{
	int a,b,flag=0;
	char str[64];
  
	fgets(str,sizeof(str),stdin);
	sscanf(str,"%d %d",&a,&b);
	
	if(a%3 == 0)
	{
		flag++;
	}
	if(b%3 == 0)
	{
		flag++;
	}
	if((a+b)%3 == 0)
	{
		flag++;
	}
	
	if(flag > 0)
	{
		puts("Possible");
	}else
	{
		puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 128
# C - management
def main():
    N, *A = map(int, open(0).read().split())
    cnt_subordinates = [0] * (N + 1)
    for a in A:
        cnt_subordinates[a] += 1
    print("\n".join(map(str, cnt_subordinates[1:])))


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int x[100005];
int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    ll ans = 0;
    for(int i=1;i<=n;i++){
        scanf("%d", &x[i]);
        if(i > 1) ans += min(a*1ll*(x[i]-x[i-1]), b*1ll);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 4124
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n, x;
	cin >> n >> x;
	int p[100005], dif[100005];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	p[n] = x;
	sort(p, p + n + 1);
	int mini = 1000000000, num;
	for (int i = 0; i < n; i++) {
		dif[i] = p[i + 1] - p[i];
		mini = min(mini, dif[i]);
		if (mini == dif[i])num = i;
	}
	while (1) {
		for (int i = 0; i < n; i++) {
			if (i == num)continue;
			dif[i] %= mini;
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (dif[i] == 0) {
				count++;
				continue;
			}
			mini = min(mini, dif[i]);

		}
		if (count == n - 1)break;
	}
	cout << mini << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int h, w;
vstr a;
vint dx = {1, 0, -1, 0};
vint dy = {0, 1, 0, -1};

vvint bfs(vvint d, int x, int y) {
    queue<P> que;
    que.push(P(x, y));
    d[x][y] = 0;

    while (que.size()) {
        P p = que.front();
        que.pop();
        if (a[p.fi][p.se] == '#') d[p.fi][p.se] = 0;
        rep(i, 4) {
            int nx = p.fi + dx[i], ny = p.se + dy[i];

            if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] > d[p.fi][p.se] + 1) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.fi][p.se] + 1;
            }
        }
    }

    return d;
}

int main() {
    cin >> h >> w;
    a.resize(h);
    rep(i, h) {
        cin >> a[i];
    }
    int mx = 0;
    vvint d(h, vint(w, INF));
    rep(i, h) {
        rep(j, w) {
            if (a[i][j] == '.') continue;
            else {
                d = bfs(d, i, j);
                break;
            }
        }
    }
    rep(i, h) mx = max(mx, vmax(d[i]));;

    int ans = mx;

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

Measured memory_bytes: 9248
import collections
n=int(input())
a = list(map(int,input().split()))
b = collections.Counter(a)
c = list()
for i in range(1,n+1):
    c.append(int((b[i]*(b[i]-1))/2))

sum = sum(c)
for i in range(n):
    d = int(a[i]-1)
    if c[d]>2:
        e = sum - c[d] + int( (c[d])*(b[d+1]-2) /(b[d+1]) )
    else:
        e = sum - c[d]
    print(e)

Measured memory_bytes: 26780
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

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; }

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

int main(){
  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> h[i];
  
  for(int i = 0; i < n + 1; i++) dp[i] = INF;
  
  dp[0] = 0;
  
  for(int i = 0; i < n; i++){
    chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
char s[SIZE];
int main(){
    DRIII(n,A,B);
    RS(s);   
    int x=0,y=0;
    REP(i,n){
        if(s[i]=='a'){
            if(x+y<A+B){
                x++;
                puts("Yes");
            }
            else puts("No");
        }
        else if(s[i]=='b'){
            if(x+y<A+B&&y<B){
                y++;
                puts("Yes");
            }
            else puts("No");
        }
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 768
N,e = map(int, input().split())
inf = float("inf")
adj = [[inf for _ in range(N)]  for _ in range(N)]
for _ in range(e):
    s,t,d = map(int, input().split())
    adj[s][t] = d

def memorize(f):
    cache = {}
    def func(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]
    return func

@memorize
def tsp(v, b):
    if b == (1 << N) - 1:
        return adj[v][0]
    res = inf
    for w in range(N):
        if b & (1 << w): continue
        res = min(res, adj[v][w] + tsp(w, b | (1 << w)))
    return res

if tsp(0,1) == inf:
    print(-1)
else: print(tsp(0,1))

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  ll ans = 0;
  FOR(b,1,N+1) {
    int p = N / b;
    int r = N % b;
    ans += p * max(0, b - K) + max(0, r - K + 1);
    if(K == 0) ans--;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a;
	if(n == 3){
		a.push_back(2);
		a.push_back(5);
		a.push_back(63);
	}else if(n == 4){
		a.push_back(2);
		a.push_back(5);
		a.push_back(20);
		a.push_back(63);
	}else if(n == 5){
		a.push_back(2);
		a.push_back(5);
		a.push_back(20);
		a.push_back(30);
		a.push_back(63);
	}else{
		for(int i = 0; i < 30000 && a.size() + 6 <= n; i += 12){
			a.push_back(i +  2);
			a.push_back(i +  3);
			a.push_back(i +  4);
			a.push_back(i +  8);
			a.push_back(i +  9);
			a.push_back(i + 10);
		}
		for(int i = 6; a.size() < n; i += 6){
			a.push_back(i);
		}
	}
	sort(a.begin(), a.end());
	for(const auto x : a){
		cout << x << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int lli;
#define vi vector<int>
#define vs vector<string>
#define pb push_back
#define endl "\n"
#define sortin sort(arr.begin(),arr.end())
#define inputArray for(int i{};i<n;i++){cin>>arr[i];}
#define inputArray1 for(int i{};i<m;i++){cin>>arr1[i];}
#define intloop for(int i{};i<n;i++)
#define intloopminus for(int i{};i<n-1;i++)
#define strloop for(int i{};i<str.length();i++)
#define N int n;cin>>n
#define strlen str.length()
#define InputStr string str;cin>>str
#define twoinputs int n,k;cin>>n>>k
#define T int t;cin>>t;while(t--)
using namespace std;
int main()
{
    N;
    cout<<n*(n+1)/2<<endl;
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for(int i=a; i<=b; i++){
			if(i<a+k || b-k<i)System.out.println(i);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

pair<int, bool> P[100001];
bool dame[100001];

pair<int, bool> Find(int A) {
	if (P[A].first < 0) return mp(A, 0);
	auto p = Find(P[A].first);
	P[A].first = p.first;
	P[A].second ^= p.second;
	return P[A];
}

bool Unite(int A, int B) {
	auto a = Find(A);
	auto b = Find(B);
	if (a.first == b.first) {
		if(a.second == b.second) dame[a.first] = true;
		return false;
	}
	if (P[a.first].first > P[b.first].first) swap(a, b);
	P[a.first].first += P[b.first].first;
	dame[a.first] |= dame[b.first];
	P[b.first] = mp(a.first, !(a.second ^ b.second));
	return true;
}

int Size(int A) {
	return -P[Find(A).first].first;
}

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


	int N = getint(), M = getint();
	rep1(i, N) P[i] = mp(-1, 0);
	rep(i, M) {
		int a = getint(), b = getint();
		Unite(a, b);
	}

	ll x = 0, y = 0, z = 0;
	rep1(i, N) {
		if (Find(i).first == i) {
			if (Size(i) > 1) {
				if (dame[i]) y++;
				else x++;
			}
			else z++;
		}
	}
	co(x * x + (x + y) * (x + y) + 2 * N * z - z * z);

	Would you please return 0;
}

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

int main(){
    int H, W;
    std::cin >> H >> W;
    std::vector< std::string > S(H);
    for(int i=0; i<H; i++){
        std::cin >> S[i];
    }
    
    std::vector< std::vector< int > > H_continue(H, std::vector< int >(W));
    std::vector< std::vector< int > > W_continue(H, std::vector< int >(W));
    
    for(int i=0; i<H; i++){
        int c = 0;
        int index = 0;
        for(int j=0; j<W; j++){
            if(S[i][j] == '#'){
                for(int k=index; k<j; k++){
                    H_continue[i][k] = c;
                }
                H_continue[i][j] = 0;
                c = 0;
                index = j + 1;
            }else{
                if(j == W - 1){
                    c++;
                    for(int k=index; k<=j; k++){
                        H_continue[i][k] = c;
                    }
                }else{
                    c++;
                }
            }
        }
    }
    
    for(int j=0; j<W; j++){
        int c = 0;
        int index = 0;
        for(int i=0; i<H; i++){
            if(S[i][j] == '#'){
                for(int k=index; k<i; k++){
                    W_continue[k][j] = c;
                }
                W_continue[i][j] = 0;
                c = 0;
                index = i + 1;
            }else{
                if(i == H - 1){
                    c++;
                    for(int k=index; k<=i; k++){
                        W_continue[k][j] = c;
                    }
                }else{
                    c++;
                }
            }
        }
    }
    
    int max = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(max < H_continue[i][j] + W_continue[i][j] - 1){
                max = H_continue[i][j] + W_continue[i][j] - 1;
            }
        }
    }
    std::cout << max << std::endl;
    
    return 0;
}



Measured memory_bytes: 35712
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Flip,Flip, and Flip......
            var line = ReadLine();
            long N = line[0];
            long M = line[1];
            long ans;

            if (N == 2 | M == 2)
            {
                ans = 0;
            }
            else if (N == 1 | M == 1)
            {
                ans = Math.Max(N, M) - 2;

                //N,Mが両方とも"1"のケースを考慮
                ans = Math.Max(ans, 1);
            }
            else
            {
                ans = (N - 2) * (M - 2);
            }

            Console.WriteLine(ans);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

ll GCD(ll a, ll b){
    if(a < b) return GCD(b,a);
    if(b == 0) return a;
    else return GCD(b,a%b);
}

int main(){
  ll K;
  cin >> K;
  ll ans = 0;
  for(int i = 1;i <= K;i++){
    for(int j = 1;j <= K;j++){
      for(int k = 1;k <= K;k++){
        ans += GCD(GCD(i,j),k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int ball[10];
int serch(int now,int B,int C)
{
    if(now==10)return 1;
    if(B<ball[now])return serch(now+1,ball[now],C);
    if(C<ball[now])return serch(now+1,B,ball[now]);
    return 0;
}
int main()
{
    int n,ans;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++)cin>>ball[j];
        ans=serch(0,0,0);
        if(ans==1)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

}

Measured memory_bytes: 1152
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = Integer.parseInt(sc.next());
        sc.close();

        if (N <= 999) {
            out.printf("ABC\n");
        } else {
            out.printf("ABD\n");
        }
        out.flush();
    }
}


Measured memory_bytes: 22996
import java.util.Scanner;

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

		int[] a = new int[N + 1];
		for (int i = 1; i <= N; i++)
			a[i] = sc.nextInt();
		int[] b = new int[N + 1];
		int M = 0;
		for (int i = N; i >= 1; i--) {
			int x = 0;
			for (int j = i; j <= N; j += i)
				x += b[j];
			if (x % 2 != a[i]) {
				b[i] = 1;
				M++;
			}
		}
		System.out.println(M);
		for (int i = 1; i <= N; i++) {
			if (b[i] == 1)
				System.out.println(i);
		}
	}
}


Measured memory_bytes: 90348
def main():
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    total_time = 0
    for time, deadline in sorted(AB, key=lambda x: x[1]):
        total_time += time
        if total_time > deadline:
            print('No')
            break
    else:
        print('Yes')
main()

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORD(i, m, n) for (int i = m; i >= n; i--)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 0; i <= n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

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

	string n;
	cin >> n;
	if(n[1]==n[2]){
		if(n[0]==n[1]||n[2]==n[3]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

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


using namespace std;


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


int main() {
    int n;
    cin >> n;
    int a[n];
    for (int& x : a)
        cin >> x;
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            ans += a[i] * a[j];
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    map<int,int> amap;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        amap[a]++;
    }
    
    if(n==amap.size()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 9600
import java.util.Random;
import java.util.Scanner;

public class Main {
    static int d = 365;
    static int[] c = new int[26];
    static int[][] s = new int[d][26];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        sc.nextInt();
        for (int i=0;i<26;i++){
            c[i]=sc.nextInt();
        }
        for (int i=0;i<d;i++){
            for (int j=0;j<26;j++){
                s[i][j]=sc.nextInt();
            }
        }
        int[] contest = new int[d];
        int count = 100000;
        for (int i=0;i<d;i++)contest[i]=random.nextInt(26);
        for (int i=0;i<count;i++){
            int[] instance = contest.clone();
            int times = random.nextInt(25)+15;
            int[] choose = new int[times];
            for (int j=0;j<times;j++)choose[j]=random.nextInt(d);
            for (int j=0;j<times;j++)instance[choose[j]]=random.nextInt(26);
            if (function(contest)<function(instance))contest=instance;
        }
        for (int i=0;i<d;i++)System.out.println(contest[i]+1);
    }
    static long function(int[] contest){
        long satisfaction = 0;
        int[] interval = new int[26];
        for (int i=0;i<d;i++){
            satisfaction+=s[i][contest[i]];
            for (int j=0;j<26;j++)interval[j]++;
            interval[contest[i]]=0;
            for (int j=0;j<26;j++)satisfaction-=c[j]*interval[j];
        }
        return  satisfaction;
    }
}


Measured memory_bytes: 58184
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100000

ll Weight[N+5],Profit[N+5],dp[2][N+5];

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,w;cin>>n>>w;
   for(int i=1;i<=n;i++){
      cin>>Weight[i]>>Profit[i];
   }
   fill(dp[0],dp[0]+2*(N+5),INT_MAX*105);
   dp[(n+1)%2][0]=0;
   for(int i=n;i>=1;i--){
      for(int p=0;p<=N;p++){
         ll op1=dp[(i+1)%2][p];
         ll op2=(p-Profit[i]>=0)?Weight[i]+dp[(i+1)%2][p-Profit[i]]:INT_MAX*105;
         dp[i%2][p]=min(op1,op2);
      }
   }
   int ans=0;
   for(int i=0;i<=N;i++){
      if(dp[1][i]<=w){
         ans=max(ans,i);
      }
   }
   cout<<ans<<"\n";
   return 0;
}


Measured memory_bytes: 5216
n = input()
data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(0,len(data)-1):
  if data[i]  == n:
    print(data[i+1])

Measured memory_bytes: 3060
#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 r, d, x2000;
  cin >> r >> d >> x2000;

  int result = x2000;
  rep(i, 10) {
    result = r * result - d;
    cout << result << endl;
  }

  return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>x>>n;
    set<ll> st;
    for0(n)
    {
        cin>>a;
        st.insert(a);
    }
    y=st.size();
    a=b=x;
    while(1)
    {
        st.insert(a);
        if(y<st.size())
        {
            cout<<a<<endl;
            break;
        }
        st.insert(b);
        if(y<st.size())
        {
            cout<<b<<endl;
            break;
        }
        a--;b++;
    }
}



Measured memory_bytes: 3620
#include<stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n,i,sum=1;

  scanf("%d",&n);
  char s[n][11];
   for(i=0; i<n; i++)
       scanf("%s",&s[i]);

  qsort(s,n,11,strcmp);

  for(i=1;i<n;i++){
      if(strcmp(s[i],s[i-1])!=0) 
        sum++;    
  }
   
  printf("%d",sum);
  
  return 0;
}


Measured memory_bytes: 5744
def check_str(s):
    n = len(s) - 1
    if (s[1] != 1) or (s[-1] != 0):
        return False
    else:
        for i in range(1, n / 2):
            if s[i] != s[n - i]:
                return False
    return True

def solve():
    s = [int(_) for _ in raw_input()]
    s.insert(0,0)
    if not check_str(s):
        print '-1'
        return
    sub = []
    for i in range(len(s)):
        if s[i] == 1:
            sub.append(i)
    ## Create tree caterpillar type
    ## body
    body_leng = len(sub) + 1
    for i in range(1, body_leng):
        print str(i) + ' ' + str(i+1)
    ## legs
    cnt = body_leng
    for i in range(1, body_leng - 1):
        num_legs = sub[i] - sub[i-1] - 1
        for j in range(cnt + 1, cnt + num_legs + 1):
            print str(i+1) + ' ' + str(j)
        cnt += num_legs

if __name__ == '__main__':
    solve()


Measured memory_bytes: 10952
#include <iostream>
using namespace std;
int main(void){
    
    int a,m,h,i;
    
    string w,x,y;  //文字を受ける
    
    while(1){
    
       cin >> w;
         if(w == "-")break;
       cin >> m;  //カードN
    
       //a =  w.length();
    
       //cout << a << endl; 「入力確認用」
    
          for(i=0;i<m;i++){
              cin >> h;
              x = w.substr(0,h); //ｘは切り取る部分
              y = w.substr(h);  //ｙは残りの部分
              w = y+x;         // 並べる
              //cout << w << endl; 「順番確認用」
           }
           cout << w << endl;
    
        
    }
    
    
    return 0;
    
}




Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MX 100005

const ll INF = 1e12;

int A[MX][4];
ll dp[MX][4];

ll recur(int i, int j){
    if (i == 1) return dp[i][j] = A[i][j];
    if (dp[i][j] != -1) return dp[i][j];

    ll mx = 0;
    for (int x = 1; x <= 3; x++){
        if (x != j) mx = max(mx, recur(i-1, x));
    }
    return dp[i][j] = (mx + A[i][j]);
}

int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 3; j++){
            scanf("%d", &A[i][j]);
            dp[i][j] = -1;
        }
    }

    ll ans = 0;
    for (int j = 1; j <= 3; j++){
        ans = max(ans, recur(n, j));
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
int main()
{
	int n,m,i,j,k,s,t,x;
	while(~scanf("%d%d",&n,&x))
	{
		s=1;k=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&m);
			k+=m;
			if(k<=x) s++;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

struct work {
  ll a;
  ll b;
};


int asc(const void *x, const void *y){
  struct work *c = (struct work *)x;
  struct work *d = (struct work *)y;
  if(c->b - d->b > 0) return 1;
  if(c->b == d->b) return 0;
  else return -1;
}



int
main(int argc, char *argv[])
{
  int  n; ll aa, bb;
  struct work w[200000];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%lld %lld", &aa, &bb);
    w[i].a = aa;
    w[i].b = bb;
  }

  

  qsort(w, n, sizeof(struct work), asc);


  ll time = 0; int flag = 0;

  for(int i = 0; i < n; i++){
    time += w[i].a;
    if(time > w[i].b){
      flag++;
      break;
    }
  }

  if(flag > 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}
    
    


Measured memory_bytes: 6396
#include<stdio.h>
int cal(int r,int temp,int d)
{
  int s;
  s=r*temp-d;
  return s;
}
int main()
{
int r,d;
int x2000;
int i,temp;
scanf("%d%d%d",&r,&d,&x2000); 
  temp=x2000;
  for(i=1;i<=10;i++)
  {
	temp=cal(r,temp,d);  
    printf("%d\n",temp);
  
  }
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int o,w;
    while(scanf("%d%d",&o,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=o;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=o;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    string s;
    cin >> s;
    for (auto c: s) {
        if (c == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
Public Class Program
  Shared Sub Main()
    Dim s As String = Console.ReadLine()
    Dim sLength As Integer = s.Length()
    Dim ans As Integer = 0
    For i As Integer = 0 To sLength \ 2 - 1
      If s(i) <> s(sLength - 1 - i) Then ans += 1
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x = -x;
    ll m = x % d - d;
    ll u = (x - m) / d;
    if (k >= u) {
        if ((k - u) % 2 == 0)
            cout << abs(m) << endl;
        else
            cout << abs(m + d) << endl;
    } else {
        cout << abs(x - k * d) << endl;
    }
}

Measured memory_bytes: 3636
def ALDS1_5A():
    n, A, q = int(input()), list(map(int, input().split())), int(input())
    S=[False for i in range(2001)]
    for a in A:
        for i in range(2001-a, 0, -1):
            if S[i]: S[i+a] = True
        S[a] = True
    for mi in input().split():
        if S[int(mi)]:
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    ALDS1_5A()

Measured memory_bytes: 7804
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
long long ans=0;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	int n;
	n=read();
	for(rr int i=1;i<=n;++i){
		if(i%5&&i%3){
			ans+=i;
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3700
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        out.print(b-a == c-b ? "YES" : "NO");
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23252
#include <stdio.h>
 int main(void)
{
int a, b, c;
 scanf("%d%d%d", &a, &b, &c);
 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;
 if (ispoor) {
 puts("Yes");
 } else 
 puts("No");
 
 return 0;
 }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	string s;
	cin >> s;
	if (s == "Sunny")
		printf("Cloudy\n");
	else if (s == "Cloudy")
		printf("Rainy\n");
	else
		printf("Sunny\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int left = 0;
    int right = w;
    int up = 0;
    int down = h;
    for(int i=0;i<n;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            left = max(left,x);
        }else if(a==2){
            right = min(right,x);
        }else if(a==3){
            up = max(up,y);
        }else{
            down = min(down,y);
        }
    }
    int ans = (right-left)*(down-up);
    if(right-left<=0 || down-up<=0)ans=0;
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);

  int heap[n + 1];
  for (int i = 1; i <= n; ++i)
    scanf("%d", &heap[i]);

  for (int i = 1; i <= n; ++i)
  {
    printf("node %d: ", i);
    printf("key = %d, ", heap[i]);
    if (i > 1)
      printf("parent key = %d, ", heap[i / 2]);
    if (2 * i <= n)
      printf("left key = %d, ", heap[2 * i]);
    if (2 * i + 1 <= n)
      printf("right key = %d, ", heap[2 * i + 1]);
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2740
N = int(input())
count = 0
BA = 0
Ba = 0
bA = 0
for i in range(N):
    a = input()
    count += a.count('AB')
    if a[0] == 'B':
        if a[-1] =='A':
            BA += 1
        else:
            Ba += 1
    elif a[-1] == 'A':
        bA +=1
if BA == 0:
    count += min(Ba,bA)
else:
    if bA or Ba:
        count += BA + min(bA,Ba)
    else:
        count += BA-1
print(count)

Measured memory_bytes: 3064