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

#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
priority_queue<pll,vector<pll>,greater<pll> >pq;

vector<int>arr(100001),dp(100001,0);
int n;
int solve(int i){
    if(i>=n)
        return 0;
    if(dp[i]!=0)
        return dp[i];
    if(i+1<n)
        dp[i]=(abs(arr[i+1]-arr[i])+solve(i+1));
    if(i+2<n)
        dp[i]=min(dp[i],abs(arr[i+2]-arr[i])+solve(i+2));
    return dp[i];
}

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



Measured memory_bytes: 1024
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second


int main(int argc, const char * argv[]) {
  
  int N;
  
  cin >> N;
  
  cout << "ABC" << N << endl;
  
  return 0;
}


Measured memory_bytes: 3612
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
num, ans, val = 0, 0, 0
vals = []

for i in range(n):
    c = b[i]-a[i]
    if c > 0:
        num += c
        ans += 1
    elif c < 0:
        vals.append(-c)
vals.sort()

if sum(a) < sum(b):
    print(-1)
else:
    for i in vals[::-1]:
        if val >= num:
            break
        ans += 1
        val += i
    print(ans)


Measured memory_bytes: 24184
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll factorial(ll n) {
  if(n == 1) return 1;
  return (n * factorial(n - 1)) % MOD;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  const char *sptr = s.c_str();
  int invrl[n * 2];
  for(int i = 0; i < 2 * n; i++) {
    int invnum = i;
    if(sptr[i] == 'W') invnum++;
    invrl[i] = invnum % 2;
  }
  //for(int i = 0; i < 2 * n; i++) {
  //  cout << invrl[i] << " ";
  //}
  //cout << "\n";
  ll lsum = 0;
  ll ans = 1;
  for(int lptr = 0; lptr < 2 * n; lptr++) {
    if(invrl[lptr] == 0) lsum++;
    else {
      if (lsum <= 0) {
        lsum = -1;
        break;
      }
      ans = (ans * lsum) % MOD;
      lsum--;
    }
  }

  if(lsum != 0) {
    cout  << 0 << "\n";
    return 0;
  }
  ans = (ans * factorial(n)) % MOD;
  cout << ans << "\n";

  return 0;
}



Measured memory_bytes: 2964
// https://kmjp.hatenablog.jp/entry/2020/08/15/1100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// グローバル変数で宣言することで0で初期化
// 宝の場所と価値
int T[3030][3030];
// 同一行内での取得済みお宝数(0,1,2,3個)を状態に持たせる
int dp[3030][3030][4];

void solve() {
    int H, W, K;

    cin >> H >> W >> K;
    REP(i, K) {
        int y, x, r;
        cin >> y >> x >> r;
        T[y - 1][x - 1] = r;
    }

    REP(y, H) REP(x, W) {
        // 宝があれば拾ってスコアを加算する
        if (T[y][x] > 0) {
            // 取得済みの宝が2個以下なら拾う
            for (int i = 2; i >= 0; i--)
                dp[y][x][i + 1] = max(dp[y][x][i + 1], dp[y][x][i] + T[y][x]);
        }

        // 取得済みの宝の数に対してx,y方向へ移動処理
        REP(i, 4) {
            // y方向へ移動する場合は、前の行で拾った宝の数を0にリセット
            dp[y + 1][x][0] = max(dp[y + 1][x][0], dp[y][x][i]);
            // x方向へ移動する場合は、宝の数が同じ物に対してスコアを更新
            dp[y][x + 1][i] = max(dp[y][x + 1][i], dp[y][x][i]);
        }
    }

    // ゴール地点のスコアが最大値
    cout << dp[H][W - 1][0] << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 358716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
template <class T> void chmin(T& a, const T& b) { if (b < a) a = b; }
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll N, X;
    cin >> N >> X;

    vector<ll> xi(N);
    REP(i, N) cin >> xi[i];

    vector<ll> di(N);
    REP(i, N) {
        di[i] = abs(X - xi[i]);
    }

    if (di.size() == 1) {
        cout << di[0] << LF;
        return 0;
    }

    ll ans = di[0];
    REP(i, N) {
        ans = __gcd(ans, di[i]);
        if (ans == 1) break;
    }

    cout << ans << LF;

    return 0;
}

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

using namespace std;

struct zahyou {
	int x;
	int y;
};

void makemap(vector<zahyou>& block, int i, int from,int way) {
	block[i].x = block[from].x;
	block[i].y = block[from].y;
	if(way == 0) {
		block[i].x--;
	}
	if(way == 1) {
		block[i].y--;
	}
	if(way == 2) {
		block[i].x++;
	}
	if(way == 3) {
		block[i].y++;
	}
}

int main(void) {
	int N;
	while(1) {
		cin >> N;
		if(N == 0) {
			break;
		}

		vector<zahyou> block(N);
		block[0].x = 0;
		block[0].y = 0;
		int from, way;
		for(int i = 0; i < N - 1; i++) {
			cin >> from >> way;
			makemap(block, i + 1, from, way);
		}

		int max_x = 0, min_x = 0, max_y = 0, min_y = 0;
		for(auto b : block) {
			if(b.x > max_x) {
				max_x = b.x;
			}
			if(b.x < min_x) {
				min_x = b.x;
			}
			if(b.y > max_y) {
				max_y = b.y;
			}
			if(b.y < min_y) {
				min_y = b.y;
			}
		}

		int H, W;
		H = max_y - min_y + 1;
		W = max_x - min_x + 1;
		cout << W << " " << H << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;

int N;
ll X, D;
vector<ll> x;
stack<ll> xDiff;

ll calc(ll num1, ll num2) {
    if (num1 % num2 == 0) {
        return num2;
    } else {
        calc(num2, num1 % num2);
    }
}

int main() {
        
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        ll xi;
        cin >> xi;
        x.push_back(xi);
    }
    x.push_back(X);
    sort(x.begin(), x.end());

    for (int i = 0; i < N; i++) {
        ll diff = x[i+1] - x[i];
        xDiff.push(diff);
    }

    while(true) {
        if (xDiff.size() == 1) {
            break;
        }
        ll num1, num2;
        num1 = xDiff.top();
        xDiff.pop();
        num2 = xDiff.top();
        xDiff.pop();
        ll num3 = calc(num1, num2);
        xDiff.push(num3);
    }
    ll result = xDiff.top();
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

pair<int, int> num2pair(int x) {
  int a, b;
  a = x % 10;
  b = x;
  while (b >= 10) {
    b /= 10;
  }
  return make_pair(b, a);
}

int main() {
  int n;
  int ans = 0;
  read n;
  map<pair<int, int>, int> freq;
  FOR(i, 1, n + 1) {
    pair<int, int> tp;
    tp = num2pair(i);
    freq[tp]++;
  }
  FOR(i, 1, n + 1) {
    pair<int, int> tp;
    tp = num2pair(i);
    ans += freq[make_pair(tp.second, tp.first)];
  }
  echo ans fin;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 200005
#define INF 1000000000
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
int main()
{
//    ll test=1;
////    in(test);
//    while(test--)
//    {
       ll i,j,k,l,n,m,r,x;
       in(x);
       if(x>=30LL)puts("Yes");
       else puts("No");
//    }
}


Measured memory_bytes: 3688
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int A = s[0];
            int B = s[1];
            int C = s[2];


            WriteLine(
                A<=C && C <= B || B <= C && C <= A ? "Yes":"No"
                 );
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int k;
    cin >> n >> k;
    vec(a,n);
    REP(i,n){
        int t;
        cin >> t;
        a[t-1]++;
    }
    Sort(a);
    Reverse(a);
    //Debug(a);
    int cnt = 0;
    REP(i,k){
        cnt += a[i];
    }
    print(n-cnt);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 1792
n = int(input())
d, x = map(int, input().split())

a = []

ans = 0

for i in range(n):
    a.append(int(input()))

for i in range(n):
    c = 0
    while True:
        if c * a[i] + 1 > d:
            break
    
        ans += 1
        c += 1

ans += x

print(ans)


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());

    unsigned long ans = 0;
    for (int i = 0; i < (N - K); i++) {
        ans += H[i];
    }

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


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

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

	int leng = S.size();
	int cnt = 0;
	for (int i = 0; i + 2 < leng; i++) {
      string T = S.substr(i,3);
      if(T == "ABC") cnt++;
	}
	cout << cnt << endl;
}

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

int main()
{
    string S;
    cin>>S;
    int N = S.length();

    for(int i = 0;i<N/2;i++)
    {
        if(S[i]!=S[N-1-i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    int check1 = (N - 1) / 2;
    for(int i = 0;i<check1/2;i++)
    {
        if(S[i]!=S[check1-1-i])
        {
            cout<<"No"<<endl;
            return 0; 
        }
    }

    int check2 = (N + 3) / 2;
    for(int i = check2 - 1;i<check2 + ((N - check2)/2) - 1;i++)
    {
        if(S[i]!=S[(N - 1) - (i - (check2 - 1))])
        {
            cout<<"No"<<endl;
            return 0; 
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Scanner;

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

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            BigDecimal a = new BigDecimal("" + in.nextDouble());
            BigDecimal b = new BigDecimal("" + in.nextDouble());
            out.println(a.multiply(b).toBigInteger());
        }

    }
}



Measured memory_bytes: 29116
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long,long long>& a,
         pair<long long,long long>& b)
{
    return a.second < b.second;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    long long sum=0;
    vector<long long>v;
    while(n--)
    {
        int num;
        cin>>num;
        v.push_back(num);
    }
    sort(v.begin(),v.end());
    for(int i=1;i<v.size();i++)
    {
        sum += v[v.size()-1-i/2];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 5312
#include<cstdio>
#include<vector>
using namespace std;

vector<int>g[100001];
bool vis[100001],vis2[100001],w[100001];
struct ed{int u,v;};
ed ans[100001];
int anst;
void dfs(int u){
	vis[u]=1;
	for(int i=0;i<g[u].size();i++)
		if(!vis[g[u][i]])
			dfs(g[u][i]);
	for(int i=0;i<g[u].size();i++)
		if(!vis2[g[u][i]]){
			w[g[u][i]]^=1;
			ans[++anst]=(ed){g[u][i],u};
		}
	if(w[u]){
		swap(ans[anst].u,ans[anst].v);
		w[ans[anst].u]^=1;
		w[ans[anst].v]^=1;
	}
	vis2[u]=1;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(m&1){
		printf("-1\n");
		return 0;
	}
	dfs(1);
	for(int i=1;i<=anst;i++)
		printf("%d %d\n",ans[i].u,ans[i].v);
}

Measured memory_bytes: 14440
#include<stdio.h>
int main(void)
{
  int i,j,wide,height;
  int h[10000],w[10000];
  i = 1;
  while(1){
    scanf("%d %d",&h[i],&w[i]);
    if(h[i] == 0 && w[i] == 0){
      break;
    }
    i++;
  }
  for(j = 1;j < i;j++){
    for(wide = 0;wide < w[j];wide++){
      printf("#");
    }
    printf("\n");
    for(height = 3;height <= h[j];height++){
      printf("#");
      for(wide = 3;wide <= w[j];wide++){
        printf(".");
      }
      printf("#\n");
    }
    for(wide = 1;wide <= w[j];wide++){
      printf("#");
    }
    printf("\n");
       printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 596
n, m = map(int, input().split())
request = [list(map(int, input().split())) for _ in range(m)]

request = sorted(request, key=lambda x:x[1])
broken = -1
ans = 0
for a, b in request:
    if a > broken:
        broken = b - 1
        ans += 1
print(ans)


Measured memory_bytes: 29852
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
const long double EPS = 1e-14;
const int maxn = 100500;
const int mod = 1e9 + 7;


signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    int n;
    cin >> n >> s;
    vector < int > acc(n + 1);
    acc[n] = 0;
    for(int i = n - 1 ; i >= 0 ; --i)
        acc[i] = acc[i + 1] + (s[i] == 'E');
    int ans = 1e9;
    int w = 0;
    for(int i = 0 ; i < n ; ++i){
        ans = min(ans, w + acc[i + 1]);
        w += s[i] == 'W';
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <string>

using namespace std;
static const vector<int> aaa = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	int tmp = 0;

	tmp = x;
	x = y;
	y = tmp;

	tmp = x;
	x = z;
	z = tmp;

	printf("%d %d %d\n", x, y, z);

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 1e9 + 7;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll fact[200005];
ll invFact[200005];

ll C(ll n, ll r){
	if(r > n) return 0;
	ll ret = fact[n];
	ret = ((ret * invFact[n - r]) + MOD) % MOD;
	ret = ((ret * invFact[r]) + MOD) % MOD;
	return ret;
}

ll mypow(ll a, ll p){
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1) % MOD)) % MOD;
	ll x = mypow(a, p / 2) % MOD;
	return (x * x) % MOD;
}

ll inv(ll base){
	return mypow(base, MOD - 2);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	fact[0] = 1;
	invFact[0] = 1;
	for(ll i = 1; i < 200005; i++){
		fact[i] = (1LL * fact[i - 1] * i) % MOD;
		invFact[i] = inv(fact[i]);
	}
	ll ans = 0LL;
	repn(i, b + 1, w + 1){
		ll cur = 0LL;
		ll one = C(i - 1 + (h - a - 1), i - 1);
		ll two = C(a - 1 + (w - i), w - i);
		(cur += (one * two) % MOD) %= MOD;
		(ans += cur) %= MOD;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 6764
import collections

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

cs = collections.Counter(s)
ct = collections.Counter(t)

ans = 0

for i, j in cs.items():
    ans = max(j-ct[i], ans)

print(ans)

Measured memory_bytes: 9404
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    n = I()
    ans = 0

    for i in range(1,n):
        ans += (n-1)//i

    print(ans)

main()


Measured memory_bytes: 68436
import java.util.*;
public class Main{
  public static void main (String[] args)throws java.lang.Exception{
    Scanner scanner = new Scanner(System.in);
    while(true){
      int a = scanner.nextInt();
      String d = scanner.next();
      int b = scanner.nextInt();
      if(d.equals("?")){
        break;
      }
      if(d.equals("+")){
        System.out.println(a+b);
      }
      if(d.equals("-")){
        System.out.println(a-b);
      }
      if(d.equals("*")){
        System.out.println(a*b);
      }
      if(d.equals  ("/")){
        System.out.println(a/b);
      }
    }
  }
}

Measured memory_bytes: 26336
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n;
    cin>>n;
    vii dp(n,vi(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>dp[i][j];
        }
    }
    for(int i=1;i<n;i++)
    {
        dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
    }
    int maxfun=-1;
    for(int i=0;i<3;i++)maxfun=max(maxfun,dp[n-1][i]);
    cout<<maxfun;
    return 0;
}

Measured memory_bytes: 8744
# -*- coding: utf-8 -*-
from math import sqrt
from bisect import bisect

def inpl(): return tuple(map(int, input().split()))

def isprime(N, P):
    if N <= 1:
        return False
    for p in P[:bisect(P, sqrt(N))]:
        if N%p==0:
            return False
            break
    else:
        return True

def primes(N):
    P = [2]
    searched = [False]*(N+1)
    for i in range(3, N+1, 2):
        if searched[i]:
            continue
        P.append(i)
        searched[i:N+1:i] = [True]*(N//i)
    return P

P = primes(int(sqrt(10**8)))

res = 0
for i in range(int(input())):
    res += isprime(int(input()), P)
print(res)


Measured memory_bytes: 5824
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n,z,w;
    cin >> n >> z >> w;

    //zは不必要な情報のはず

    //便宜上、ここにwを置いても問題ないはず
    vector<int> a(1,w);

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    vector<vector<int>> v(n + 1, vector<int>(n + 1, -1));

    //x=nのばあい

    for(int i = n - 1; i >= 0; i--){
        v[n][i] = abs(a[i] - a[n]);
    }

    //y=nのばあい
    for(int i = n - 1; i >= 1; i--){
        v[i][n] = abs(a[i] - a[n]);
    }

    for(int k = n - 1; k >= 1; k--){


        int tmpscore = INT_MAX;

        for(int j = n; j > k; j--){
            tmpscore = min(tmpscore, v[k][j]);
        }

        for(int j = k - 1; j >= 0; j--){
            v[k][j] = tmpscore;
        }

        tmpscore = 0;

        for(int i = n; i > k; i--){
            tmpscore = max(tmpscore, v[i][k]);
        }

        for(int i = k - 1; i > 0; i--){
            v[i][k] = tmpscore;
        }
    }

    int ans = 0;

    for(int i = n; i > 0; i--){
        ans = max(ans, v[i][0]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    int n;
    cin >> n;
    int ans = (n+2-1)/2;
    dunk(ans);
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            x =  500 * a + 100 * b + 50 * c
            if x == X:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	long long X, Y, Z, W;
	cin >> X >> Y;

	int ans = 1, i, j;

	Z = X;
	W = X;
	j = 1;

	while(true)
	{
		i = 1;
		while(i <= j)
		{
			i++;

			if ((Z * i) % W == 0)
			{
				break;
			}
		}
		
		Z *= i;
		
		if (Z > Y)
		{
			break;
		}

		ans++;
	}

	cout << ans << endl;

	return 0;
}



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

int main(){
	vector<int> A(3);
	cin >> A[0] >> A[1] >> A[2];
	int min_A, max_A;
	min_A = min(A[0], (int)min(A[1], A[2]));
	max_A = max(A[0], (int)max(A[1], A[2]));
	cout << max_A - min_A << endl;
}



Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
solved = 0
for _ in range(N):
  evalue = C
  for A_i, B_i in zip(map(int, input().split()), B):
    evalue += A_i * B_i
  solved += 1 if evalue > 0 else 0
print(solved)

Measured memory_bytes: 9180
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}


void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}
*/

int main()
{
	ll n;
	cin >> n;

	vector<ll> v( n );
	rep( i, n ) cin >> v[i];

	Pll p( max( v[0], v[1] ), min( v[0], v[1] ) );

	if ( n > 2 )
	{
		sort( ALL( v ) );

		ll halfN = -1;;
		rep( i, n - 1 )
		{
			if ( min( v[i], v[n - 1] - v[i] ) > halfN )
			{
				halfN = v[i];
			}
		}

		p.F = v[n - 1]; p.S = halfN;
	}

	cout << p.F << " " << p.S << endl;

	return ( 0 );
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll n,x,m; cin >> n >> x >> m;
  ll nd = n;
  
  queue<ll> q; set<ll> came;
  bool flag = true;
  
  ll ans = 0; ll doubling = 0;
  
  while(flag and n != 0){
    if(came.count(x)){
      flag = false;
      doubling = x;
      ans += x;
      n--;
      break;
    }
    else if(x == 0){
      cout << ans << endl;
      return 0;
    }
    
    came.insert(x);
    q.push(x);
    
    ans += x;
    n--;
    x = ((x*x) % m);
  }
  
  bool flag2 = true; ll loopcnt = 0; ll loopsum = 0;
  bool loopin = false;
  
  while(flag2){
    if(q.front() == doubling){
      if(!loopin){
        loopin = true;
        loopcnt++;
        loopsum += q.front();
        q.push(q.front());
        q.pop();
      }
      else{
        //loopcnt++;
        //loopsum += q.front();
        flag2 = false;
        //q.push(q.front());
        q.pop();
        break;
      }
    }
    else if(!loopin){
      q.pop();
    }
    else{
      loopsum += q.front();
      loopcnt++;
      q.push(q.front());
      q.pop();
    }
  }
      
  
  if(n == 0){
    cout << ans << endl;
    return 0;
  }
  
  //cout << loopcnt << ' ' << loopsum << endl;
  
  ans += (n/loopcnt) * loopsum;
  n = n % loopcnt;
  
  while(n > 0){
    ans += q.front();
    q.push(q.front());
    q.pop();
    n--;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 6324
n = int(input())
blist = list(map(int, input().split()))

alist = [-1 for i in range(n)]

alist[0] = blist[0]
alist[1] = blist[0]

for i in range(1,n):
    if alist[i-1] <= blist[i-1]:
        alist[i] = blist[i-1]
    else:
        alist[i-1] = blist[i-1]
        alist[i] = blist[i-1]

print(sum(alist))

Measured memory_bytes: 3064
N,M,C = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0

N.times do
  a = gets.split.map(&:to_i)
  sum = C
  for i in 0..M-1 do
    sum += a[i]*b[i]
  end

  ans += 1 if sum >0
end

puts ans


Measured memory_bytes: 1788
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h = inp()
cnt = 0
tmp = h
while True:
    if tmp <= 1:
        break
    tmp //= 2
    cnt += 1
print(2**(cnt+1)-1)

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

typedef long long ll;

int main () {
    ll N;
    cin >> N;
    ll ans = 0;
    for (int i = floor(sqrt(N)); i > 0; i--) {
        if (N % i == 0) {
            ans = i + N/i - 2;
            break;
        }
    }
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    while (cin >> n, n != 0) {
        int k = n / 4;
        int sum = 0;
        for (int i = 0; i < k; i++) {
            int hit; cin >> hit;
            sum += hit;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
e=a*b;
f=c*d;
if(e>f)
{printf("%d",e);}
if(a*b<c*d)
{printf("%d",f);}
if(e==f)
{printf("%d",e);}

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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


using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    string s[200000];
    map<string,int> mp;
    int n; cin >> n;
    int Max = -1;
    rep(i,n)cin >> s[i];
    sort(s,s+n);
    rep(i,n) mp[s[i]] = 0;
    rep(i,n){
        mp[s[i]] ++;
        Max = max(Max,mp[s[i]]);
    }
    rep(i,n){
        if(mp[s[i]] == Max){
            mp[s[i]] = -1;
            cout << s[i] << endl;
        }
    }
    return 0;
}











Measured memory_bytes: 25424
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
while(true)
{
int max=0;
String ans="";
int j=0;
for(int i=0;i<5;i++)
	{
String str=input.readLine();
String str_ary[]=str.split(" ");

if(str_ary[0].equals("0") && str_ary[1].equals("0"))
{
System.exit(0);
}
	
	int m,a;
	String s[]={"A","B","C","D","E"};	
	m=Integer.parseInt(str_ary[0]);
	a=Integer.parseInt(str_ary[1]);
	if(max<m+a)
	{
	max=m+a;
	ans=s[i];
	}
	
	}
	System.out.println(ans+" "+max);
	}
}


}

Measured memory_bytes: 19632
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  const int c[10]={6,2,5,5,4,5,6,3,7,6};
  int A[M];
  REP(i,M)cin>>A[i];
  sort(A,A+M,greater<int>());
  int dp[N+1];
  REP(i,N+1)dp[i]=-1;
  dp[0]=0;
  REP(i,N+1){
    REP(j,M){
      int k=i+c[A[j]];
      if(k>N)continue;
      dp[k]=max(dp[k],dp[i]+1);
    }
  }

  while(N>0){
    REP(i,M){
      if(N-c[A[i]]<0)continue;
      if(dp[N-c[A[i]]]==dp[N]-1){
        cout<<A[i];
        N-=c[A[i]];
        break;
      }
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#%%
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for i in range(N):
    b = B[i]
    a = bisect.bisect_left(A, b)
    c = N - bisect.bisect_right(C, b)
    ans += a * c

print(ans)


Measured memory_bytes: 23360
#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int dp[3]={0};
    for(int d=0;d<n;d++){
        int arr[3];
        for(int i=0;i<3;i++) scanf("%d", &arr[i]);
        int curr[3] = {0};
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(i==j)continue;
                curr[j] = max(curr[j], dp[i] + arr[j]);
            }
        }

        for(int z = 0;z<3;z++){
            dp[z] = curr[z];
        }
    }
    printf("%d", max({dp[0], dp[1], dp[2]}));
   return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();

        int[] x = cin.ArrayInt(m);

        int count = 0;

        if (n < m)
        {
            Array.Sort(x);

            if (n == 1)
            {
                count = Math.Abs(x[0] - x[m - 1]);
            }
            else
            {
                int[] space = new int[m - 1];
                int[] index = new int[m - 1];

                for (int i = 0; i < m - 1; ++i)
                {
                    space[i] = Math.Abs(x[i + 1] - x[i]);
                    index[i] = i;
                }

                var arr = index.Zip(space, (_index, _space) => new { _index, _space }).ToArray();
                Array.Sort(arr, (a, b) => { return a._space.CompareTo(b._space); });


                int loopCount = (m - 1) - (n - 1);
                int loopIndex = 0;
                foreach (var _space in arr)
                {
                    count += _space._space;

                    if (++loopIndex == loopCount) { break; }
                }
            }
        }

        Console.WriteLine(count);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 27868
#include<bits/stdc++.h>
using namespace std;
vector <string>p;
int main()
{
    int a,b,c;
    string d,e;
    cin>>d;
    for(int i=0;i<d.size();i++)
        {
            if(d[i]==',')
                cout<<" ";
            else
                cout<<d[i];
        }
}

Measured memory_bytes: 256
#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 Would
#define you
#define please

pair<int, int> odp[100001];
pair<int, int> evp[100001];

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

	int N, V;
	cin >> N;

	rep(i, N) {
		cin >> V;
		if (i % 2) {
			odp[V].first++;
			odp[V].second = V;
		}
		else {
			evp[V].first++;
			evp[V].second = V;
		}
	}

	sort(odp, odp + 100001, greater<pair<int, int>>());
	sort(evp, evp + 100001, greater<pair<int, int>>());

	if (odp[0].second != evp[0].second) {
		co(N - odp[0].first - evp[0].first);
	}
	else {
		int dotti = min(N - odp[1].first - evp[0].first, N - evp[1].first - odp[0].first);
		co(dotti);
	}
	Would you please return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int dp[55][4][4],n;
char arr[3][55];
int rec(int pos,int col1,int col2){
	if(pos>n)
		return 1;
	int &ret=dp[pos][col1][col2];
	if(~ret)
		return ret;ret=0;
	if(arr[1][pos]==arr[2][pos]){
		for(int i=1;i<=3;i++){
			if(col1==i or col2==i)
				continue;
			ret=(ret+rec(pos+1,i,i))%INF;	
		}
		return ret;
	}
	for(int i=1;i<=3;i++){
		if(col1==i)
			continue;
		for(int j=1;j<=3;j++)
			if(col2!=j and i!=j)
				ret=(ret+rec(pos+2,i,j))%INF;
	}
	return ret;
}
int main(){
	memset(dp,-1,sizeof dp);
    //~ freopen("file.in", "r", stdin);
    scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			scanf(" %c",&arr[i][j]);
	printf("%d\n",rec(1,0,0));
	return 0;
}


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

#define MX1 2005
#define MX2 4000005
bitset<MX2>b_set;
int a[MX1],n;

void process()
{
    b_set.reset();
    b_set.set(0);
    for(int i=0; i<n; i++)
    {
        b_set = b_set|(b_set<<a[i]);
    }
}

int main()
{
    int i,x,s=0;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        s += a[i];
    }
    x = (s+1)>>1;
    process();
    for(i=x; i<=s; i++)
    {
        if(b_set.test(i))
        {
            printf("%d\n",i);
            exit(0);
        }
    }
    return  0;
}
/// median >= (sum+1)/2


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

int main(){
    int n;
    cin >> n;
    int num[10][10];
    memset(num,0,sizeof(num));
    for(int i=1;i<=n;i++){
        string nn = to_string(i);
        int p = nn[0]-'0';
        int q = nn[nn.length()-1]-'0';
        if(p==0 || q==0) continue;
        num[p][q]++;
    }
    ll ans = 0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans+=num[i][j]*num[j][i];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*(10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N,M,K = map(int,input().split())
a=cmb(N*M-2, K-2, mod)
b=((N**2)*M*(M+1)*(M-1)//6)%(10**9+7)
c=((M**2)*N*(N+1)*(N-1)//6)%(10**9+7)
print((a*(b+c))%(10**9+7))

Measured memory_bytes: 80880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long x, long long y){
	ll res = INF;
	if (y-x >= 0) res = min(res, y-x);
	if (-y-x >= 0) res = min(res, -y-x+1);
	if (y+x >= 0) res = min(res, y+x+1);
	if (-y+x >= 0) res = min(res, -y+x+2);
	cout << res << endl;
}

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



Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x = tx-sx
y = ty-sy
print("U" * y + "R" * x + "D" * y + "L" * (x+1) + "U" * (y+1) + "R" * (x+1) + "D" + "R" + "D" * (y+1) + "L" * (x+1) + "U")

Measured memory_bytes: 3060
h,w = map(int,input().split())
s = ["#"*(w+2)]+["#"+input()+"#" for _ in range(h)]+["#"*(w+2)]
res = 0
l = [[0 for _ in range(w+2)] for _ in range(h+2)]
r = [[0 for _ in range(w+2)] for _ in range(h+2)]
d = [[0 for _ in range(w+2)] for _ in range(h+2)]
u = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
       if s[i][j]==".":
           l[i][j]=l[i][j-1]+1 
           d[i][j]=d[i-1][j]+1 
for i in range(h,0,-1):
    for j in range(w,0,-1):
       if s[i][j]==".":
           r[i][j]=r[i][j+1]+1 
           u[i][j]=u[i+1][j]+1 


for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == ".":
            res = max(res,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
            if res == h+w-1:break

print(res)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sum;
  sum = a + b + c;
  if (sum == 17) {
    cout << "YES" << endl;
  }
   else {
     cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  string ans = "Yes";
  REP(i, s.length()) {
    if (s[i] != t[i]) ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mod 1000000007
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;

ll n,m;
ll grid[1005][1005];
ll dp[1005][1005];
ll solve(ll i,ll j)
{
    if(i==1&&j==1)
    {
        return 1;
    }
    if(i<1||j<1)
        return 0;
    if(grid[i][j]=='#')
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];

    return dp[i][j]=((solve(i-1,j)%mod)+(solve(i,j-1)%mod))%mod;
}
int main()
{
    memset(dp,-1,sizeof dp);
    sc2(n,m);
    for(ll i=1;i<=n;i++)
    {
        getchar();
        for(ll j=1;j<=m;j++)
        {
            scanf("%c",&grid[i][j]);
        }
    }
    ll ans=solve(n,m);
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 16128
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
orderlist = [A,B,C,D,E]
maxtime = 10

for x in range(0,4):
    if orderlist[x] % 10 == 0:
        continue
    time = orderlist[x] % 10
    maxtime = min(time,maxtime) 

Sum = 0

for x in range(0,5):
    if orderlist[x] % 10 ==0:
        Sum += orderlist[x]
    else:
        Sum += orderlist[x] + 10 - (orderlist[x] % 10)

Sum += maxtime -10

print(Sum)

Measured memory_bytes: 3064
#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>;
 
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
ll sum(ll l, ll r) {
  return (l+r)*(r-l+1)/2;
}
 
int main() {
  int n, k;
  cin >> n >> k;
  mint ans;
  for (int i = k; i <= n+1; ++i) {
    ll l = sum(0,i-1), r = sum(n-i+1,n);
    ans += r-l+1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644