akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int n = 0;
    cin >> n;
    vector<int> vec(n);
    REP(i, n)
    {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    if (n % 2 != 0)
    {
        cout << 0;
    }
    else
    {
        if (vec[n / 2] == vec[n / 2 - 1])
        {
            cout << 0;
        }
        else
        {
            cout << vec[n / 2] - vec[n / 2 - 1];
        }
    }
}


Measured memory_bytes: 640
def f(x):
    y=x[:n];heapify(y);z=sum(y);yield z
    for i in x[n:n*2]:z+=i-heappushpop(y,i);yield z
from heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f([-i for i in a[n:][::-1]]),list(f(a))[::-1]))))

Measured memory_bytes: 36308
list3=['aab', 'd.b', 'dcc']
list4=['aacd', 'bbcd', 'efgg', 'efhh']
list5=['abc..', 'abc..', 'ddehh', 'g.eii', 'gffjj']
list7=['.aabbcc', 'dghh...', 'dg.j...', 'eiij...', 'e...kll', 'f...k.n', 'f...mmn']

n=int(input())
if n<=2:
    print(-1)
elif n%3==0:
    lists=[]
    for i in range(n):
        row='.'*((i//3)*3)+list3[i%3]+'.'*(n-3-(i//3)*3)
        lists.append(row)
    for l in lists:
        print(l)
else:
    kotae=[
            [],
            [],
            [],
            [],
            [1,0,0],
            
            [0,1,0],
            [],
            [0,0,1],
            [2,0,0],
            [1,1,0],
            
            [0,2,0],
            [1,0,1],
            [3,0,0],
            [2,1,0],
            [1,2,0],
            
            [0,3,0],
            [4,0,0],
            [3,1,0],
            [2,2,0],
            [1,3,0],
            
            [0,4,0],
            [4,1,0],
            [3,2,0],
            [2,3,0],
            [6,0,0],
            
            [0,5,0],
            [4,2,0]
        ]
    if n<=25:
        loop=kotae[n]
    else:
        mazu=n%20
        if mazu<7:
            mazu+=20
        loop=kotae[mazu]
        loop[0]+=((n-mazu)//20)*5
    
    lists=[]
    now=0
    for i in range(loop[0]*4):
        row='.'*(i//4)*4+list4[i%4]+'.'*(n-4-(i//4)*4)
        lists.append(row)
    now+=loop[0]*4
    
    for i in range(loop[1]*5):
        row='.'*(now+(i//5)*5)+list5[i%5]+'.'*(n-5-now-(i//5)*5)
        lists.append(row)
    now+=loop[1]*5
    
    for i in range(loop[2]*7):
        row='.'*(now+(i//7)*7)+list7[i%7]+'.'*(n-7-now-(i//7)*7)
        lists.append(row)
    now+=loop[1]*7
    
    for l in lists:
        print(l)

Measured memory_bytes: 44144
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, m;
    cin >> N; //scanf("%d", &N);
    m = N % 10;
    if (m == 2 || m == 4 || m == 5 || m == 7 || m == 9)
        cout << "hon" << endl;
    else if (m == 0 || m == 1 || m == 6 || m == 8)
        cout << "pon" << endl;
    else
        cout << "bon" << endl;
    return 0;
}

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

typedef long long ll;

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

  list<ll> ans;
  int a;
  cin >> a;
  ans.push_back(a);
  if (n % 2 == 0)
  {
    for (int i = 1; i < n; i++)
    {
      cin >> a;
      if (i % 2 == 0)
      {
        ans.push_back(a);
      }
      else
      {
        ans.push_front(a);
      }
    }
  }
  else
  {
    for (int i = 1; i < n; i++)
    {
      cin >> a;
      if (i % 2 == 1)
      {
        ans.push_back(a);
      }
      else
      {
        ans.push_front(a);
      }
    }
  }

  for (auto itr = ans.begin(); itr != ans.end(); itr++)
  {
    cout << *itr;
    if (itr != ans.end()--)
    {
      cout << " ";
    }
  }
  cout << "\n";
}

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

int main(){
  int X, Y, Z;
  cin >> X;
  cin >> Y;
  cin >> Z;

  int X_temp, Y_temp, Z_temp;
  X_temp = X;
  Y_temp = Y;
  Z_temp = Z;
  X = Y_temp;
  Y = X_temp;
  X_temp = X;
  Z = X_temp;
  X = Z_temp;

  cout << X << " " << Y << " " << Z << endl;
}


Measured memory_bytes: 256
S = gets.chomp

max = 0
S.length.times do |i|
  len = 0
  (i...S.length).each do |j|
    if S[j] == 'A' or S[j] == 'G' or S[j] == 'C' or S[j] == 'T'
      len += 1
    else
      break
    end
  end

  if max < len
    max = len
  end
end

puts max

Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
int64_t inline gcd(int64_t a, int64_t b) {
    if (a < b) return gcd(b, a);

    int64_t r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
int main() {
    int k; cin >> k;

    int64_t ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = i; j <= k; j++) {
            for (int l = j; l <= k; l++) {
                if (i == j && j == l) {
                    ans +=  gcd(i, gcd(j, l));
                } else if (i == j || j == l || l == i){
                    ans += 3 * gcd(i, gcd(j, l));
                } else {
                    ans += 6 *  gcd(i, gcd(j, l));
                }

            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3164
#include <algorithm>
#include <iostream>
#include <list>
#include <string>
#include <map>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
const Board GOAL = 0x087654321;

struct state {
    Board board;
    int count;
};

list<state> q;
map<Board,char> history;

inline void swap(int numpos, int spacepos, Board& board) {
    long long num = (board >> (numpos*4)) & 15;
    board |= num << (spacepos*4);
    board &= ~(15LL << (numpos*4));
}

inline int swap_and_check(int numpos, int spacepos, state s) {
    swap(numpos, spacepos, s.board);
    ++s.count;
    if (s.board == GOAL) {
        return s.count;
    }
    map<Board,char>::iterator it = history.find(s.board);
    if (it == history.end()) {
        history.insert(make_pair(s.board, ' '));
        q.push_back(s);
    }
    return -1;
}

void print(Board b) {
    for (int i = 0; i < N; ++i) {
        printf("%2lld", (b >> (i*4) & 15));
    }
    printf("\n");
}

int main(void) {

    Board board = 0;
    for (int i = 0; i < N; ) {
        char ch;
        scanf("%c", &ch);
        if (isdigit(ch)) {
            board |= static_cast<long long>((ch - '0')) << (i*4);
            ++i;
        }
    }

    if (board == GOAL) {
        printf("0\n");
        return 0;
    }

//    print(GOAL);
//    print(board);

    q.push_back({ board, 0 });
    int count = 0;
    while (!q.empty()) {
        state s = q.front();
        q.pop_front();

        int pos = -1;
        while (++pos < N) {
            if (((s.board >> (pos*4)) & 15) == 0) {
                break;
            }
        }

        if (pos < 6) {
            if ((count = swap_and_check(pos + 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos > 2) {
            if ((count = swap_and_check(pos - 3, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 < 2) {
            if ((count = swap_and_check(pos + 1, pos, s)) > 0) {
                break;
            }
        }
        if (pos % 3 > 0) {
            if ((count = swap_and_check(pos - 1, pos, s)) > 0) {
                break;
            }
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 13680
import java.lang.Math.abs
import java.util.*


fun main(args: Array<String>) {

    with(Scanner(System.`in`)) {
        val n = nextInt()
        val a = Array(n+2, {0})
        var total = 0
        (1..n).forEach {
            a[it] = nextInt()
            total += abs(a[it] - a[it-1])
        }
        total += abs(a[n])
        (1..n).forEach {
            println(total + abs(a[it+1]-a[it-1]) - abs(a[it]-a[it-1]) - abs(a[it+1]-a[it]))
        }
    }

}

Measured memory_bytes: 65064
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,l[N],r[N];
priority_queue<ll> L;
priority_queue<ll,vector<ll>,greater<ll>> R;

int main() {
	n=read();
	for (int i=1;i<=n;++i) l[i]=read(),r[i]=read();
	L.push(l[1]),R.push(l[1]); ll addl=0,addr=0,ans=0;
	for (int i=2;i<=n;++i) {
		addl-=r[i]-l[i],addr+=r[i-1]-l[i-1];
		ll lb=L.top()+addl,rb=R.top()+addr;
		if (lb<=l[i]&&l[i]<=rb) L.push(l[i]-addl),R.push(l[i]-addr);
		else if (l[i]<lb) {
			ans+=lb-l[i];
			R.push(lb-addr);
			L.pop(),L.push(l[i]-addl),L.push(l[i]-addl);
		} else {
			ans+=l[i]-rb;
			L.push(rb-addl);
			R.pop(),R.push(l[i]-addr),R.push(l[i]-addr);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5740
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	vector<double> a(n);
	rep(i,n)cin >> a[i];
	sort(a.begin(),a.end());
	double ret = a[0];
	rep(i,n){
		if(!i)continue;
		ret = (ret+a[i])/2.0;
	}
	printf("%lf",ret);

	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  
  for(int i = 0; i < (int)s.size() - 1; i++){
      for(int j = i + 1; j < (int)s.size(); j++){
	      if(s[i] != s[j]){
		      cout << "Yes" << "\n";
		      return 0;
		  }
	  }
  }
  cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    long long int n,q[100];
    int d[100];
    int i=0;
    cin>>n;

    for(;;){
        i++;
        q[i]=n%10;
        n-=q[i];
        n/=10;
        if(n==0)break;
    }
    int max=0;

    for(int j=1;j<=i-1;j++){
        if(q[j]<=8){
            //if(0<q[j+1]){
                q[j]=9;
                q[j+1]--;
            //}
        }
    }
    for(int j=1;j<=i;j++){
        max+=q[j];
    }

    cout<<max;
    

    return 0;
}

Measured memory_bytes: 256
n, m, c = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]

count = 0
for i in range(n):
    a = [int(x) for x in input().split(' ')]
    ab = sum(x * y for (x, y) in zip(a, b))
    if ab + c > 0:
        count += 1
        
print(count)

Measured memory_bytes: 3064
import collections

n = int(raw_input())
p = map(int,raw_input().split(' '))
q = map(int,raw_input().split(' '))

def factorial(n): return (n * factorial(n-1)) if n>0 else 1


def f(p,n):

	if len(p) == 1:
		return 0
	sp = sorted(p)
	for i,e in enumerate(sp):
		if e == p[0]:
			hm = i
			break 

	return i * factorial(len(p) -1) + f(p[1:],n)


print abs(f(p,n) - f(q,n))

Measured memory_bytes: 28012
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
int n;
string s;

ll Get(int l,int r)
{
	ll num=0;
	for(int i=l;i<=r;i++)
	{
		num=(num*10)+(s[i]-'0');
	}
	return num;
}

ll Solve(ll lastSum,int lastId)
{
	if(lastId==n-1)return lastSum;
	ll sum=0;
	for(int i=lastId+1;i<n;i++)
	{
		ll cur=Get(lastId+1,i);
		sum+=Solve(lastSum+cur,i);
	}
	return sum;
}	

int main()
{
	while(cin>>s)
	{
		n=sz(s);
		pf("%lld\n",Solve(0,-1));
	}
    return 0;
}



































Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <limits>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

double HeronFormula(double a, double b, double c) {
	double s = (a + b + c) / 2.0;
	return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main() {

	double x[3],y[3];
	REP(i,3) cin >> x[i] >> y[i];

	double l[3];
	REP(i,3) l[i] = sqrt(pow(x[i]-x[(i+1)%3],2.0) + pow(y[i]-y[(i+1)%3],2.0));
	double S = HeronFormula(l[0],l[1],l[2]);
	double r = 2.0 * S / (l[0]+l[1]+l[2]);

	double m = max(l[0],max(l[1],l[2]));

	cout << fixed << setprecision(10) << m / (2.0 + m/r) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N, X, Y; cin >> N >> X >> Y;
	vector<int> ans(N - 1, 0);
	rep(i, 1, N) {
		rep(j, i + 1, N + 1) {
			int distance = min(j - i, abs(X - i) + 1 + abs(Y - j));
			distance = min(distance, abs(Y - i) + 1 + abs(X - j));
			//cout << distance << endl;
			ans[distance - 1]++;
		}
	}
	rep(i, 0, N - 1)cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main()
{
    char inputN[10];
 
    scanf("%s", inputN);
    
    // checks if letters are in the same configuration(by comparing indexes) as in 'coffee' word.
    if (inputN[2] == inputN[3] && inputN[4] == inputN[5])
    {
        printf("Yes \n");
    }
    else
    {
        printf("No \n");
    }
 
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


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

	int n = s.size();

	vi a(26, 0);
	for(int i = 0; i < n; i++)
		a[s[i]-'a']++;

	for(int i = 0; i < 26; i++)
	{
		if(a[i] == 0)
		{
			cout << char(i+'a') << endl;
			return 0;
		}
	}

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

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

int main() {
int n;
  cin>>n;
  ll k[n];
  rep(i, n)cin>>k[i];
    ll sumsum[n+1];
  rep(i, n){if(!i) sumsum[i]=k[0];
    else sumsum[i]=sumsum[i-1]+k[i];}
  sumsum[n]=0;
  
  sort(sumsum,sumsum+n+1);

  ll renzoku=0;
  ll renx[n+1]={0};
  bool counting=false;

  for(int i=1;i<=n;i++){
    if(counting){if(sumsum[i]==sumsum[i-1])
    {renzoku++;
                 if(i==n) renx[n]=renzoku;
    continue;}

                 else {renx[i-1]=renzoku;
                 renzoku=0;
  counting=false;}
                }
      
      
      if(sumsum[i]==sumsum[i-1]){
        counting=true;
        renzoku=2;
        if(i==n) renx[n]=2;
      }
  }
  
  ll ans=0;
  rep(i, n+1){ans+=renx[i]*(renx[i]-1)/2;}
  
  cout<<ans<<endl;


}


Measured memory_bytes: 4992
import heapq
import sys
N=int(input())
BA=[]
for i in range(N):
  a,b=map(int,input().split())
  heapq.heappush(BA,[b,a])
time=0
while BA!=[]:
  v=heapq.heappop(BA)
  b1,a1=v[0],v[1]
  time+=a1
  if time>b1:
    print('No')
    sys.exit()   
print('Yes')

Measured memory_bytes: 34832
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,M;
map<int,int> m[20];
int P[20];

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

    for(int i = 1;i <= M;i++) {
        int k;
        cin>>k;
        for(int j = 0;j < k;j++) {
            int s;
            cin>>s;
            m[i][s] = 1;
        }
    }

    for(int i = 1;i <= M;i++) {
        int p;
        cin>>p;
        P[i] = p;
    }

    int d;
    int ans = 0;
    d = (1<<N);
    for(int bit = 0;bit < d;bit++) {
        int num = bit;
        int score[M+1] = {0};
        for(int i = 0;i < N;i++) {
            if((num>>i) & 1) {
                int swit = i+1;
                for(int j = 1;j <= M;j++) {
                    if(m[j].count(swit) != 0)
                        score[j]++;
                }
            }
        }

        bool flag = true;
        for(int i = 1;i<= M;i++) {
            if((score[i] % 2) != P[i])
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
  int N,A[3],i,j,k,nj,nk;
  char s[3];
  int ans[100000];
  scanf("%d%d%d%d",&N,A,A+1,A+2);
  //if(A[0] + A[1] + A[2] == 0){
  //  printf("No");
  //}
  scanf("%s",s);
  if(strcmp(s,"AB")==0){
    j = 0; k = 1;
  }
  if(strcmp(s,"AC")==0){
    j = 0; k = 2;
  }
  if(strcmp(s,"BC")==0){
    j = 1; k = 2;
  }
  for(i=0;i<N;i++){
    if(i!=N-1){
      scanf("%s",s);
      if(strcmp(s,"AB")==0){
        nj = 0; nk = 1;
      }
      if(strcmp(s,"AC")==0){
        nj = 0; nk = 2;
      }
      if(strcmp(s,"BC")==0){
        nj = 1; nk = 2;
      }
    }
    if(A[j] == 0 && A[k] == 0 ){
      printf("No");
      //break;
      return 0;
    }
    if(A[j] == 0){
      A[j]++; A[k]--;
      ans[i] = j;
    }
    else if(A[k] == 0){
      A[j]--; A[k]++;
      ans[i] = k;
    }
    else if(i != N-1){
      if(j == nj || j == nk){
        A[j]++; A[k]--;
        ans[i] = j;
      }
      else{
        A[j]--; A[k]++;
        ans[i] = k;
      }
    }
    else{
        A[j]++; A[k]--;
        ans[i] = j;
    }
    j = nj; k = nk;
  }
  printf("Yes\n");
  for(i=0;i<N;i++){
    printf("%c\n",'A'+ans[i]);
  }
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;

    rep(i, n - 1)
    {
        if (a[i] > a[i + 1])
        {
            ans += (a[i] - a[i + 1]);
            a[i + 1] = a[i];
        }
    }

    dunk(ans);
}

Measured memory_bytes: 4744
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  int N = s.size();

  // i文字目まで見て, j個丸をつけた時の数
  vector<vector<int>> dp(N+1, vector<int>(4, 0));
  dp[0][0] = 1;

  REP(i, N) REP(j, 4){
    (dp[i+1][j] += dp[i][j]*(s[i] == '?'? 3: 1)) %= MOD;
    if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])){
      (dp[i+1][j+1] += dp[i][j]) %= MOD;
    }
  }

  cout << dp[N][3] << "\n";

  return 0;
}

Measured memory_bytes: 7376
#include <iostream>
#include <stdlib.h>
using namespace std;
int search(int lim,int money)
{
    money=money*1.05;	
    if(money%1000>0)
    {
        money/=1000;
		money+=1;
        money*=1000;
    }
    if(lim==1)
        return money;	
    search(lim-1,money);
}
int main()
{    
	int n;     
    cin >> n ;	
    int ans = search(n,100000);	
    cout << ans << endl;
}

Measured memory_bytes: 1160
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()

minh = 10000000000
for i in range(n-(k-1)):
	if h[i+k-1] - h[i] < minh:
		minh = h[i+k-1] - h[i]

print (minh)

Measured memory_bytes: 7384
n=int(input())
phrase=[tuple(map(int,input().split())) for i in range(n)]
m=int(input())
inf=float('inf')
def main(phrase):
    point=[-1 for _ in range(394)]
    for x in phrase:
        s,l,p=x
        for k in range(s,l+1):
            point[k]=max(point[k],p)
    point[0]=0
    for i in range(1,394):
        for j in range(i):
            point[i]=max(point[i-j]+point[j],point[i])
    return point
ans=[]
dp=main(phrase)
for i in range(m):
    res=dp[int(input())]
    if res==-1:
        print(-1)
        break
    ans.append(res)
    if i==m-1:
        for i in range(m):
            print(ans[i])


Measured memory_bytes: 5688
N,M,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
asum=[0]
bsum=[0]
a.each{|x|asum << asum[-1]+x}
b.each{|y|bsum << bsum[-1]+y}
# ans=0
# j=M
# c.each_with_index do |c,i|
#     break if c > k
#     while d[j] > k-c
#         j -= 1
#     end
#     ans=[ans,i+j].max
# end
# puts ans


i = 0
j = 0
ans = [0, 0]
asum.each do |as|
  break if as > k

  j = bsum.bsearch_index { |bs| as + bs > k }
  j ||= M + 1
  j -= 1 # bsearchでoverした分を引く
  ans = [i, j] if i + j > ans.sum
  i += 1
end

puts ans.sum


Measured memory_bytes: 50592
#include<cstdio>

int a,b,c,d,e,f,dp[3010],dp2[3010];

int main()
{
    scanf ("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

    a*=100; b*=100;
    dp[0]=1;
    for (int i=a;i<=f;i++)
        if (dp[i-a]) dp[i]=1;
    for (int i=b;i<=f;i++)
        if (dp[i-b]) dp[i]=1;
    int br=-1;
    for (int i=f;i>=0;i--)
        if (!dp[i]) dp[i]=br;
        else { br=i; dp[i]=br; }
    dp[0]=dp[1];


    dp2[0]=1;
    for (int i=c;i<=f;i++)
        if (dp2[i-c]) dp2[i]=1;
    for (int i=d;i<=f;i++)
        if (dp2[i-d]) dp2[i]=1;
    double ans=0;
    int p=a,q=0;
    for (int i=1;i<=f;i++)
        if (dp2[i])
        {
            int y=(100*i)/e;
            if ((100*i)%e) y++;
            if ((y>f)||(dp[y]==-1)) break;

            if ((dp[y]+i)<=f)
            {
                double r=100*i, t=(dp[y]+i);
                if ((r/t)>ans)
                {
                    ans=r/t;
                    p=dp[y]+i;
                    q=i;
                }
            }
        }
    printf ("%d %d",p,q);
    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int t = s.size();
	rep(i, t) {
		int c = s[i] - 'A';
		int u = (c + n) % 26;
		cout << (char)(u + 'A');
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;



void solve(int t)
{
	ll n;
	cin >> n;

	if (n >= 400 and n <= 599)
	{
		cout << 8 << endl;
		return;
	}
	if (n >= 600 and n <= 799)
	{
		cout << 7 << endl;
		return;
	}
	if (n >= 800 and n <= 999)
	{
		cout << 6 << endl;
		return;
	}
	if (n >= 1000 and n <= 1199)
	{
		cout << 5 << endl;
		return;
	}

	if (n >= 1200 and n <= 1399)
	{
		cout << 4 << endl;
		return;
	}
	if (n >= 1400 and n <= 1599)
	{
		cout << 3 << endl;
		return;
	}
	if (n >= 1600 and n <= 1799)
	{
		cout << 2 << endl;
		return;
	}
	if (n >= 1800 and n <= 1999)
	{
		cout << 1 << endl;
		return;
	}



}




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



	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3644
# coding: utf-8
from math import cos, sqrt, radians
A, B, H, M = map(int, input().split())
ln = M * 6
sh = H * 30 + 0.5 * M
theta = abs(ln - sh)
theta = min(theta, 360 - theta)
ans = sqrt(A**2 + B**2 - 2 * A * B * cos(radians(theta)))
print(ans)

Measured memory_bytes: 9440
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MOD 1000000007
#define f(i,j) f[(i)&1][(j)+4000]
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
typedef pair<int,int> pii; pii p[200005]; int f[2][8005], fac[8005], efac[8005], n, X, Y, K, Ans;
inline int exp(int s, int n=MOD-2){int a=1; for(; n; n&1 ? a = 1ll*a*s%MOD : 0, s = 1ll*s*s%MOD, n >>= 1); return a;}
inline int C(int n, int k){return 1ll*fac[n]*efac[k]%MOD*efac[n-k]%MOD;}
int main()
{
	n = read(); for(rint i = 1; i <= n; X = max(X,p[i].first=read()), Y = max(Y,p[i].second=read()), i++); K = (X+Y)<<1, sort(p+1,p+n+1);
	for(rint i = -X, j, q = n, t = 1; i <= X; i++)
	{
		for(j = -Y; j <= Y; j++) for(f(i,j) = f(i-1,j)+f(i,j-1), f(i,j)<MOD?:f(i,j)-=MOD; q && p[q]==pii(-i,-j); ++f(i,j)==MOD?f(i,j)=0:0, q--);
		for(; t <= n && p[t].first==i; Ans += f(i,p[t].second), Ans<MOD?:Ans-=MOD, t++);
	}	fac[0] = 1; for(rint i = 1; i <= K; fac[i] = 1ll*i*fac[i-1]%MOD, i++); efac[K] = exp(fac[K]); for(rint i = K; i; efac[i-1] = 1ll*i*efac[i]%MOD, i--);
	for(rint i = 1; i <= n; Ans -= C((p[i].first<<1)+(p[i].second<<1),p[i].first<<1), Ans<0?Ans+=MOD:0, i++); printf("%lld\n",500000004ll*Ans%MOD); return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//昇順
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i=0; i<n; i++)
    scanf("%d", a+i);
  qsort(a, n, sizeof(int), acs);
  int ans = 0, p = 0, cnt = 0;
  for (int i=0; i<n; i++) {
    if (p == a[i] && cnt == 0) {
      ans++;
      cnt++;
    } else if (p == a[i] && cnt == 1) {
      ans--;
      cnt--;
    } else {
      ans++;
      cnt = 1;
      p = a[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 892
package main
import (
        "bufio"
        "fmt"
        "os"
        "strings"
        "strconv"
)

//入力
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

//型変換
func Atoi2(c string) int {
  tmp, _ := strconv.Atoi(c)
  return tmp
}

func Itoa2(a []int) string{
  var str []string
  for _, i := range a{
    str = append(str,strconv.Itoa(i))
  }
  return strings.Join(str, " ")
}

func swap(a []int,x int,y int){
    tmp := a[x]
    a[x] = a[y]
    a[y] = tmp
}

func bubbleSort(a []int, n int) ([]int, int) {
  flag := true
  swapNum := 0
  for flag {
    flag = false
    for j:=n-1;j>0;j--{
      if a[j]<a[j-1]{
        swap(a,j,j-1)
        swapNum++
        flag =true
      }
    }
  }
    return a,swapNum
}

//main
func main() {
	length := Atoi2(nextLine())
	str := strings.Split(nextLine(), " ")
  var origin []int
  for _, c := range str{
    origin = append(origin, Atoi2(c))
  }
  output, num := bubbleSort(origin, length)
  fmt.Println(Itoa2(output))
  fmt.Println(strconv.Itoa(num))
}



Measured memory_bytes: 1128
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 501000;
const int MOD = 1e9 + 7;

int A, B, M;
int a[N], b[N];
int ans = 1e18;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> A >> B >> M;
    for (int i = 0; i < A; i++) cin >> a[i];
    for (int i = 0; i < B; i++) cin >> b[i];
    int xx = 1e18, yy = 1e18;
    for (int i = 0; i < A; i++) xx = min(xx, a[i]);
    for (int i = 0; i < B; i++) yy = min(yy, b[i]);
    ans = min(ans, xx + yy);
    while (M--)
    {
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans;
}


Measured memory_bytes: 5120
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

#define REP(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef pair<double,double> P;
int n;

void Koch(P p1,P p2,int n1){
		P s,t,u;
		s.first = (p1.first*2+p2.first)/3;
		s.second = (p1.second*2+p2.second)/3;
		u.first = (p1.first+2*p2.first)/3;
		u.second = (p1.second+2*p2.second)/3;
		t.first = (u.first-s.first)*0.5-(u.second-s.second)*0.8660254+s.first;
		t.second = (u.first-s.first)*0.8660254+(u.second-s.second)*0.5+s.second;
		if(n1 < n){
			Koch(p1,s,n1+1);Koch(s,t,n1+1);Koch(t,u,n1+1);Koch(u,p2,n1+1);
		}else{
			cout << p1.first << " " << p1.second << endl;
			cout << s.first << " " << s.second << endl;
			cout << t.first << " " << t.second << endl;
			cout << u.first << " " << u.second << endl;
		}
}

int main(){
	cin >> n;
	if(n!=0)Koch(P(0,0),P(100,0),1);
	else cout << "0 0" << endl;
	cout << "100 0" << endl;; 
}

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

int main(){
    int n, a_median, b_median, count_median;
    cin >> n;
    int a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    sort(a, a+n);
    sort(b, b+n);
    if(n % 2 == 0){
        a_median = (a[n/2 - 1] + a[n/2]);
        b_median = (b[n/2 - 1] + b[n/2]);
        count_median = (b_median - a_median) + 1;

    }else{
        a_median = a[(n-1)/2];
        b_median = b[(n-1)/2];
        count_median = (b_median - a_median) + 1;
    }
    cout << count_median << endl;

    return 0;

    /*
    2
    1 2
    2 3

    3
    100 100
    10 10000
    1 1000000000
    */
}

Measured memory_bytes: 4712
#include <stdio.h>
int main()
{
  int i, n, h;
  scanf("%d", &n);
  int s = 0;
  int now = 0;
  for(i = 0; i < n; i++)
  {
    scanf("%d", &h);
    if(h > now)
    {
      s += h - now;
    }
    now = h;
  }
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 128
n,c,k = list(map(int, input().split()))
ts = [int(input()) for i in range(n)]
ts.sort()
start = ts[0] + k
cnt = 0
ans = 1
for t in ts:
    # 乗れるので乗せる
    if t <= start and cnt < c:
        cnt += 1
    # 乗れるバスがないとき、次のバスを作る
    else:
        start = t+k
        cnt = 1
        ans += 1
print(ans)

Measured memory_bytes: 7420
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    repeat(i, n) cin >> a[i];
    
    for (int i = n - 1; i >= 0; i -= 2) cout << a[i] << " "; 
    for (int i = (n % 2 == 0 ? 0 : 1); i <= n - 1; i += 2) cout << a[i] << " ";
    return 0;
}   

Measured memory_bytes: 2944
import sys
S = input()
L = len(S)
if S[0] == S[1]:
    print(1, 2)
    sys.exit()
if L == 2:
    print(-1, -1)
    sys.exit()
ansL = -1
ansR = -1
for i in range(2, L):
    if S[i-1] == S[i]:
        ansL = i
        ansR = i+1
        break
    if S[i-2] == S[i]:
        ansL = i-1
        ansR = i+1
        break
print(ansL, ansR)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=1e5+10,inf=1e9+10,mod=1e9+7;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a); a=(a*a); b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }

char ch[N];
vector<ll> vec;

ll a[N],x,q,b,c,n,ans;
int main()
{
    iosks;
    cin>>n;
    xh1(0,n) cin>>x,a[x]++,ans+=x;
    cin>>q;
    while(q--) cin>>b>>c,a[c]+=a[b],ans+=(c-b)*a[b],a[b]=0,cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4344
#include <iostream>
#include <stack>
#include <algorithm>


int main(){
	std::stack<int> State;
	std::stack<std::pair<int, int> > Lake;
	char ch;
	int sum, s;
	for (int i = 0; (std::cin >> ch); i ++){
		if (ch == '\\')State.push(i);
		else if (ch == '/' and State.size() > 0){
			sum += s = i - State.top();
			while((Lake.size() > 0) and (State.top() < Lake.top().first)){
			s += Lake.top().second;
			Lake.pop();
			}
			Lake.push(std::make_pair(State.top(), s));
			State.pop();
		}
	}
	std::stack<int> ans;
	while (Lake.size() > 0){ans.push(Lake.top().second);Lake.pop();}
	std::cout << sum << "\n";
	std::cout << ans.size();
	while (ans.size() > 0){std::cout << " " << ans.top();ans.pop();}
	std::cout << std::endl;
}

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

int main() {
  string s;
  cin >> s;
  int a = 0, z = 0;
  
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) == 'A'){
      a = i;
      break; }
  }
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) == 'Z')
      z = i; }
  
  cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int,int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
ll h , w;
cin>>h>>w;
if ((h==1)||(w==1)) cout<<1<<endl;
 else cout<<((h*w)+1)/2<<endl;
return 0;
}



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            string str = Console.ReadLine();
            int[] a = new int[26];
            for (int i = 0; i < 4; i++)
                a[str[i] - 'A']++;
            if (a.Contains(1) || a.Contains(4)) Console.WriteLine("No");
            else Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 11220
#-*- coding = utf-8 -*-
x1, y1, x2, y2 = map(int, input().split())
x3 = int(x2 + (y1-y2))
y3 = int(y2 - (x1-x2))
x4 = int(x1 + (y1-y2))
y4 = int(y1 - (x1-x2))
print(x3, y3, x4, y4)
 

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


int main()
{
    int N,T;
    cin >> N >> T;
    
    vector<int> C(N);
    vector<int> t(N);
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        cin >> t[i];
    }
    
    int result = 9999;
    for (int i = 0; i < N; i++) {
        if (t[i] <= T) {
            if (C[i] < result) {
                result = C[i];
            }
        }
    }
    
    if (result != 9999) {
        cout << result << endl;
    }else{
        cout << "TLE" << endl;
    }
    
    return 0;
}

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

int main()
{
    Fast;
    long long t,n,m,i,j,k,x=0,y=0,z;
    cin>>n>>k;
    double a[n+5],b[n+5],c[n+5];
    c[0]=0.0;
    for(i=1;i<=n;i++){
        cin>>a[i];
        b[i]=(((a[i]+1)*a[i])/2)/a[i];
        if(i==1){
            c[i]=b[i];
        }
        else{
            c[i]=c[i-1]+b[i];
        }
    }
    double ans=0.0;
    for(i=1;i<=n;i++){
        //cout<<c[i]<<" ";
    }
    ///cout<<endl;
    for(i=k;i<=n;i++){

        double pp=c[i]-c[i-k];

        ans=max(ans,pp);
    }
    printf("%.8lf\n",ans);


}


Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    ll N; cin >> N;
    vector < ll > A(N),B(N),C(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    REP(i,N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    A.insert(A.begin(), 0);
    C.insert(C.begin(), 0);

    ll ans = 0;
    REP(i,N) {
        auto itr1 = upper_bound(A.begin(), A.end(), B[i] - 1);
        auto itr2 = lower_bound(C.begin(), C.end(), B[i] + 1);
        ll pre = (ll) (itr1 - A.begin()) - 1;
        ll nxt = N + 1 - (ll) (itr2 - C.begin());
        ans += pre * nxt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>
int main()
{
    int k,i,count=0;
    char a[20];
    scanf("%s",&a);
    k=strlen(a);
    for(i=0;i<k;i++)
    {
        if(a[i]=='o')
            count++;
    }
    if((15-k+count)>=8)
    printf("YES\n");
    else
         printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
s = input()
sukima = len(s)-1

for i in range(2**sukima):
  l = ['-']*sukima
  for j in range(sukima):
    if ((i >> j)&1):
      l[sukima-j-1] = '+'
  if eval(str(s[0]) + l[0] + str(s[1]) + l[1] +str(s[2]) + l[2] +str(s[3])) ==7:
    print(str(s[0]) + l[0] + str(s[1]) + l[1] +str(s[2]) + l[2] +str(s[3]) + '=7')
    exit()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string S; cin >> S;
    ll cnt1 = 0,cnt2 = 0;
    for(int i = 0; i < S.length();i++){
        S[i] -= '0';
        cnt1 += (i%2==0)==S[i];
        cnt2 += (i%2==1)==S[i];
    }
    res = min(cnt1,cnt2);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(void){
    long long int n, k, r, i, j, max=0, po=0, p, q, ii, jj;
    scanf("%lld", &n);
    long long int x[n], y[n];
    for(i=0; i<n; i++) scanf("%lld %lld", &x[i], &y[i]);
    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            po=0;
            p=x[i]-x[j];
            q=y[i]-y[j];
            for(ii=0; ii<n; ii++){
                for(jj=0; jj<n; jj++){
                    if(x[ii]-x[jj]==p&&y[ii]-y[jj]==q) po++;


                }
            }
            if(po>max) max = po;
        }
    }
    printf("%lld", n-max);
    
}

Measured memory_bytes: 128
#B
N = int(input())
A = []
B = []
C = []

for i in range(N):
    a,b,c = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    
ans = [0]*N
for i in range(N):
    a,b,c = A[i],B[i],C[i]
    if A.count(a) == 1:
        ans[i]+=a
    if B.count(b) == 1:
        ans[i]+=b
    if C.count(c) == 1:
        ans[i]+=c
        
    print(ans[i])






Measured memory_bytes: 5632