akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int ans=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            ans++;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,count=0;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=a;i<b+1;i++){
		if(c%i==0)count++;
	}
	printf("%d\n",count);
	return 0;
}


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

int main(){
    int N, H, a, b, c;
    cin >> N;
    bool flag;
    vector<int> x(N), y(N), h(N);
    
    for(int i=0; i<N; i++){
	cin >> x[i]>> y[i]>> h[i];	
	if(h[i] != 0){
	    a = x[i];
	    b = y[i];
	    c = h[i];
	}
	    
    }

    for(int xpos=0; xpos<=100; xpos++){
	for(int ypos=0; ypos<=100; ypos++){
	    H = c + abs(xpos-a) + abs(ypos-b);	    
	    flag = true;
	    for(int i=0; i<N; i++){
		if(h[i] != max(H - abs(xpos-x[i]) - abs(ypos-y[i]), 0)){
		    flag = false;
		    break;
		}
	    }
	    if(flag){
		cout << xpos <<" "<< ypos <<" "<< H <<endl;
		return 0;
	    }
	}
    }

    assert(0);
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const int64_t CYCLES_PER_SEC = 2800000000;

struct Timer {
  int64_t start;
  Timer() { reset(); }
  void reset() { start = getCycle(); }
  void plus(double a) { start -= (a * CYCLES_PER_SEC); }
  inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
  inline int64_t getCycle() {
    uint32_t low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((int64_t)low) | ((int64_t)high << 32);
  }
};

class XorShift {
public:
  unsigned int x, y, z, w;
  double nL[65536];

  XorShift()
  {
    init();
  }

  void init()
  {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288;
    double n = 1 / (double)(2 * 65536);
    for (int i = 0; i < 65536; i++) {
      nL[i] = log(((double)i / 65536) + n);
    }
  }
  void setSeed(int seed) {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288 + seed;
    for (int i = 0; i < 500; i++) {
      next();
    }
  }
  inline unsigned int next()
  {
    unsigned int t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
  }

  inline double nextLog() {
    return nL[next() & 0xFFFF];
  }

  inline int nextInt(int m)
  {
    return (int)(next() % m);
  }


  int nextInt(int min, int max)
  {
    return min + nextInt(max - min + 1);
  }


  double nextDouble()
  {
    return (double)next() / ((long long)1 << 32);
  }


};



// グローバル変数
Timer timer;
XorShift rnd;

int D;
vector<int> c(26,0);
vector<vector<int>> s;

vector<int> bestState;
int bestScr;



void input(){
  cin>>D;
  rep(i,26) cin>>c[i];
  s.resize(D, vector<int>(26,0));
  rep(i,D)rep(j,26) cin>>s[i][j];

  bestState.resize(D);
};

void output(){
  for(auto e:bestState) cout<<e<<endl;
};

int eval(){
  return 1;
}

void init(){

  rep(i,D) bestState[i] = 1;
}

void rndInit(){
  rep(i,D) bestState[i] = rnd.nextInt(1,26);
}


void solveClimb(){
  double ti;
  double T;
  double T0 = 100; // 調整する
  double rem;


  double TIMELIMIT = 1.98;
  double st = timer.get();

  while(true){
    ti = timer.get();

    if(ti > TIMELIMIT){
      // cout<<"break"<<endl;
      break;
    }
    rem = (TIMELIMIT - ti) / (TIMELIMIT - st);
    T = rem * T0;

    cout<<ti<<" "<<rem<<endl;

  }

};





int main() {
  cout<<fixed<<setprecision(12);

  input();

  // init();
  rndInit();

  // solveClimb();
  output();

;






}


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

bool isOK(string s, string t) {
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != '?' && s[i] != t[i]) return false;
    }
    return true;
}

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = n - 1; i >= m - 1; --i) {
        if (isOK(s.substr(i - m + 1, m), t)) {
            for (int j = 0; j < n; ++j) {
                if (s[j] != '?') cout << s[j];
                else if (i - m + 1 <= j && j <= i) cout << t[j - (i - m + 1)];
                else cout << 'a';
            }
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}


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

using namespace std;

int main() {
  long k, n;
  cin >> k >> n;

  long as[n];
  for (int i = 0; i < n; i++) { cin >> as[i]; }

  long max = 0;
  for (int i = 0; i < n - 1; i++) {
    long dif = as[i + 1] - as[i];
    if (max < dif) max = dif;
  }
  long dif = as[0] + k - as[n - 1];
  if (max < dif) max = dif;

  cout << k - max << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	double d;
	while(scanf("%lf", &d) != EOF) {
		double r[10];
		r[0] = d;
		rep2(i,1,10) {
			if(i % 2) r[i] = r[i-1] * 2;
			else r[i] = r[i-1] / 3;
		}
		double ret = 0;
		rep(i,10) {
			ret += r[i];
		}
		printf("%.8lf\n", ret);
	}
	return 0;
}

Measured memory_bytes: 1236
A,B,C,D,E,F = map(int,input().split())
mx =- 1
S = set()
W = set()

for a in range(0,F+1,100*A):
  for b in range(0,F+1-a,100*B):
    W.add(a+b)

for c in range(0,F+1,C):
  for d in range(0,F+1-c,D):
    S.add(c+d)

for w in W:
  for s in S:
    if 0<w+s<=F and s<=w*E//100:
      if mx<s/(w+s):
        ans=w+s,s
        mx=s/(w+s)

print(ans[0],ans[1])

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin>>s;
  static ll a,b,c;
  if(s[0]=='a') a++;
  if(s[0]=='b') b++;
  if(s[0]=='c') c++;
  if(s[1]=='a') a++;
  if(s[1]=='b') b++;
  if(s[1]=='c') c++;
  if(s[2]=='a') a++;
  if(s[2]=='b') b++;
  if(s[2]=='c') c++;
  if(a==b&&b==c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

ll dx[] = {0, 0, 1, -1};
ll dy[] = {1, -1, 0, 0};

int main()

{

    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll mx = max(x,y);
    mx*=2;
    ll cst = inf;
    for(ll i = mx; i >= 0; i--)
    {

        ll abc = i*c;
        ll acab=i/2;
        ll an=0, bn=0;
        if(x > acab) an=x-acab;
        if(y > acab) bn = y-acab;
        ll tc = abc+an*a+bn*b;
        //cout << "CH " << i << " " << acab << " " <<
        cst = min(cst,tc);
    }
    cout << cst;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
/* test
typedef struct {
	double x;
	double y;
} point;

typedef struct {
	double a;
	double b;
	double c;
} abc;

point ans;

void GetCenter(abc* p, abc* q);

int main(void) {
	point p[3];
	abc tmpP[2];
	char buf[80];
	int i, j, n;
	double tmp1, tmp2, tmp3;
	
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &n);
	
	for (i=0; i<n; i++) {
		fgets(buf, sizeof(buf), stdin);
		sscanf(buf, "%lf %lf %lf %lf %lf %lf",
			&p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y);
		
		/*
		tmpP[0].a = -2*(p[0].x - p[1].x);
		tmpP[0].b = -2*(p[0].y - p[1].y);
		tmpP[0].c = (p[0].x*p[0].x) - (p[0].y*p[0].y) + (p[1].x*p[1].x) - (p[1].y*p[1].y);
		
		tmpP[1].a = -2*(p[1].x - p[2].x);
		tmpP[1].b = -2*(p[1].y - p[2].y);
		tmpP[1].c = (p[1].x*p[1].x) - (p[1].y*p[1].y) + (p[2].x*p[2].x) - (p[2].y*p[2].y);
		
		GetCenter(&tmpP[0], &tmpP[1]);
		*
		
		ans.x = ((p[0].y-p[2].y)*(pow(p[0].y, 2)-pow(p[1].y, 2)+pow(p[0].x, 2)-pow(p[1].x, 2)) - 
			((p[0].y-p[1].y)*(pow(p[0].y, 2)-pow(p[2].y, 2)+pow(p[0].x, 2)-pow(p[2].x, 2)))) / 
			(2*(p[0].y-p[2].y)*(p[0].x-p[1].x)-2*(p[0].y-p[1].y)*(p[0].x-p[2].x));
			
		ans.y = ((p[0].x-p[2].x)*(pow(p[0].x, 2)-pow(p[1].x, 2)+pow(p[0].y, 2)-pow(p[1].y, 2)) - 
			((p[0].x-p[1].x)*(pow(p[0].x, 2)-pow(p[2].x, 2)+pow(p[0].y, 2)-pow(p[2].y, 2)))) / 
			(2*(p[0].x-p[2].x)*(p[0].y-p[1].y)-2*(p[0].x-p[1].x)*(p[0].y-p[2].y));
		
		printf("%.3f %.3f\n", ans.x, ans.y);
		
		tmp1 = (p[0].x - ans.x);
		tmp1 *= tmp1;
		tmp2 = (p[0].y - ans.y);
		tmp2 *= tmp2;
		tmp3 = sqrt(tmp1+tmp2);
		
		printf("%.3f %.3f %.3f\n", ans.x, ans.y, tmp3);
	}
	
	return 0;
}


void GetCenter(abc* p, abc* q) {
	double a, b, c, d, e, f;
	double na, nb, nc, nd, ne, nf;
	double x, y;
	
	a=p->a; b=p->b; c=p->c;
	d=q->a; e=q->b; f=q->c;
	
	na=a*d; nb=b*d; nc=c*d;
	nd=d*a; ne=e*a; nf=f*a;
	
	na-=nd; nb-=ne; nc-=nf;
	
	y = nc/nb;
	x = (c - b*y)/a;
	
	ans.x=x;
	ans.y=y;
}

*/
int main(){
    int a;
    scanf("%d",&a);
    for(;a>0;a--){
        double a1,a2,b1,b2,c1,c2,x1,y1,x2,y2,x3,y3;
        double x,y,r;
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        a1=2*(x2-x1),b1=2*(y2-y1);
        c1=x1*x1-x2*x2+y1*y1-y2*y2;
        a2=2*(x3-x1),b2=2*(y3-y1);
        c2=x1*x1-x3*x3+y1*y1-y3*y3;
        x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
        y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
        r=hypot(x-x1,y-y1);
        printf("%.3lf %.3lf %.3lf\n",x,y,r);
    }
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int x, y, a;
		int[][] area = new int[h][w];
		for (int i = 0; i < n; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			a = sc.nextInt();
			black(area, x, y, a);
		}
		show(area);
	}

	private static void show(int[][] area) {
		int cnt = 0;
		for (int i = 0; i < area.length; i++) {
			for (int j = 0; j < area[0].length; j++) {
				if (area[i][j] == 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

	private static void black(int[][] area, int x, int y, int a) {
		switch (a) {
		case 1:
			for (int i = 0; i < area.length; i++) {
				for (int j = 0; j < x; j++) {
					area[i][j] = 1;
				}
			}
			break;
		case 2:
			for (int i = 0; i < area.length; i++) {
				for (int j = x; j < area[0].length; j++) {
					area[i][j] = 1;
				}
			}
			break;
		case 3:
			for (int i = 0; i < y; i++) {
				Arrays.fill(area[i], 1);
			}
			break;
		case 4:
			for (int i = y; i < area.length; i++) {
				Arrays.fill(area[i], 1);
			}
			break;
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MOD 1000000007
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
LL fact[1100000];
LL invfact[1100000];
 
void init(){
    fact[0] = 1;
    invfact[0] = 1;
    for(LL i = 1; i < 1100000; i++){
        fact[i] = (i*fact[i-1]) % MOD;
        invfact[i] = inv(fact[i]);
    }
}
 
int main(){
	init();
	LL n;
	cin >> n;
	LL ans = (n-1) * fact[n-1];
	ans %= MOD;
	LL k = n-2;
	for(LL a = 1; a*2 <= k; a++){
		LL cur = fact[k-a];
		cur = (cur * fact[n-1-a]) % MOD;
		cur = (cur * invfact[k-2*a]) % MOD;
		ans -= cur;
		ans %= MOD;
	}
	if(ans < 0) ans += MOD;
	cout << ans << endl;
}

Measured memory_bytes: 17408
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    int x=0,num, prenum;
    for(int i=0; i<n; i++){
        num=a[i]-1;
        x+=b[num];
        if(i!=0){
            prenum=a[i-1]-1;
            if(num-prenum==1){
                x+=c[prenum];
            }
        }
    }
    cout<<x;
    return 0;
}


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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var graph = new List<(int, int)>[n];

            for (var i = 0; i < n; i++)
            {
                var a = int.Parse(Console.ReadLine());
                graph[i] = new List<(int, int)>();
                for (var j = 0; j < a; j++)
                {
                    var inputs = Console.ReadLine().Split(" ");
                    var x = int.Parse(inputs[0]) - 1;
                    var y = int.Parse(inputs[1]);
                    graph[i].Add((x, y));
                }
            }

            var result = 0;
            for (var bits = 0; bits < 1 << n; bits++)
            {
                var ok = true;
                var count = 0;
                for (var i = 0; i < n; i++)
                {
                    if (((bits >> i) & 1) == 0) continue;
                    count++;
                    for (var j = 0; j < graph[i].Count; j++)
                    {
                        if ((bits >> (graph[i][j].Item1) & 1) != graph[i][j].Item2)
                        {
                            ok = false;
                        }
                    }
                }
                if (ok)
                {
                    result = Math.Max(result, count);
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 10001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {printf("0\n"); return 0;}
#define FAIL_1 {printf("-1\n"); return 0;}

int N, M;
int D[] = {0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6};
map<int,int> m;
int B[MAXN];
int dp[MAXN];
int trace[MAXN];

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        int a;
        scanf("%d", &a);
        m[D[a]] = max(a, m[D[a]]);
        //printf("%d %d\n", a, D[a]);
    }

    //printf("\n");
    vector<pii> pp;
    for (auto it: m) {
        //printf("%d %d\n", it.fi, it.se);
        pp.pb({it.se,it.fi});
    }

    sort(pp.begin(), pp.end());
    //reverse(pp.begin(), pp.end());

    B[0] = 1;
    for (auto it: pp) {
        int d = it.se;
        for (int i = 0; i + d <= N; i++) {
            if (B[i] && dp[i+d] <= dp[i] + 1) {
                dp[i+d] = dp[i] + 1;
                trace[i+d] = d;
                B[i+d] = 1;
            }
        }
    
        //printf("%d %d\n", it.fi, it.se);
    //for (int i = 1; i <= N; i++) printf("%02d ", i); printf("\n");
    //for (int i = 1; i <= N; i++) printf("%02d ", dp[i]); printf("\n");
    //for (int i = 1; i <= N; i++) printf("%02d ", trace[i]); printf("\n");
    }
    //return 0;
    vector<int> v;
    int k = N;
    while(k) {
        //printf("%d %d %d\n", k, trace[k], m[trace[k]]);
        v.pb(m[trace[k]]);
        k -= trace[k];
        //printf("k = %d\n", k);
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    for (auto a: v) printf("%d", a);
    printf("\n");
	return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FPure {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    vector<vector<int>> G;

    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;

        G = vector<vector<int>>(N);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
        }

        int ans = INF;
        vector<int> res;
        // 最小最短閉路
        REP(i, N) {
            queue<int> q;
            q.push(i);
            vector<int> d(N, -1), prev(N, -1);
            d[i] = 0;
            bool ok = false;
            while (!ok && !q.empty()) {
                int v = q.front();
                q.pop();
                for (auto to : G[v]) {
                    if (to == i) {
                        int n = d[v] + 1;
                        if (n < ans) {
                            ans = n;
                            res.clear();
                            while (v != i) {
                                res.push_back(v);
                                v = prev[v];
                            }
                            res.push_back(i);
                        }
                        ok = true;
                        break;
                    } else if (d[to] == -1) {
                        q.push(to);
                        d[to] = d[v] + 1;
                        prev[to] = v;
                    }
                }
            }
        }
        if (ans == INF) {
            cout << -1 << endl;
            return;
        }
        cout << res.size() << endl;
        REP(i, res.size()) cout << res[i] + 1 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FPure solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.chomp;
		if (x.length == 0) continue;
		auto f = new string[](10);
		f[0] = f[9] = "0000000000";
		f[1] = "0" ~ line.to!string ~ "0";
		foreach (i; 2..9) {
			f[i] = "0" ~ readln.chomp ~ "0";
		}
		bool ff;
		foreach (i; 1..9) {
			foreach (j; 1..9) {
				if (f[i][j] == '0') continue;
				if (f[i+1][j-1] == '1' && f[i][j+1] == '1') writeln("G");
				else if (f[i+1][j-1] == '1') writeln("D");
				else if (f[i][j+1] == '1' && f[i+1][j] == '1') writeln("A");
				else if (f[i][j+1] == '1' && f[i+1][j+1] == '1') writeln("E");
				else if (f[i+1][j] == '1' && f[i+1][j+1] == '1') writeln("F");
				else if (f[i+1][j] == '1') writeln("B");
				else if (f[i][j+1] == '1') writeln("C");
				ff = 1;
				break;
			}
			if (ff) break;
		}
	}
}

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

using namespace std;

int main(){
  int number, a=0, b=0, ab=0, o=0;
  char c;
  string blood;

  while(cin >> number >> c >> blood){
    if(blood == "A")
      a++;
    else if(blood == "B")
      b++;
    else if(blood == "AB")
      ab++;
    else if(blood == "O")
      o++;
  }

  cout << a << endl;
  cout << b << endl;
  cout << ab << endl;
  cout << o << endl;

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();
		int c = scan.nextInt();
		int table[][] = new int[r+1][c+1];
		
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				table[i][j] = scan.nextInt();
			}
		}
		
		for (int i = 0; i < r; i++) {
			int sum = 0;
			for (int j = 0; j < c; j++) {
				sum += table[i][j];
			}
			table[i][c] = sum;
		}

		for (int i = 0; i < c + 1; i++) {
			int sum = 0;
			for (int j = 0; j < r; j++) {
				sum += table[j][i];
			}
			table[r][i] = sum;
		}
		
		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c + 1; j++) {
				System.out.print(table[i][j]);
				if (j != c) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		
		scan.close();
	}

}

Measured memory_bytes: 39452
N, M = map(int, input().split())
question_list = []
score_list = []

for i in range(M):
  q,s = input().split()
  question_list.append(int(q))
  score_list.append(s)

maru_flag = [0] * N
pena_flag = [0] * N
for i in range(M):
  if score_list[i] == "AC":
    maru_flag[question_list[i] - 1] = 1

  if maru_flag[question_list[i] - 1] != 1 and score_list[i] == "WA":
    pena_flag[question_list[i] - 1] += 1

for i in range(N):
  if maru_flag[i] != 1 and pena_flag[i] > 0:
    pena_flag[i] = 0

print(str(sum(maru_flag)) + " " + str(sum(pena_flag)))

Measured memory_bytes: 15320
S = list(input())
T = list(input())
cmin = 1000

for i in range(len(S)-len(T)+1):
    c = 0
    s = S[i:i+len(T)]
    for j in range(len(T)):
        if s[j] != T[j]:
            c += 1
    cmin = min(c,cmin)

print(cmin)

Measured memory_bytes: 9044
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main() {
    int K,S,cnt=0;
    cin >> K >> S;
    for(int i=0;i<K+1;i++){
        for(int j=0;j<K+1;j++){
            int k=S-i-j;
            if(0<=k && k<=K) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge{ll to, cost;};
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 1000000000000

using Graph = vector<vector<edge>>;

int main(){
    ll k;
    string s;
    cin >> k;
    cin >> s;
    ll huga = s.length();
    if(k >= huga){
        cout << s << endl;
    }
    else{
        for(int i = 0; i < k; i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3628
from queue import PriorityQueue


def main():
    N, M = map(int, input().split(' '))
    jobs = [[] for _ in range(M + 1)]
    for i in [input() for i in range(N)]:
        A, B = map(int, i.split(' '))
        if A > M:
            continue
        jobs[A].append(B)

    pq = PriorityQueue()
    reward = 0

    for sameJobs in jobs:
        for job in sameJobs:
            pq.put(-job)
        if not pq.empty():
            reward += -(pq.get())

    print(reward)

if __name__ == "__main__":
    main()

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

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}

/*
18
insert 8
insert 2
insert 3
insert 7
insert 22
insert 1
find 1
find 2
find 3
find 4
find 5
find 6
find 7
find 8
print
delete 3
delete 7
print
*/


Measured memory_bytes: 20524
loop do
    a, op, b = gets.split.map(&:to_s)
    break if op=="?"
    puts a.to_i+b.to_i if op=="+"
    puts a.to_i-b.to_i if op=="-"
    puts a.to_i*b.to_i if op=="*"
    puts a.to_i/b.to_i if op=="/"
end


Measured memory_bytes: 6872
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc164_e
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000

using edge = tuple<int, ll, ll>;

const int nax = 60;
const ll infll = LLONG_MAX/3;
vector<vector<edge>> g(nax);
vector<ll> c(nax);
vector<ll> d(nax);
int n, m;
ll s;

int main() {
    scanf("%d %d %lld", &n, &m, &s);
    for(int i=0; i<m; i++) {
        int u, v;
        ll a, b;
        scanf("%d %d %lld %lld", &u, &v, &a, &b);
        g[u].push_back({v, a, b});
        g[v].push_back({u, a, b});
    }
    for(int i=1; i<=n; i++) {
        scanf("%lld %lld", &c[i], &d[i]);
    }
    int mxn = 2500;
    vector<vector<ll>> dp(nax, vector<ll>(mxn, infll));
    s = min(mxn-1ll, s);
    dp[1][s] = 0;
    for(int i=0; i<=n; i++) {
        for(int v=1; v<=n; v++) {
            for(int p=0; p<mxn; p++) {
                if(p+c[v] < mxn) {
                    dp[v][p+c[v]] = min(dp[v][p+c[v]], dp[v][p] + d[v]);
                }
            }
            for(int p=0; p<mxn; p++) {
                if(dp[v][p] == infll) continue;
                for(auto [u, a, b]: g[v]) {
                    if(p - a >= 0) {
                        dp[u][p-a] = min(dp[u][p-a], dp[v][p] + b);
                    }
                }
            }
        }
    }
    for(int i=2; i<=n; i++) {
        ll rs = infll;
        for(int j=0; j<mxn; j++) {
            rs = min(rs, dp[i][j]);
        }
        printf("%lld\n", rs);
    }
}


Measured memory_bytes: 4592
def is_much_money(num_of_coin, yen):
  if num_of_coin * 500 >= yen:
    return "Yes"
  else:
    return "No"
 
if __name__ == "__main__":
    num_of_coin, yen = input().split()
    judgement = is_much_money(int(num_of_coin), int(yen))
    print(judgement)

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());

  if(N == 2){
    cout << a[1] << " " << a[0] << endl;
    return 0;
  }


  ll max_val = 0;
  ll now = a[N-1];

  // now/2に近い数字 を探す
  ll r = lower_bound(a.begin(), a.end(), now / 2) - a.begin();

  if(r >= 1){
    ll diff1 = abs(a[r] - now / 2 );
    ll diff2 = abs(a[r-1] - now / 2);

    if(diff1 <= diff2){
      cout << now << " " << a[r] << endl;
    } else { 
      cout << now << " " << a[r-1] << endl;
    }
  } else { 
    cout << now << " " << a[r] << endl;
  }
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int dy[] = {1, -1, 0, 0};
int dx[] = {0, 0, 1, -1};

int main()
{
    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h+2, string(w+2, '#'));
        vector<queue<pair<int, int> > > q(2);
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                cin >> s[i][j];
                if(s[i][j] == 'B')
                    q[0].push(make_pair(i, j));
                else if(s[i][j] == 'W')
                    q[1].push(make_pair(i, j));
            }
        }

        vector<vector<vector<bool> > > check(2, vector<vector<bool> >(h+2, vector<bool>(w+2, false)));
        for(int i=0; i<2; ++i){
            while(!q[i].empty()){
                int y = q[i].front().first;
                int x = q[i].front().second;
                q[i].pop();

                for(int j=0; j<4; ++j){
                    int y2 = y + dy[j];
                    int x2 = x + dx[j];
                    if(s[y2][x2] == '.' && !check[i][y2][x2]){
                        check[i][y2][x2] = true;
                        q[i].push(make_pair(y2, x2));
                    }
                }
            }
        }

        int retB = 0;
        int retW = 0;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                if(check[0][i][j] && !check[1][i][j])
                    ++ retB;
                else if(!check[0][i][j] && check[1][i][j])
                    ++ retW;
            }
        }
        cout << retB << ' ' << retW << endl;
    }
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, K;
double x[60], y[60], c[60];

// 円 i, j の交点を求める
pair<double, double> calc_point(int i, int j, double t, int p){
    // https://shogo82148.github.io/homepage/memo/geometry/circle-cross.html
    double x_1 = x[j]-x[i];
    double y_1 = y[j]-y[i];
    double r_1 = t / c[i];
    double r_2 = t / c[j];
    double a = x_1*x_1 + y_1*y_1 + r_1*r_1 - r_2*r_2;
    a /= 2.0;
    if(p == 1){
        double X = a*x_1 + y_1*sqrt((x_1*x_1+y_1*y_1)*r_1*r_1 - a*a);
        X /= x_1*x_1 + y_1*y_1;
        X += x[i];
        double Y = a*y_1 - x_1*sqrt((x_1*x_1+y_1*y_1)*r_1*r_1 - a*a);
        Y /= x_1*x_1 + y_1*y_1;
        Y += y[i];
        return mp(X, Y);
    }
    else{
        double X = a*x_1 - y_1*sqrt((x_1*x_1+y_1*y_1)*r_1*r_1 - a*a);
        X /= x_1*x_1 + y_1*y_1;
        X += x[i];
        double Y = a*y_1 + x_1*sqrt((x_1*x_1+y_1*y_1)*r_1*r_1 - a*a);
        Y /= x_1*x_1 + y_1*y_1;
        Y += y[i];
        return mp(X, Y);
    }
}

double dist(double x_1, double y_1, double x_2, double y_2){
    return sqrt((x_1-x_2)*(x_1-x_2)+(y_1-y_2)*(y_1-y_2));
}

// t 秒以内に K 枚の肉を焼くことができる熱源の位置は存在するか
bool isOK(double t){
    // 各肉 i について，その位置から半径 t/c_i 以内の位置に熱源を置けば t 秒以内に焼ける
    // よって「中心 (x_i, y_i) 半径 t/c_i の円が K 個以上重なる点があるか」が必要十分条件
    // 2 円の交点だけ調べれば十分
    rep(i, N){
        rep(j, N){
            if(i >= j) continue;
            rep(k, 2){
                pair<double, double> p = calc_point(i, j, t, k);
                int cnt = 0;
                rep(l, N){
                    if(dist(p.first, p.second, x[l], y[l]) <= t/c[l] + 1e-8) cnt++;
                }
                if(cnt >= K) return true;
            }
            rep(k, 2){
                pair<double, double> p = mp(x[(k==0 ? i : j)], y[(k==0 ? i : j)]);
                int cnt = 0;
                rep(l, N){
                    if(dist(p.first, p.second, x[l], y[l]) <= t/c[l] + 1e-8) cnt++;
                }
                if(cnt >= K) return true;
            }
        }
    }
    return false;
}

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> x[i] >> y[i] >> c[i];

    if(K == 1){
        cout << 0 << endl;
        return 0;
    }
    
    double ok = 300000;
    double ng = -1;
    while(ok - ng > 1e-8){
        double m = (ok+ng)/2;
        if(isOK(m)) ok = m;
        else ng = m;
    }
    cout << fixed << setprecision(16) << ok << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M;

int main()
{
  std::cin >> N >> M;

  if( N&1 )
  {
    for( ll l = 1, r = N-1, cnt = 0; l < r && cnt < M; ++l, --r, ++cnt )
      std::cout << l+1 << ' ' << r+1 << std::endl;
  }
  else
  {
    bool fl = false;

    for( ll l = 1, r = N-1, cnt = 0; l < r && cnt < M; ++l, --r, ++cnt )
    {
      if( !fl && r-l <= N/2 )
        fl = true, ++l;

      std::cout << l+1 << ' ' << r+1 << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	char a, b;
	cin >> a >> b;

	char ans = 'N';
	if (a == 'H') {
		ans = b;
	}
	else {
		if (b == 'H') ans = 'D';
		else ans = 'H';
	}

	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;

int dp[50][2];

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

  int n,k;
  cin>>n>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  int mx = 50;
  rep(i,mx) {
    int mask = 1LL << (mx - i - 1);
    int cnt0 = 0;int cnt1 = 0;
    rep(j,n) {
      if(a[j] & mask) cnt1++;
      else cnt0++;
    }
    if(dp[i][1] != -1) {
      dp[i+1][1] = dp[i][1] + mask * max(cnt0, cnt1);
    }
    if(dp[i][0] != -1) {

    }
    if(mask & k) {
      dp[i+1][1] = max(dp[i+1][1], dp[i][0] + mask * cnt1);
      dp[i+1][0] = dp[i][0] + mask * cnt0;
    } else {
      dp[i+1][0] = dp[i][0] + mask * cnt1;
    }
  }
  cout << max(dp[mx][0],dp[mx][1]) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	map<char,int> mp;
	mp['0']=0;
	mp['1']=1;
	mp['2']=2;
	mp['3']=3;
	mp['4']=4;
	mp['5']=5;
	mp['6']=6;
	mp['7']=7;
	mp['8']=8;
	mp['9']=9;
	ll sum=0;
	for(ll i=0;i<s.length();i++)
	{
		sum+=mp[s[i]];
	}
	if(sum%9==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int N;
string S;

long long solve() {
    N = (int)S.size();
    vector<vector<bool>> dp(4, vector<bool>(1010, 0));
    dp[0][0] = true;
    for (int i = 0; i < N; ++i) {
        for (int j = 2; j >= 0; --j) {
            for (int k = 0; k < 1000; ++k) {
                if (!dp[j][k]) continue;
                int nk = k * 10 + (int)(S[i] - '0');
                if (nk >= 1000) continue;
                dp[j+1][nk] = true;
            }
        }
    }
    long long res = 0;
    for (int k = 0; k < 1000; ++k) if (dp[3][k]) ++res;
    return res;
}

int main() {
    while (cin >> N >> S) {
        cout << solve() << endl;
    }
}





Measured memory_bytes: 256
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 5e3 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int ans;
string s;
char l;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;

    l = '#';

    for (int i = 0; i < s.size(); ++i) {
        if(s[i]==l) {
            if(i!=s.size()-1) {
                ++i;
                ++ans;
                l = '#';
            }
        } else {
            ++ans;
            l = s[i];
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 720
N, totalWt = list(map(int, input().split()))
itemsVal = [0]
itemsWt = [0]
for i in range(0, N):
    val, weight = list(map(int, input().split()))
    itemsVal.append(val)
    itemsWt.append(weight)

mylist = [[0 for _ in range(totalWt+1)] for _ in range(N + 1)]


for i in range(1, N + 1):
    for j in range(1, totalWt+1):
        if j >= itemsWt[i]:
            mylist[i][j] = max(mylist[i-1][j], mylist[i-1][j-itemsWt[i]] + itemsVal[i])
        else:
            mylist[i][j] = mylist[i-1][j]

print(mylist[len(itemsWt)-1][totalWt])


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

int main()
{
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int sum =0;

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

    cout << sum;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip> : 表示桁数

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned char Byte;
using namespace std;

//string ans = "Yes";
double ans;
int A, B, H, M;
int main() {
	cin >> A >> B >> H >> M;

	double thetaH = 2.0 * pi * (H + M / 60.0) / 12.0;
	double thetaM = 2.0 * pi * M / 60.0;

	double hX = A * cos(thetaH);
	double hY = A * sin(thetaH);
	double mX = B * cos(thetaM);
	double mY = B * sin(thetaM);

	ans = sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));



	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}


Measured memory_bytes: 4100
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b;
int main(){
  scan(a);scan(b);
  if((a+b)%2==0)prin((a+b)/2);
  else prin((a+b)/2+1);
  
  return 0;
}


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

using namespace std;

int main() {
  string S;
  cin>>S;
  
  bool flag=true;
  for(int i=1;i<4;i++) {
    if(S[i]==S[i-1]) {
      flag=false;
      break;
    }
  }
  if(flag==true) cout<<"Good";
  else cout<<"Bad";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    string S,T,U;
    int A,B;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    if(!S.compare(U)) cout<<A-1<<" "<<B<<endl;
    else cout<<A<<" "<<B-1<<endl;
    return 0;
}

Measured memory_bytes: 256
N = input()
digit = len(N)

# dp[i番目まで][N未満かどうか][0以外を含んだかどうか][7][5][3]
dp = [[[[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(digit+2)]
dp[0][0][0][0][0][0] = 1

for i in range(digit):
  num = int(N[i])
  for j in range(2):
    for nonzero in range(2):
      for seven in range(2):
        for five in range(2):
          for three in range(2):
            for n in [0,3,5,7]:
              if (nonzero and (n == 0)) or ((j == 0) and (n > num)):
                continue
              else:
                dp[i+1][j or (n < num)][nonzero or (n != 0)]\
                [seven or (n == 7)][five or (n == 5)][three or (n == 3)]\
                += dp[i][j][nonzero][seven][five][three]

print(dp[digit][0][1][1][1][1] + dp[digit][1][1][1][1][1])

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

maxtall = A[0]
ans = 0
for i in range(1, N):
    if A[i] < maxtall:
        ans += maxtall - A[i]

    elif A[i] > maxtall:
        maxtall = A[i]

print(ans)

Measured memory_bytes: 32376
a, b = map(int, input().split())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0: # i で割り切れればiは素因数
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


s = set(prime_decomposition(a))
t = set(prime_decomposition(b))
print(len(s&t) + 1)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

void addEdge(int a, int b, vector<vector<int>>& g, vector<int>& in){
	g[a].emplace_back(b);
	g[b].emplace_back(a);
	in[a]--; in[b]--;
	assert(in[a] >= 0 and in[b] >= 0 and "invalid edge");
}

void dfs(int& idx, int& num, vector<int>& d, vector<int>& in, vector<int>& par, vector<vector<int>>& g){
	int pos = num++;
	//cout << pos << endl;
	while(in[pos] > 0 and idx < d.size()){
		if(d[idx] >= 0){
			idx++; 
			addEdge(pos, num, g, in);
			par[num] = pos;
			dfs(idx, num, d, in, par, g);
		}else{
			int p = pos;
			rep(i,-d[idx]){
				p = par[p];
			}
			idx++;
			assert(p >= 0 and "invalid par");
			addEdge(p, pos, g, in);
		}
	}
}

int main(){
	int n;
	cin >> n;
	rep(_,n){
		int a;
		vector<int> d, in;
		while(cin >> a, a){
			if(a >= 0){
				in.emplace_back(a);
			}
			d.emplace_back(a);
		}

		vector<int> par(in.size(), - 1);
		vector<vector<int>> g(in.size());
		int idx = 1, num = 0; 
		dfs(idx, num, d, in, par, g);

		rep(i,in.size()){
			sort(all(g[i]));
		}

		rep(i,in.size()){
			cout << i + 1;
			rep(j,g[i].size()){
				cout << ' ' << g[i][j] + 1;
			}
			cout << endl;
		}
	}
}



Measured memory_bytes: 3116
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    string s;
    cin >> s;
    int N = s.size();
    int cnt[26] = {};
    rep(i,0,s.size()){
        cnt[s[i]-'a']++;
    }
    ll ans = 1LL * N * (N-1) / 2;
    rep(i,0,26){
        ans -= 1LL * cnt[i] * (cnt[i] - 1) / 2;
    }
    ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640