akhauriyash/Code-Regression huggingface dataset:
// 2020-10-01 00:15:14
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<ll> a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  vector<ll> s(n + 1, 0), t(n + 1, 0);
  {
    priority_queue<ll, vector<ll>, greater<ll> > que;
    ll tot = 0;
    rep(i, n) {
      tot += a[i];
      que.push(a[i]);
    }
    s[0] = tot;
    rep(i, n) {
      tot += a[n + i];
      que.push(a[n + i]);
      tot -= que.top();
      que.pop();
      s[i + 1] = tot;
    }
  }
  reverse(ALL(a));
  {
    priority_queue<ll, vector<ll>, less<ll> > que;
    ll tot = 0;
    rep(i, n) {
      tot += a[i];
      que.push(a[i]);
    }
    t[0] = tot;
    rep(i, n) {
      tot += a[n + i];
      que.push(a[n + i]);
      tot -= que.top();
      que.pop();
      t[i + 1] = tot;
    }
  }
  reverse(ALL(t));
  ll ans = -(ll(1e18));
  repc(i, n) chmax(ans, s[i] - t[i]);
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 8996
#include <stdio.h>

int main()
{
   int a, b;
   
   scanf("%d %d", &a, &b);
   
   if(a <= 5){
       b = 0;
       printf("%d", b);
   }else if(a <= 12){
       b = b / 2;
       printf("%d", b);
       
   }else{
       printf("%d", b);
   }

    return 0;
}

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

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

    ll n,i,j;
    cin>>n;
    if(n==3)
    {
      cout<<2<<endl;
        cout<<1<<" "<<3<<endl;
        cout<<2<<" "<<3<<endl;
    }
    else if(n%2)
    {
      ll c=0;
              for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if((i+j)==n)
                {
                    continue;
                }
              c++;
            }
        }
cout<<c<<endl;
        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if((i+j)==n)
                {
                    continue;
                }
                cout<<i<<" "<<j<<endl;
            }
        }
    }
    else
    {
      ll c=0;
        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if((i+j)==(n+1))
                {
                    continue;
                }
              c++;
            }
        }
cout<<c<<endl;
      for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if((i+j)==(n+1))
                {
                    continue;
                }
                cout<<i<<" "<<j<<endl;
            }
        }

    }
}

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

#define ll long long

int main()
{
int n, m;
cin>>n>>m;
set<pair<int, int>> stop;
int a, b;
for (int i = 0; i<m; i++) {cin>>a>>b; a--; b--; stop.insert(make_pair(b, a));}
int current = -1;
int counter = 0;
for (auto it = stop.begin(); it!=stop.end(); it++)
{
    if (it->second>=current) {current = it->first; counter++;}
}

cout<<counter;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const double INF = 0x3f3f3f3f;
const double r = 0.8;
const int maxn = 50;
const int num = 20;

struct Point
{
	double x, y, z;
};
Point a[maxn], op;
int n;
double d[maxn];

double dis(Point A, Point B)
{
	return sqrt((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y)+(A.z-B.z)*(A.z-B.z));
}

double MAX(Point t)
{
	double res = -1;
	for (int i = 0; i < n; i++)
	{
		res = max(res, dis(t, a[i]));
	}
	return res;
}
int main()
{
	while (cin>>n&&n)
	{
		op.x = op.y = op.z = 0.0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i].x >> a[i].y>>a[i].z;
		}
		double ret, delta = 100.0;
		double maxDis, temDis;
		int id;
		while (delta>EPS)
		{
			id = 0;
			maxDis = dis(op, a[id]);
			for (int i = 1; i < n; i++)
			{
				temDis = dis(op, a[i]);
				if (temDis > maxDis)
				{
					maxDis = temDis;
					id = i;
				}
			}
			ret = maxDis;
			op.x += (a[id].x - op.x) / maxDis * delta;
			op.y += (a[id].y - op.y) / maxDis * delta;
			op.z += (a[id].z - op.z) / maxDis * delta;
			delta *= 0.99;
		}
		printf("%.5lf\n", ret);
	}
	return 0;
}



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

int main(){
    int n, m;
    cin >> n >> m;
    ll h[n];
    int flag[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
        flag[i] = 0;
    }

    pair<int, int> p[m];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b){
            p[i] = make_pair(b, a);
        }else{
            p[i] = make_pair(a, b);
        }
    }

    int ans = 0;
    for(int j = 0; j < m; j++){
        if(h[p[j].first] > h[p[j].second]){
            flag[p[j].second] = 1;
        }else if(h[p[j].first] == h[p[j].second]){
            flag[p[j].first] = 1;
            flag[p[j].second] = 1;
        }else{
            flag[p[j].first] = 1;
        }
    }

    for(int i = 0; i < n; i++){
        if(flag[i] == 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5564
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int n, a[20 + 5];
priority_queue<int> que;

int main(int argc, char *argv[])
{
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        int minus;
        cin >> minus;
        que.emplace(a[i] - minus);
    }
    
    int result = 0;
    while (!que.empty() && que.top() > 0)
    {
        result += que.top();
        que.pop();
    }
    
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int h,w,i,l,n,c;
	int r[10000];

	while(scanf("%d%d%d",&h,&w,&i),h+w+i){
		scanf("%d",&n);
		for(l=0;l<n;l++)scanf("%d",&r[l]);

		if(h<i){
			if(i<w) c=h*h+i*i;
			else c=h*h+w*w;
		}else if(i<w){
			if(w<h) c=w*w+i*i;
			else c=h*h+i*i;
		}else if(w<h){
			if(i<h) c=w*w+i*i;
			else c=h*h+w*w;
		}
		for(l=0;l<n;l++){
			if(r[l]*r[l]*4<=c)puts("NA");
			else puts("OK");
		}
	}
	return 0;
}

Measured memory_bytes: 588
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        var a = new int[n];
        var b = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(a);
        Arrays.sort(b);
        if(n%2 == 1){
            System.out.println(b[n/2] - a[n/2] + 1);
        }else{
            var a2 = BigDecimal.valueOf(a[n/2-1]).add(BigDecimal.valueOf(a[n/2]));
            a2 = a2.divide(BigDecimal.valueOf(2), 1, RoundingMode.HALF_EVEN);
            var b2 = BigDecimal.valueOf(b[n/2-1]).add(BigDecimal.valueOf(b[n/2]));
            b2 = b2.divide(BigDecimal.valueOf(2), 1, RoundingMode.HALF_EVEN);
            var ans = BigDecimal.ONE.add(b2.subtract(a2).multiply(BigDecimal.valueOf(2)));
            System.out.println(ans.setScale(0, RoundingMode.HALF_EVEN));
        }
    }
}

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

const int MOD = (int)1e9+7;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> a(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a.at(i).at(j);
    }
  }

  int ans=0;
  vector<pair<int,int>> yx;
  vector<pair<int,int>> next_yx;
  for(int i=0;i<H-1;i++){
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)%2==1){
        a.at(i).at(j)--;
        a.at(i+1).at(j)++;
        ans++;
        yx.push_back(make_pair(i+1,j+1));
        next_yx.push_back(make_pair(i+2,j+1));
      }
    }
  }
  for(int j=0;j<W-1;j++){
    if(a.at(H-1).at(j)%2==1){
      a.at(H-1).at(j)--;
      a.at(H-1).at(j+1)++;
      ans++;
      yx.push_back(make_pair(H,j+1));
      next_yx.push_back(make_pair(H,j+2));
    }
  }

  cout << ans << endl;
  for(int i=0;i<ans;i++){
    cout << yx.at(i).first << " " << yx.at(i).second << " " << next_yx.at(i).first << " " << next_yx.at(i).second << endl;
  }

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> sum(20, vector<int>(n+1));
    rep(i,n){
        rep(j,20) if(a[i] >> j & 1) sum[j][i+1]++;
        rep(j,20) sum[j][i+1] += sum[j][i];
    }

    ll ans = 0;
    vector<int> cnt(20);
    int idx = 0;
    rep(i,n){
        while(1){
            if(idx == n) break;
            bool flag = true;
            rep(j,20) if(cnt[j] + (sum[j][idx+1]-sum[j][idx]) > 1) flag = false;
            if(!flag) break;
            rep(j,20) cnt[j] += sum[j][idx+1] - sum[j][idx];
            idx++;
            if(idx == n) break;
        }
        ans += idx - i;
        rep(j,20) cnt[j] -= sum[j][i+1] - sum[j][i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 20352
using System;

using System .Linq;


namespace ConsoleApplication2
{
	using System;

	public class Dice
	{

		public static void Main(String[] args)
		{

			string yesNo = "No";
			string dataA = Console.ReadLine();
			string dataB = Console.ReadLine();
      		string[] diceA = dataA.Split();
     		string[] diceB = dataB.Split();
     		
           	int i = 0;
			int j = 0;
			do {
				do {
                  
					for (int k = 0; k < diceA.Length; k++) {
						if (!diceA[k].Equals(diceB[k])) {
							yesNo = "No";
							break;
						}
						if (k == diceA.Length - 1) {
							yesNo = "Yes";
						}
					}
					if (yesNo == "Yes") {
						break;
					}
					turn(3, 5, 2, 0, diceB);                   
					j++;
				} while (j < 4);

				if (yesNo == "Yes") {
					break;
				}
				
				j = 0;
				
				if (i == 3) {
                   
					turn(4, 5, 1, 0, diceB);//????????§?????????
					turn(2, 5, 3, 0, diceB);
					
				} else if (i == 4) {
					//??????????????§diceB[1]=east
					//west ???south????????????????????????                   
					turn(4, 5, 1, 0, diceB);                       
				}

				turn(4, 5, 1, 0, diceB);
				
				i++;
			} while (i < 6);
			
			Console.WriteLine(yesNo);
		}

		public static void turn(int a, int b, int c, int d, string[] dice)
		{
			string temp = dice[a];
			dice[a] = dice[b];
			dice[b] = dice[c];
			dice[c] = dice[d];
			dice[d] = temp;
            
		}
	}
}

Measured memory_bytes: 8928
function Main(arg) {
 
    var N = arg.split("\n")[0]-0;
 
    var ans = "No";
    for (var i = 1; i <= 9; i++){
        for (var j = 1; j <= 9; j++){
            if (i * j === N) {
                ans = "Yes";
            }
        }
    }

    console.log(ans)

    return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
from collections import deque
S = deque()
S.extend(input())
Q = int(input())
reverse = 0
for i in range(Q):
    list = input().split(' ')
    if list[0] == '1':
        reverse += 1
    elif list[1] == '1':
        if reverse % 2 == 1:
            S.append(list[2])
        else:
            S.appendleft(list[2])
    elif list[1] == '2':
        if reverse % 2 == 1:
            S.appendleft(list[2])
        else:
            S.append(list[2])
if reverse % 2 == 1:
    S.reverse()
ans = ''.join(S)
print(ans)

Measured memory_bytes: 8436
W,H,x,y,r = map(int, input().split())

#x - r が0 より小さい、または、x + r がW より大きいならばNoと判定。
if (0<= x-r and x+r <= W and 0 <= y - r and y+r <=H):
    print ("Yes")
else:
    print ("No")



Measured memory_bytes: 5596
n = int(input())
ab = []
for _ in range(n):
    ab.append([int(x) for x in input().split()])
ab.sort(key=lambda x: x[1])
punctual = "Yes"
now = 0
for ai, bi in ab:
    now += ai
    if now > bi:
        punctual = "No"
print(punctual)

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    vector<ll> vec[26];
    ll vecindex[26] = {};
    string s,t;
    cin >> s >> t;
    rep(i,0,s.size()){
        vec[s[i] - 'a'].push_back(i);
    }

    ll cnt = 0,index = -1;
    rep(i,0,t.size()){
        ll temp = t[i] - 'a';
        if(vec[temp].size() == 0){
            cout << -1 << endl;
            return 0;
        }
        else{
            ll ng = -1, ok = vec[temp].size();
            while(abs(ok-ng) > 1){
                ll mid = (ok+ng)/2;
                if(vec[temp][mid] > index){
                    ok = mid;
                }
                else{
                    ng = mid;
                }
            } 

            if(ok == vec[temp].size()){
                cnt++;
                index = vec[temp][0];
            }
            else{
                index = vec[temp][ok];
            }
        }
        //cout << cnt << " " << index << endl;
    }
    cout << cnt*s.size() + index + 1 << endl;
}




Measured memory_bytes: 4656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
int A[200010];


llint solve(){
	llint ans = 0;
	llint sum = 0;
	llint xsum = 0;
	int j = 0;
	rep(i, 0, N){
		while(j < N && sum+A[j] == (xsum^A[j])) sum+=A[j], xsum^=A[j], j++;
		ans += j-i;
		sum -= A[i];
		xsum ^= A[i];
	}
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

//再帰関数による最大公約数
int gcd(int x, int y){
    return y ? gcd(y, x % y) : x;
}

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", gcd(a, b));

    return 0;
}


Measured memory_bytes: 2760
#include <stdio.h>
#include <string.h>
int N;

int main(){
    int S[4]={0};
    char str[4];
    scanf("%d",&N);
    for(int i=0;i<N;i++){
	scanf("%s",str);
	if(strcmp(str,"AC")==0)
	    S[0]++;
	else if(strcmp(str,"WA")==0)
	    S[1]++;
	else if(strcmp(str,"TLE")==0)
	    S[2]++;
	else
	    S[3]++;
    }

    printf("AC x %d\n",S[0]);
    printf("WA x %d\n",S[1]);
    printf("TLE x %d\n",S[2]);
    printf("RE x %d\n",S[3]);

    return 0;
}



    


Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<bool> check(n,false);
  vector<int> wanum(n,0);
  int ac = 0;
  int wa = 0;
  for(int i=0;i<m;i++){
    int p;
    string s;
    cin >> p >> s;
    if(check[p]) continue;
    if(s == "AC"){
      check[p] = true;
      ac++;
      wa += wanum[p];
    }else if(s == "WA"){
      wanum[p]++;
    }
  }
 
  cout << ac << " " << wa << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  list<int> lst;
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string query;
  int key;
  list<int>::iterator itr;
  while(n--){
    cin >> query;
    if(query == "insert"){
      cin >> key;
      lst.push_front(key);
    }
    if(query == "delete"){
      cin >> key;
      for(itr = lst.begin();itr != lst.end();itr++){
	if(*itr == key){lst.erase(itr);break;}
      }
    }
    if(query == "deleteFirst")lst.pop_front();
    if(query == "deleteLast")lst.pop_back();
  }
  for(itr = lst.begin();itr != --lst.end();itr++){
    cout << *itr << " ";
  }
  cout << *itr << endl;
  return 0;
}

Measured memory_bytes: 32476
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    string s;cin>>s;
    int cnt0=0;
    int cnt1=0;
    rep(i,s.size()){
        if(s.at(i)=='0') cnt0++;
        if(s.at(i)=='1') cnt1++;
    }

    int ans = 2*min(cnt0, cnt1);
    cout<<ans<<endl;
}

Measured memory_bytes: 3800
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a[5], k;
    bool t=0;
    for(int i=0; i<5; ++i){
        cin >> a[i] ;
    }   
    cin >>k;
    for(int i=0; i<4; ++i){
        for(int j=i+1; j<5; ++j){
            if(a[j]-a[i]>k)t=1;
        }
    }
    if(t)cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int select(int,int);
int n;
int ns[20];
int m;
int ms;
int main(){
  scanf("%d",&n);
  m=n;
  while(m){
    scanf("%d",&ns[n-m]);
    m--;
  }
  scanf("%d",&m);
  while(m){
    scanf("%d",&ms);
     printf(select(0,ms)?"yes\n":"no\n");
    m--;
  }
  return 0;
}
int select(int i,int s){
  if(s==0)return 1;
  if(i>=n)return 0;
  select(i+1,s)||select(i+1,s-ns[i]);
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;
const LL MAX = 2e5 + 47;

int a[MAX];
PII b[MAX];
int ans[MAX];
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, n)
		b[i] = MP(a[i], i);
		
	sort(b, b + n);
	
	FOR(i, 0, n/2)
		ans[b[i].Y] = b[n/2].X;
		
	FOR(i, n/2, n)
		ans[b[i].Y] = b[n/2 - 1].X;
	
	FOR(i, 0, n)
		cout << ans[i] << endl;
	
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int f(int n) {
    int res = 0;
    for (int x=1; x*x <= n; x++) {
	for (int y=1; x*x+y*y+x*y <= n; y++) {
	    for (int z=1; x*x + y*y + z*z + x*y + y*z + z*x <= n; z++) {
		if (x*x + y*y + z*z + x*y + y*z + z*x == n) {
		    res++;
		}
	    }
	}
    }
    return res;
}



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

    int n;
    cin>>n;
    for (int i=1; i<=n; i++) {
	cout<<f(i)<<"\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 3568
#include "bits/stdc++.h"

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x) 
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

constexpr int MOD = 998244353;

struct fenwick_t {
    LL ft[1000000];
    LL query(int w) {
        LL a = 0;
        for(; w; w -= (w & -w)) {
            a = (a + ft[w]) % MOD;
        }
        return a;
    }
    void update(int w, int v) {
        for(; w < 1000000; w += w & (-w)) {
            ft[w] = (ft[w] + v) % MOD;
        }
    }
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N, K;
    cin >> N >> K;
    vector<int> L(K), R(K);
    for(int k = 0; k < K; ++k) {
        cin >> L[k] >> R[k];
    }
    fenwick_t ft;
    ft.update(1, 1);
    for(int n = 2; n <= N; ++n) {
        LL x = 0;
        for(int k = 0; k < K; ++k) {
            x = (x + ft.query(max(0, n - L[k])) - ft.query(max(0, n - R[k] - 1)) + MOD) % MOD;
        }
        ft.update(n, x);
    }
    cout << ((ft.query(N) - ft.query(N - 1) + MOD) % MOD) << "\n";
    
    
    return 0;
}


Measured memory_bytes: 5232
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		double ans=0;
		for(int i=1;i<=a;i++) {
			int tokuten=i;
			int kaisuu=0;
			for(;tokuten<b;) {
				kaisuu++;
				tokuten*=2;
			}
			ans+=(double)1/a*1/(Math.pow(2, kaisuu));
			}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;
const double pi=acos(-1);
const int inf=1e9;
const int N=200100;
int n,sx,sy,ex,ey,x,y;
int f[N],len,flag,tot;
double ans;
struct node{
	int x,y;
	node(int _x=0,int _y=0):x(_x),y(_y){}
	friend bool operator < (node a,node b){
		return a.x!=b.x?a.x<b.x:a.y<b.y;
	}
}a[N];

double calc(int line,int less,int more){
	return 100.0*line+(5.0*pi-20.0)*less+(10.0*pi-20.0)*more;
}

int main(){
	
	scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
	if (sx>ex) swap(sx,ex),swap(sy,ey);
	if (sy>ey) flag=1,sy=inf-sy,ey=inf-ey;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		if (flag) y=inf-y;
		if (sx<=x && x<=ex && sy<=y && y<=ey)
			a[++tot]=node(x,y);
	}
	sort(a+1,a+tot+1);
	for (int i=1;i<=tot;i++)
	if (!len || f[len]<a[i].y)
		f[++len]=a[i].y; else
		f[lower_bound(f+1,f+len+1,a[i].y)-f]=a[i].y;
	int half=(len==min(ex-sx,ey-sy)+1);
	printf("%.15lf\n",calc(ex-sx+ey-sy,len-half,half));
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, a, b, x, y;
    cin >> h >> w >> a >> b >> x >> y;
    char grid[h + 3][w + 3];
    int vis[h + 3][w + 3];
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> grid[i][j];
            vis[i][j] = 1e8;
        }
    }
    priority_queue<pair<int, pair<int, int> > >q;
    vis[a][b] = 0;
    q.push({0, {a, b}});
    while(!q.empty()){
        int c = q.top().second.first, d = q.top().second.second;
        int cost = -q.top().first;
        q.pop();
        if(cost > vis[c][d]){
            continue;
        }
        if(c > 1 && grid[c - 1][d] == '.'){
            if(vis[c - 1][d] > cost){
                vis[c - 1][d] = cost;
                q.push({-cost, {c - 1, d}});
            }
        }
        if(c < h && grid[c + 1][d] == '.'){
            if(vis[c + 1][d] > cost){
                vis[c + 1][d] = cost;
                q.push({-cost, {c + 1, d}});
            }
        }
        if(d > 1 && grid[c][d - 1] == '.'){
            if(vis[c][d - 1] > cost){
                vis[c][d - 1] = cost;
                q.push({-cost, {c, d - 1}});
            }
        }
        if(d < w && grid[c][d + 1] == '.'){
            if(vis[c][d + 1] > cost){
                vis[c][d + 1] = cost;
                q.push({-cost, {c, d + 1}});
            }
        }
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                if(c + i >= 1 && c + i <= h && d + j >= 1 && d + j <= w && grid[c + i][d + j] == '.'){
                    if(vis[c + i][d + j] > cost + 1){
                        vis[c + i][d + j] = cost + 1;
                        q.push({-(cost + 1), {c + i, d + j}});
                    }
                }
            }
        }
    }
    if(vis[x][y] == 1e8){
        cout << "-1";
    }
    else{
        cout << vis[x][y];
    }
    return 0;
}

Measured memory_bytes: 8648
#include <stdio.h>
int main()
{
    int H, N, i, j, tmp;
    int A;
    int breakpoint = 0;

    scanf("%d %d", &H, &N);
    for (int a = 0; a < N; a++)
    {
        scanf("%d", &A);
      breakpoint += A;
      
    }
   
   if(breakpoint>=H){
   printf("Yes");}else{printf("No");}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){return e1.cost<e2.cost;}

int par[101],cost[101];
void init(int n){
	for(int i=0;i<n;i++)par[i]=i,cost[i]=0;
}
int find(int n){
	if(n==par[n])return n;
	return par[n]=find(par[n]);
}
void unite(int x,int y){
	x=find(x),y=find(y);
	if(x==y)return;
	if(cost[x]<cost[y])par[x]=y;
	else{
		par[y]=x;
		if(cost[x]==cost[y])cost[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int n,m;
	while(cin>>n>>m,n){
		int ans=0;
		edge es[m];
		for(int i=0;i<m;i++)cin>>es[i].u>>es[i].v>>es[i].cost;
		sort(es,es+m,comp);
		init(n);
		for(int i=0;i<m;i++){
			edge e=es[i];
			if(!same(e.u,e.v)){
				unite(e.u,e.v);
				ans+=e.cost;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1180
import java.util.*;

public class Main{
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = a * b;
        int f = c * d;

        if(e >= f){
            System.out.println(e);
        }else{
            System.out.println(f);
        }
    }
}

Measured memory_bytes: 35820
N = int(input())
a = list(map(int, input().split()))

if N == 2:
    print(sum(a))
    exit()

a_cum = [0, a[0]]
for i in range(1,N):
    a_cum.append(a_cum[-1] + a[i])

def a_sum(i,j):
    return a_cum[j] - a_cum[i]

INF = 10**15

dp = [[INF]*(N+1) for _ in range(N+1)]
for i in range(N):
    dp[i][i+1] = 0
    if i != N-1:
        dp[i][i+2] = a[i] + a[i+1]

for length in range(3, N+1):
    for l in range(N-length+1):
        tmp = INF
        for m in range(l+1, l+length):
            tmp = min(tmp, dp[l][m] + dp[m][l+length] + a_sum(l, l+length))
        dp[l][l+length] = tmp

print(dp[0][N])

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

int main() {
	int N;
	cin >> N;
	if (N == 1) { // 例外
		cout << "Yes" << endl << 2 << endl << "1 1" << endl << "1 1";
		return 0;
	}
	int64_t K = 1;
	for (int64_t max = N, mid = N >> 1;max - K > 1;mid = K + (max - K >> 1)) {
		if (mid * (mid + 1) >> 1 > N) max = mid;
		else K = mid;
	}
	if (K * (K + 1) >> 1 != N) { // 不可能
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;
	cout << K + 1 << endl;
	for (int i = 0;i <= K;++ i) {
		cout << K;
		int out = i - K;
		for (int j = 0;j < K;++ j) {
			if (j <= i) out += K - j;
			if (j >= i) ++ out;
			cout << " " << out;
		}
		cout << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー


*/

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int X, Y;
	int kame = 0, turu = 0;

	scanf("%d %d", &X, &Y);

	if (Y % 2 == 1)
	{
		printf("No\n");
		return (0);
	}

	kame = (Y - 2 * X) / 2;
	turu = X - kame;

	if (kame < 0 || turu < 0)
		printf("No\n");
	else
		printf("Yes\n");

	return (0);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000007
#define maxn 1000000009b
int main()
{
    ll A,B;
    cin >> A >> B;
    int i = 1;
    ll c = 1;
    if(B == 1){
        cout << 0 << endl;
        return 0;
    }
    for(;i < INF;i++){
        c += A-1;
        if(c >= B){
            break;
        }
    }
    cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    ll k[200009];
    k[1] = 0;
    for (int i = 2; i <=200005 ;i++) k[i] = k[i-1] + (i-1);
    ll n; cin >> n;
    ll a[n]; ll b[n+10] = {0};
    for (ll i = 0; i < n; i++) 
    {
        cin >> a[i]; b[a[i]]++;
    }
    ll sum = 0;
    for (ll i = 0; i < n+3; i++)
    {
        if (b[i]!=0)
        {
            sum += k[b[i]];
        }
    }
    for (ll i = 0; i < n; i++)
    {
        ll t = sum - k[b[a[i]]];
        nout(t+k[b[a[i]]-1]);
        //nout(t);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7296
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, C: int):
    if A+B > C:
        print(B+C)
    elif A+B == C:
        print(A+2*B)
    else:
        print(A+2*B+1)
        
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#!/usr/bin/env python
import sys
import re

def move(char, num):
    if ord(char) + num <= ord('z'):
        return ord(char) + num
    else:
        return ord(char) + num - (ord('z') - ord('a') + 1)

def shift(s, num):
    new = ""
    for i in range(0, len(s)):
        if s[i].isalpha():
            new += str(chr(move(s[i], num)));
        else:
            new += s[i]
    return new

def decrypt(s):
    for i in range(0, 26):
        decrypted = shift(s, i)
        if re.search('the|this|that', decrypted):
            return decrypted

if __name__ == '__main__':
    lines = []
    for line in sys.stdin:
        lines.append(line)
    for line in lines:
        print(decrypt(line), end="")

Measured memory_bytes: 7580
n = int(input())
slist = [input()for i in range(n)]

alp = {chr(i):float('inf') for i in range(97,97+26)}

for i in range(len(slist)):
    sdic = {chr(i):0 for i in range(97,97+26)}
    for j in range(len(slist[i])):
        sdic[slist[i][j]] += 1
    
    for k in alp:
        alp[k] = min(alp[k],sdic[k])

alplist = sorted(list(alp.items()))
ans = ''
for i in range(26):
    ans += alplist[i][0]*alplist[i][1]
print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

void makeKochCurve(double x1, double y1, double x2, double y2, int depth)
{
	if (depth == 0) return;
	
	double length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
	double angle  = atan2(y2-y1, x2-x1);
	
	double xa = (2.0 * x1 + x2) / 3;
	double ya = (2.0 * y1 + y2) / 3;
	double xb = (x1 + x2) / 2 - sqrt(3) * length * sin(angle) / 6.0; 
	double yb = (y1 + y2) / 2 + sqrt(3) * length * cos(angle) / 6.0;
	double xc = (x1 + 2.0 * x2) / 3;
	double yc = (y1 + 2.0 * y2) / 3;

	makeKochCurve(x1, y1, xa, ya, depth-1);
	std::cout << xa << " " << ya << std::endl;
	makeKochCurve(xa, ya, xb, yb, depth-1);
	std::cout << xb << " " << yb << std::endl;
	makeKochCurve(xb, yb, xc, yc, depth-1);
	std::cout << xc << " " << yc << std::endl;
	makeKochCurve(xc, yc, x2, y2, depth-1);
}

int main()
{
	int n;
	std::cin >> n;
	
	std::cout << std::fixed;
	std::cout << 0.0 << " " << 0.0 << std::endl;
	makeKochCurve(0.0, 0.0, 100.0, 0.0, n);
	std::cout << 100.0 << " " << 0.0 << std::endl;
	
	return 0;
}




Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    int a[n];
    int saidai = 0;
    int basyo = 0;
    for(int i = 0;i<n;i++) {
      cin >> a[i];
      if(saidai <= a[i]) {
        saidai = a[i];
        basyo = i;
      }
    }
    a[basyo] = 0;
    int nsaidai = 0;
    for(int i = 0;i<n;i++) {
      if(nsaidai <= a[i]) {
        nsaidai = a[i];
      }
    }
    for(int i = 0;i<n;i++){
     if(i!= basyo){
     	cout<<saidai<<endl;
     }
     else{
       cout<<nsaidai<<endl;
     }
    }
    return 0;
}

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

using namespace std;


typedef long long ll ;
const ll mk = 200055;
const ll logn  = 29;
const ll mod = 1e9 + 7;

#define endl "\n"
#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define fi first
#define se second
#define pii pair<ll,ll>
#define pq priority_queue
#define UwU              uwu
#define UwU              Mikuwu
#define Miku             best_waifu
#define Miku_dancing     god_waving
#define Miku_singing     god_shaking
#define a_Miku           cho_doi_bot_ngu

ll n;
ll a[mk];
long long ans = 1e9;
long long pref[mk];

long long f(int pos, int i, int j) {
	if (!pos || pos >= i || j <= i || j == n)
		return 1e9;
	long long x1 = pref[pos], x2 = pref[i] - pref[pos], x3 = pref[j] - pref[i], x4 = pref[n] - pref[j];
	return max(max(x1, x2), max(x3, x4)) - min(min(x1, x2), min(x3, x4));
}

signed main () {
	cin >>n ;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	for (int i = 2; i <= n - 2; ++i) {
		int l = upper_bound(pref, pref + n + 1, pref[i] / 2) - pref;
		int r = upper_bound(pref, pref + n + 1, pref[i] + (pref[n] - pref[i]) / 2) - pref;
		for (int l1 = l - 1; l1 <= l; ++l1) {
			for (int l2 = r - 1; l2 <= r; ++l2)
				ans = min(ans, f(l1,i, l2));
		}
	}
	cout << ans;
}


Measured memory_bytes: 6692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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 int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,d,x;
	cin>>n>>d>>x;
	vector<vector<ll>> p(d,vector<ll>(n));
	REP(i,d) REP(j,n) cin>>p[i][j];
	REP(i,d-1) {
		vector<vector<ll>> dp(n,vector<ll>(x+1,-INF*INF));
		dp[0][0]=0;
		REP(j,n) REP(k,x+1) {
			if(j!=0) dp[j][k]=max(dp[j][k],dp[j-1][k]);
			if(p[i][j]<=k) dp[j][k]=max(dp[j][k],dp[j][k-p[i][j]]+(p[i+1][j]-p[i][j]));
		}
		ll tmp=-INF*INF;
		REP(j,x+1) if(dp[n-1][j]>=0) tmp=max(tmp,x+dp[n-1][j]);
		x=tmp;
	}
	cout<<x<<endl;
}




Measured memory_bytes: 5484
# -*- coding: utf-8 -*-
"""
D - XOR World
https://atcoder.jp/contests/abc121/tasks/abc121_d#

"""
import sys


def solve(A, B):
    ans = 0
    if B - A < 10:
        for i in range(A, B+1):
            ans ^= i
        return ans

    if A % 2 == 1:
        ans = A
        A += 1
    if B % 2 == 0:
        ans ^= B
        B -= 1
    pair = (B - A + 1) // 2 % 2
    ans ^= pair
    return ans


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(void)
{
    string s1, s2;
    int cnt = 0;
    cin >> s1;
    s2 = s1.substr(s1.size()/2);
    reverse(s2.begin(), s2.end());
    s1 = s1.substr(0, s1.size()/2);
    
    for (int i = 0; i < s1.size(); i++) {
        if (s1.at(i) != s2.at(i)) cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int BASE = 998244353;

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

  int n, d[100100], cnt[100100] = {0}, maxD = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    cin >> d[i];
    if ((d[i] == 0) ^ (i == 1))
    {
      cout << 0 << endl;
      return 0;
    }
    cnt[d[i]]++;
    maxD = max(maxD, d[i]);
  }

  long long ans = 1;
  for (int i = 1; i <= maxD; i++)
    for (int j = 0; j < cnt[i]; j++)
      ans = ans * cnt[i - 1] % BASE;

  cout << ans << endl;
}


Measured memory_bytes: 1024
using System;

public class Program{
    public static void Main(){
        string str = Console.ReadLine();
        string beforeWheather = "";
        int currentChain = 0;
        int result = 0;
        
        for (int i = 0; i < str.Length - 1; i++){
            if (str[i].Equals('R') || str[i + 1].Equals('R')){
                if (currentChain == 0) currentChain = 1;
                
                if (str[i].Equals(str[i + 1])){
                    currentChain++;
                } else {
                    currentChain = 1;
                }
                
                if (currentChain > result) result = currentChain;
            }
        }
        
        Console.WriteLine(result);
    }
}


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

int main(){
  vector<int> abc(3);
  
  cin >> abc.at(0) >> abc.at(1) >> abc.at(2);
  
  sort(abc.begin(), abc.end());
  
  int ans = 0;
  ans += (abc.at(2) - abc.at(1)) / 2;
  ans += (abc.at(2) - abc.at(0)) / 2;
  
  if((abc.at(2) - abc.at(1)) % 2 && (abc.at(2) - abc.at(0)) % 2) ans++;
  else if((abc.at(2) - abc.at(1)) % 2 || (abc.at(2) - abc.at(0)) % 2) ans += 2;
  
  cout << ans << endl;
  
  return 0;
}

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

int n, m, row[110], col[110];
char a[110][110];
bool vr[110], vc[110];

int main ()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
        {
            cin >> a[i][j];
            if (a[i][j] == '#')
                ++row[i], ++col[j];
        }
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (!row[i] && !col[j])
                vr[i] = 1, vc[j] = 1;
    for (int i = 1; i <= n; ++i)
        if (!vr[i])
        {
            for (int j = 1; j <= m; ++j)
                if (!vc[j])
                    cout << a[i][j];
            cout << endl;
        }

}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

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

  double ans = 0;
  for (int i=0; i<N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "BTC") {
      ans += x * 380000.0;
    } else {
      ans += int(x);
    }
  }
  cout  << ans << '\n';
  return 0;
}

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

main(){
  int N,W;
  cin >> N >> W;
  int w[N],v[N];
  for(int ii=0;ii<N;ii++){
    cin >> w[ii] >> v[ii];
  }
  long dp[N+1][W+1];
  for(int ii=0;ii<N+1;ii++){
    for(int jj=0;jj<W+1;jj++){
      dp[ii][jj]=0;
    }
  }
  dp[0][0]=0;
  for(int ii=0;ii<N;ii++){
    for(int jj=0;jj<W+1;jj++){
      if(jj>=w[ii])dp[ii+1][jj]=max(dp[ii+1][jj],dp[ii][jj-w[ii]]+v[ii]);
      dp[ii+1][jj]=max(dp[ii+1][jj],dp[ii][jj]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 79104
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;


vector<vector<int>> warshallFloyd(vector<vector<int>> ary, int N){
	vector<vector<int>> v(ary);
	for (size_t k = 0; k < N; k++) {
		for (size_t i = 0; i < N; i++) {
			for (size_t j = 0; j < N; j++) {
				v[i][j] = min(v[i][j] , v[i][k] + v[k][j]);
			}
		}
	}
	return v;
}


int main(int argc, char const *argv[]) {
	int N,temp;
	cin >> N;
	vector<vector<int>> v;
	v.resize(N);
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < N; j++) {
			std::cin >> temp;
			v[i].push_back(temp);
		}
	}

	// warshall Floyd法により各点から各点への最小距離を出す
	vector<vector<int>> ideal(warshallFloyd(v,N));

	// とりあえず入力が本当に最小距離だったのか判定
	for (size_t i = 0; i < N; i++) {
		for (size_t j = 0; j < N; j++) {
			// 入力が最小距離じゃなかったら終了
			if (v[i][j] > ideal[i][j]) {
				std::cout << -1 << '\n';
				return 0;
			}
		}
	}


	bool flag;
	unsigned long long ans = 0;
	for (size_t i = 0; i < N; i++) {
		for (size_t j = i; j < N; j++) {
			flag = true;
			for (size_t k = 0; k < N; k++) {
				if (k != i && k != j) {
					if (ideal[i][j] == ideal[i][k] + ideal[k][j]) {
						flag = false;
					}
				}
			}
			if (flag) {
				ans += ideal[i][j];
			}
		}
	}

	std::cout << ans << '\n';

	return 0;
}


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

int n, ans, l;
int main()
{
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (l < h[i])
			ans += h[i] - l;
		l = h[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
	
	
	string s;
	cin >> s;
	
	map<char,int> mp;
	rep(i,s.size()) mp[s[i]]++;
	
	bool isOK = true;
	for(auto p : mp){
		if(p.second != 2){
			isOK = false;
			break;
		}
	}
	
	if(isOK){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

import itertools

D, G = map(int, input().split())

# 各点数問題毎の、全問解いた場合の回答数と得点を保持
class ScoreSet:
    def __init__(self, times, score):
        self.times = times
        self.score = score

# 各パターン毎の、合計回答数と合計得点と、どの点数問題を全問解いたのかを保持
class ScoreSetSum:
    def __init__(self, times, score, bool_list):
        self.times = times
        self.score = score
        self.bool_list = bool_list

# 入力内容から、ScoreSetのリストを作成
scoreSetList = []
for i in range(D):
    p, c = map(int, input().split())
    scoreSetList.append(ScoreSet(p, p*100*(i+1) + c))

# どの点数問題を全問解いたのかの各パターンの全網羅
bool_lists = list(itertools.product([True, False], repeat=D))

# パターン全網羅とScoreSetのリストから、ScoreSetSumのリストを作成
scoreSetSumList = []
for bool_list in bool_lists:
    times_tmp = 0
    score_tmp = 0
    for i in range(len(bool_list)):
        if bool_list[i]:
            times_tmp += scoreSetList[i].times
            score_tmp += scoreSetList[i].score
    scoreSetSumList.append(ScoreSetSum(times_tmp, score_tmp, bool_list))

# ScoreSetSumのリストを元に、適切なパターンを探していく
ans = float("inf")
for scoreSetSum in scoreSetSumList:
    tmp = float("inf")
    # 得点が既にG以上であれば、そのままその回答数が候補
    if scoreSetSum.score >= G:
        tmp = scoreSetSum.times
    else:
        # 足りなかったら、全問解いていない点数問題から最も高いもの選ぶ
        for i in range(D-1, -1, -1):
            if scoreSetSum.bool_list[i] == False:
                score = scoreSetSum.score
                times = scoreSetSum.times
                # 選んだ点数問題を1問ずつ解いていく
                for j in range(scoreSetList[i].times):
                    score += 100*(i+1)
                    times += 1
                    # G以上に達した時点で、その時の回答数が候補
                    if score >= G:
                        tmp = times
                        break
                    # 最後まで解いてもG以上にならなければ、このパターンは候補外
                break
    # 今までの最小と今回の候補を比較
    ans = min(ans, tmp)

print(ans)

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

int main() {
  string s, t;
  cin >> s >> t;
  int mi = INF;
  for (int i = 0; i <= s.length() - t.length(); i++) {
    int cnt = 0;
    for (int j = 0; j < t.length(); j++) {
      if (s[i + j] != t[j]) cnt++;
    }
    mi = min(cnt, mi);
  }
  cout << mi << endl;
}

Measured memory_bytes: 3624