akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

typedef complex<double> Point, Vector;
typedef pair<Point, Point> Segment, Line;
typedef vector<Point> Polygon;

#define X real()
#define Y imag()
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

double dot(Vector a, Vector b){
    return a.X * b.X + a.Y * b.Y;
}

double cross(Vector a, Vector b){
    return a.X * b.Y - a.Y * b.X;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;

    return ON_SEGMENT;
}

namespace std{
    bool operator<(const Point &a, const Point &b){
        return !equals(a.X, b.X) ? a.X < b.X : a.Y < b.Y;
    }

    bool cmp_y(const Point &a, const Point &b) {
        return !equals(a.Y, b.Y) ? a.Y < b.Y : a.X < b.X;
    }
}

Polygon convexHull(Polygon ps){
    int n = ps.size();
    sort(ps.begin(), ps.end(), cmp_y);
    int k = 0;
    Polygon convex(n * 2);
    for(int i=0; i<n; i++){
        while(k >= 2 && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    for(int i=n-2, t=k; i>=0; i--){
        while(k > t && ccw(convex[k-2], convex[k-1], ps[i]) == CLOCKWISE) k--;
        convex[k++] = ps[i];
    }
    convex.resize(k-1);
    return convex;
}

int main(){
    int n; cin>>n;
    Polygon pol;
    while(n--){
        double x, y; cin>>x>>y;
        pol.emplace_back(x, y);
    }

    Polygon ans = convexHull(pol);

    cout << ans.size() << endl;
    for(auto i:ans){
        cout << i.X << " " << i.Y << endl;
    }
}


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

using namespace std;

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

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

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

    vector<int> r(n);
    for (int i = 0; i < n; i++) {
        r[i] = i + 1;
    }

    int idx = 0, p_idx, q_idx;
    do {
        bool r_eq = true;
        for (int i = 0; i < n; i++) {
            if (p[i] != r[i]) {
                r_eq = false;
            }
        }
        if (r_eq) {
            p_idx = idx;
        }

        bool q_eq = true;
        for (int i = 0; i < n; i++) {
            if (q[i] != r[i]) {
                q_eq = false;
            }
        }
        if (q_eq) {
            q_idx = idx;
        }

        idx++;
    } while (next_permutation(r.begin(), r.end()));

    cout << (p_idx > q_idx ? p_idx - q_idx : q_idx - p_idx) << endl;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define int ll
ll po(ll a, ll x, ll m) { if (x == 0) {return 1;} ll ans = 1; ll k = 1;  while (k <= x) {if (x & k) {ans = ((ans * a) % m);} k <<= 1; a *= a; a %= m; } return ans; }
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
int n, w;
int dp[101][N];
int a[101][2];
int rec(int pos, int v, int mx) {
    if (pos > n)
        return INT_MAX;
    if (pos == n) {
        if (v >= mx)
            return 0;
        else
            return INT_MAX;
    }
    int &ans  = dp[pos][v];
    if (ans != -1)
        return ans ;
    ans  = min(a[pos][0] + rec(pos + 1, v + a[pos][1], mx), rec(pos + 1, v, mx));
    //return ans ;
    if (ans > w)
        return INT_MAX;
    return ans ;
}

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

    ms(dp, -1);
    cin >> n >> w;
    int jokey = 0 ;
    forr(i, n) {
        forr(j, 2) {
            cin >> a[i][j];
        }
        jokey += a[i][1];
    }
    int ans  = rec(0, 0, 91);

    int l = 0;
    int e = jokey + 1;
    int as = 0;
    while (l <= e) {
        int mid  = (l + e) / 2;
        ms(dp, -1);
        int ans  = rec(0, 0, mid);
        ans  = (ans == INT_MAX) ? -1 : ans;
        if (l == e) {
            if (ans != -1)
                as  = max(as, mid);
            break;
        }
        if (ans != -1) {
            as = max(as, mid);
            l = mid + 1;
        }
        else {
            e =  mid - 1;
        }
    }
    cout << as << "\n";
    return 0;
}

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

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef unordered_set<int> us;
#define ft first
#define se second
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define endll "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    unsigned long long x;cin>>x;
    unsigned long long a=100,y=0;
    while(a<x){
        ++y;
        a*=1.01;
    }
    cout<<y<<endl;
}


Measured memory_bytes: 3608
# coding: utf-8
# Your code here!

if __name__ == '__main__':
    n=int(input())
    a_list=[int(x)-1 for x in input().split()]
    b_list=[int(x) for x in input().split()]
    c_list=[int(x) for x in input().split()]
    score=sum(b_list)
    pre_a=-100
    for a in a_list:
        if(a-pre_a==1):
            score+=c_list[pre_a]
        pre_a=a
    print(score)
  

Measured memory_bytes: 3060
# abc159_b.py
# https://atcoder.jp/contests/abc159/tasks/abc159_b

# B - String Palindrome /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 長さが奇数である文字列 Sが以下の条件をすべて満たすとき、Sは「強い回文」であるといいます。
#     Sは回文である。
#     Nを S の長さとするとき、S の 1 文字目から (N−1)/2文字目まで(両端含む)からなる文字列は回文である。
#     Sの (N+3)/2 文字目から N文字目まで(両端含む)からなる文字列は回文である。
# Sが強い回文かどうかを判定してください。

# 制約
#     Sは英小文字のみからなる
#     Sの長さは 3 以上 99以下の奇数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# S

# が強い回文ならば Yes 、 強い回文でないならば No と出力せよ。

# 入力例 1
# akasaka

# 出力例 1
# Yes

# Sは akasaka
# Sの 1 文字目から 3文字目までからなる文字列は aka
# Sの 5 文字目から 7文字目までからなる文字列は aka
# これらはすべて回文であるため、Sは強い回文です。

# 入力例 2
# level

# 出力例 2
# No

# 入力例 3
# atcoder

# 出力例 3
# No


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    n = int((len(S)-1)/2)

    if is_kaibun(S) is not True:
        return ['No']
    if is_kaibun(S[:n]) is not True:
        return ['No']
    if is_kaibun(S[-n:]) is not True:
        return ['No']

    return ['Yes']


def is_kaibun(s):
    t = ''.join(list(reversed(s)))
    if s == t:
        return True
    else:
        return False


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['akasaka']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['level']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['atcoder']
        lines_export = ['No']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef pair<pair<int, int>, int> P;
typedef long long ll;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;



int main() {
	ll i,j, k, l, m, n, sum, flag, cc, M, X,N,Y, Z, K, x, y, z,A,P;
	cin >> N;
	vector<pair<pair<string, ll>,int>>mise(N);
	vector<pair<string, int>>mise1(N);
	vector<pair<int, int>>mise2(N);
	REP(i,0,N){
		cin >> mise[i].first.first>>mise[i].first.second;
		mise[i].second = i;
		mise[i].first.second *= -1;
	
	}
	sort(mise.begin(), mise.end());
	string ss;
	i = 0;
	vector<ll>val;
	REP(i, 0, N) {
		cout <<1+mise[i].second<< endl;
	}
	return 0;
}








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

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 || b==1){
		if(a==b)
			cout<<"Draw"<<endl;
		else
			if(a==1)
				cout<<"Alice"<<endl;
			else
				cout<<"Bob"<<endl;
	}
	else
		if(a>b)
			cout<<"Alice"<<endl;
		else if(b>a)
			cout<<"Bob"<<endl;
		else
			cout<<"Draw"<<endl;
	return 0;
}

Measured memory_bytes: 3608
import           Control.Monad
import           Data.Array
import qualified Data.IntSet   as S

readInts :: IO [Int]
readInts = map read . words <$> getLine

readPair :: IO (Int, Int)
readPair = (\[x, y] -> (x, y)) <$> readInts

main :: IO ()
main = do
  (n, m) <- readPair
  hs <- listArray (1, n) <$> readInts
  abs <- replicateM m readPair
  print $ solve n hs abs

solve :: Int -> Array Int Int -> [(Int, Int)] -> Int
solve n hs abs = S.size $ foldr f (S.fromList [1..n]) abs
  where
    f (a, b) st = case compare (hs!a) (hs!b) of
      LT -> S.delete a st
      EQ -> S.delete a $ S.delete b st
      GT -> S.delete b st

Measured memory_bytes: 193992
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		for (int i = 1; i <= m; i++) {
			cout << i << " " << n - i + 1 << "\n";
		}
	}
	else {
		int diff = n - 1;
		vector<int> used(n);
		for (int i = 1; i <= m; i++) {
			used[n - diff] = 1;
			if (!used[diff]) {
				cout << i << " " << i + diff << "\n";
			}
			else {
				diff--;
				cout << i << " " << i + diff << "\n";
			}
			diff -= 2;
		}
	}
}

Measured memory_bytes: 3708
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  int remain = n/x;
  long long int total =0;
  total+=(remain*t);
  if(n%x!=0)
  {
      total+=t;
  }
  cout<<total<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int m,f,r,i,ii,iii,sum;
    while(cin>>m>>f>>r){
        if(m==-1 && r==-1 && f==-1){
            break;
        }
        sum=m+f;
        if(m==-1 || f==-1){
            cout<<"F"<<endl;
        }
        else if(sum>=80){
            cout<<"A"<<endl;
        }
        else if(sum>=65 && sum<80){
            cout<<"B"<<endl;
        }
        else if(sum>=50 && sum<65){
            cout<<"C"<<endl;
        }
        else if(sum>=30 && sum<50 && r<50){
            cout<<"D"<<endl;
        }
        else if(sum>=30 && sum<50 && 50<=r){
            cout<<"C"<<endl;
        }
        else if(sum<30){
            cout<<"F"<<endl;
        }

        
    }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;

int main(){
    string s;
    cin >> s;
    int a = (s[0] - '0')*10 + s[1] - '0';
    int b = (s[2] - '0')*10 + s[3] - '0';
    
    int yymm = 0, mmyy = 0;
    if(a<=12 && a>0)
        mmyy++;
    if(b<=12 && b>0)
        yymm++;

    if(yymm && mmyy){
        cout << "AMBIGUOUS";
    }else if(yymm){
        cout << "YYMM";
    }else if(mmyy){
        cout << "MMYY";
    }else{
        cout << "NA";
    }
    return 0;
}

Measured memory_bytes: 256
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$str = trim(fgets(STDIN));
$ok = true;
for($i = 0; $i < $a+$b+1; $i++){
    if($i == $a){
        if($str[$i] != "-")$ok = false;
    }else{
        if(!is_numeric($str[$i]))$ok = false;
    }
}
echo $ok ? "Yes" : "No";

Measured memory_bytes: 4728
s=input()
x=[0 for _ in range(26)]
if len(s)<26:
    for i in range(len(s)):
        x[ord(s[i])-ord('a')]=1
    for j in range(26):
        if x[j]==0:
            k=j
            break
    print("".join([s,chr(ord('a')+k)]))
elif s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
else:
    for i in range(2,27):
        if s[-i]<s[-i+1]:
            break
    for j in sorted(s[-i+1:]):
        if j>s[-i]:
            break
    print(s[:-i]+j)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
signed main() {
	ll n, m, a = 0, b = 0, cnt = 0, ans = 0; cin >> n >> a >> b;
	ans += (n / (a + b)) * a; n %= a + b;
	cout << ans + min(n, a) << endl;
	cin >> n; return 0;
}

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

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

void comb(vector<ll> &c, ll n){
  c[0] = 1;
  rep1(i,n){
    c[i] = mu(c[i - 1], mu(n + 1 - i, dv(1,i)));
  }

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

  ll x,y;
  cin >> x >> y;
  if((2LL*y-x)%3LL!=0LL || (2LL*x-y)%3LL!=0LL){
    cout << 0 << endl;
    return 0;
  }
  
  ll l=(2LL*y-x)/3LL;
  ll k=(2LL*x-y)/3LL;
  if(l<0 || k <0){
    cout << 0 << endl;
    return 0;
  }
  ll u=1;
  ll dk,dl;
  dk=dl=1;
  rep1(i,l+k) u = mu(u,i);
  rep1(i,l) dl=mu(dl,i);
  rep1(i,k) dk=mu(dk,i);
  cout << dv(dv(u,dk),dl) << endl;
  
  return 0;
    

}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

void coutbits(unsigned n) {
	for (int i = 31; i >= 0; i--) {
		cout << (((n >> i) & 1) ? 1 : 0);
	}
}

void solve() {
	unsigned a, b; cin >> a >> b;
	coutbits(a & b); cout << endl;
	coutbits(a | b); cout << endl;
	coutbits(a ^ b); cout << endl;
}

int main() {

	solve();

	return 0;
}



Measured memory_bytes: 3080
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int h,w,ans=0;
vector<string> a;
vector<vector<int>> d;
queue<P> que;
vector<int> dy={1,-1,0,0},dx={0,0,1,-1};

void bfs(){
    rep(i,h){
        rep(j,w){
            if (a[i][j]=='#') {
                que.push(P(i,j));
                d[i][j]=0;
            }
        }
    }
    while (!que.empty()){
        int y=que.front().first,x=que.front().second;
        que.pop();
        rep(i,4){
            if (y+dy[i]<0 or y+dy[i]>h-1 or x+dx[i]<0 or x+dx[i]>w-1) continue;
            if (d[y+dy[i]][x+dx[i]]!=-1) continue;
            d[y+dy[i]][x+dx[i]]=d[y][x]+1;
            que.push(P(y+dy[i],x+dx[i]));
        }
        
    }
}

void solve(){
    cin >> h >> w;
    a.resize(h,"");
    d.resize(h,{});
    rep(i,h){
        d[i].resize(w,-1);
    }
    rep(i,h){
        cin >> a[i];
        //cout << a[i] << endl;
    }
    bfs();
    rep(i,h){
        rep(j,w){
            ans=max(ans,d[i][j]);
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
int main()
{
  // お札数, 合計金額
  long long N, Y;
  cin >> N >> Y;
  // 1万円札の枚数
  for (long long lTenTh = 0; lTenTh <= N; lTenTh++)
  {
    // 5千円札の枚数
    for (long long lFifTh = 0; lFifTh <= (N - lTenTh); lFifTh++)
    {
      // 千円札は1万円札と5千円札の枚数を差っ引いた枚数で出す
      if (((10000 * lTenTh) + (5000 * lFifTh) + (1000 * (N - lTenTh - lFifTh))) == Y)
      {
        // 枚数に対する合計金額が一致したら終了
        cout << lTenTh << " " << lFifTh << " " << (N - lTenTh - lFifTh) << endl;
        return 0;
      }
    }
  }
  // 一致しない
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
/*#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};*/


int dp[1010][1010];
int N;
string s,t;

void lcs(string s,string t){
	memset(dp,0,sizeof(dp));
	int n=s.size(),m=t.size();
	rep(i,0,n){
		rep(j,0,m){
			if(s[i]==t[j]){
				dp[i+1][j+1]=dp[i][j]+1;
			}else{
				dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
			}
		}
	}
	cout<<dp[n][m]<<endl;
};
signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>N;
    rep(i,0,N){
        cin>>s>>t;
        lcs(s,t);
    }
   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 11212
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String b = sc.next();
    	sc.close();
    	switch(b){
    	case "A":
    		System.out.println("T");
    		break;
    	case "T":
    		System.out.println("A");
    		break;
    	case "C":
    		System.out.println("G");
    		break;
    	case "G":
    		System.out.println("C");
    		break;
    	default :
    		System.out.println("err");
    	}
    }
}

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

int main() {
  ll 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];
    }
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 50;

vector<int> tree[N_MAX+1];
vector<Pii> edges;
bool in_path[N_MAX+1][N_MAX+1][N_MAX];
vector<int> nodes[2];

int count_bit(unsigned  int n) {
    n = (n &  0x55555555) + (n >>  1  &  0x55555555);
    n = (n &  0x33333333) + (n >>  2  &  0x33333333);
    n = (n &  0x0f0f0f0f) + (n >>  4  &  0x0f0f0f0f);
    n = (n &  0x00ff00ff) + (n >>  8  &  0x00ff00ff);
    return (n &  0x0000ffff) + (n >>  16  &  0x0000ffff);
}

void dfs(int a, int par, int nodes_i) {
    nodes[nodes_i].push_back(a);
    for(int child: tree[a]) {
        if(child == par) continue;
        dfs(child, a, nodes_i);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, a, b;
    cin >> n;
    for(int i=0;i<n-1;++i) {
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
        edges.emplace_back(a, b);
    }

    // a -> b に行くときにi番目の辺を通るか？
    fill_n(in_path[0][0], (N_MAX+1)*(N_MAX+1)*N_MAX, false);
    for(int i=0;i<n-1;++i) {
        tie(a, b) = edges[i];
        in_path[a][b][i] = true;
        in_path[b][a][i] = true;
        dfs(a, b, 0);
        dfs(b, a, 1);
        for(int n0: nodes[0]) {
            for(int n1: nodes[1]) {
                in_path[n0][n1][i] = true;
                in_path[n1][n0][i] = true;
            }
        }
        nodes[0].clear();
        nodes[1].clear();
    }

    int m;
    cin >> m;
    vector<int> u(m), v(m);
    for(int i=0;i<m;++i) {
        cin >> u[i] >> v[i];
    }

    // 条件に当てはまらない物をかぞえあげる
    ll ans_inv = 0LL;
    for(int i=1;i<(1<<m);++i) {
        vector<bool> is_free(n-1, true);
        for(int j=0;j<m;++j) {
            if(!(i & (1 << j))) continue;
            for(int k=0;k<n-1;++k) {
                if(in_path[u[j]][v[j]][k]) {
                    is_free[k] = false;
                }
            }
        }

        ll tmp = 1LL;
        for(int k=0;k<n-1;++k) {
            if(is_free[k]) tmp *= 2LL;
        }

        // 立ってるビットの数で包除原理の符号を決める
        if(count_bit(i) % 2) {
            ans_inv += tmp;
        } else {
            ans_inv -= tmp;
        }
    }

    ll ans = 1LL;
    for(int i=0;i<n-1;++i) {
        ans *= 2LL;
    }
    ans -= ans_inv;

    cout << ans << endl;
}


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



int main() {
	
	
	ll n, d; cin >> n >> d;
	ll D = d * d;

	// cout << d*d << endl;
	
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	
	
	int ans = 0;
	rep(i,n){
		ll d2 = a[i]*a[i] + b[i]*b[i];
		if(d2 <= D) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

#define ll long long

using namespace std;

const int inf = 1e9 + 7;


ll ans = inf, cur;

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

    for (int i = 0; i < n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);

        cur += a;

        if (a > b)
            ans = min(ans, b * 1LL);
    }

    if (ans == inf)
    {
        cout << 0;
        return 0;
    }
    cout << cur - ans;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int main()
{
    int A, B;
    string S;
    cin >> A >> B >> S;
    REP(i,S.length()) {
        if((i == A && S[i] != '-') || (i != A && S[i] == '-')){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

const int Nmax = 1e5 + 5;

vector<int> path, v[Nmax], p1, p2;
int x, y, i, n, dist[Nmax];

void dfs(int node)
{
    for(auto it : v[node])
        if(!dist[it])
        {
            dist[it] = dist[node] + 1;
            dfs(it);
        }
}

int farthest(int node)
{
    memset(dist, 0, sizeof(dist));
    dist[node] = 1;
    dfs(node);
    int i, ans = 0;
    for(i=1; i<=n; ++i)
        if(dist[i] > dist[ans]) ans = i;
    return ans;
}

bool find_path(int node, int x, int dad = 0)
{
    bool ok = (node == x);
    for(auto it : v[node])
        if(it != dad)
            if(find_path(it, x, node))
                ok = 1;
    if(ok) path.push_back(node);
    return ok;
}

vector<int> solve()
{
    vector<int> ans;
    int i, j, p = 1;

    for(i=0; i<path.size(); ++i)
    {
        for(j=1; j<=path[i]; ++j)
            ans.push_back(p + j);
        ans.push_back(p);
        p += path[i] + 1;
    }
    return ans;
}

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);

    cin >> n;
    for(i=1; i<n; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    x = farthest(1);
    y = farthest(x);
    find_path(x, y);

    for(i=1; i<path.size()-1; ++i)
        path[i] = v[path[i]].size() - 2;
    path.front() = path.back() = 0;

    int sum = path.size();
    for(auto node : path) sum += node;

    if(sum != n)
    {
        cout << "-1\n";
        return 0;
    }

    p1 = solve();
    reverse(path.begin(), path.end());
    p2 = solve();

    for(i=0; i<n; ++i)
        if(p1[i] > p2[i])
        {
            swap(p1, p2);
            break;
        }
        else if(p1[i] < p2[i]) break;

    for(auto val : p1) cout << val << ' ';
    return 0;
}


Measured memory_bytes: 15736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int N, M;
  while(cin >> N >> M, N){
    vector<int> P(N);
    for(int i=0;i<N;i++)cin >> P[i];
    vector<int> cand;
    for(int i=0;i<N;i++)for(int j=i;j<N;j++)if(P[i] + P[j] <= M){
      cand.push_back(P[i] + P[j]);
    }
    for(int x : P)if(x <= M)cand.push_back(x);
    sort(cand.begin(), cand.end());
    int j = cand.size() - 1;
    int res = cand.back();
    for(int i=0;i<cand.size();i++){
      while(j >= 0 && cand[i] + cand[j] > M)--j;
      if(j >= 0){
        res = max(res, cand[i] + cand[j]);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 6740
N = int(input())
B = list(map(int,input().split()))
A = [0 for _ in range(N)]
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1, N-1):
    A[i] = min(B[i-1],B[i])

print(sum(A))

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

int main(){
  string S;
  cin >> S;
  
  int start;
  if ((int)(S.length()) % 2 == 1){
    start = (int)(S.length()) - 1;
  }
  else{
    start = (int)(S.length()) - 2;
  }
  
  for (int i = start; i > 0; i -= 2){
    int num = 1;
    while (num <= i / 2){
      if (S.at(num - 1) != S.at(num - 1 + i / 2)){
        break;
      }
      num++;
    }
    
    if (num == i / 2 + 1){
      cout << i << endl;
      exit(0);
    }
  }
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int l, r;
  int k; cin >> k;
  cin >> l >> r;
  int a = r / k;
  int b = (l - 1) / k;
  if(a == b) cout << "NG\n";
  else cout << "OK\n";
  return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
   char  c[4][4];
   int i,j;

   for(i=0;i<3;i++)
    scanf("%c%c%c%c",&c[i][0],&c[i][1],&c[i][2],&c[i][3]);

   printf("%c%c%c\n",c[0][0],c[1][1],c[2][2]);
   
   return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld a, b;
	cin >> a;
	cin >> b;
	lld B[3];
	B[0] = a+b;
	B[1] = a-b;
	B[2] = a*b;
	sort(B,B+3);
	cout << B[2];
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Comparator.*;
class Restaurant {
    private String city;
    private int score;
    private int index;
    public Restaurant(String city, int score, int index) {
        this.city = city;
        this.score = score;
        this.index = index;
    }
    public String getCity() {return this.city;}
    public int getScore() {return this.score;}
    public int getIndex() {return this.index;}
}
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();        
        List<Restaurant> rstList = new ArrayList<>();
        for(int i = 1; i <= N; i++) {
            Restaurant rst = new Restaurant(stdIn.next(), -stdIn.nextInt(), i);
            rstList.add(rst);
        }
        rstList.sort(comparing(Restaurant::getCity).thenComparing(Restaurant::getScore));
        for(Restaurant rst : rstList) {
            System.out.println(rst.getIndex());
        }
    }
}

Measured memory_bytes: 28116
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    ll x=0,y=0,z=0,n,m,h,k=0,w,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n >> x;
    VI sum(n+1);
    sum[0]=0;
    rep(i,n){
        cin >> y;
        sum[i+1] = sum[i] + y;
    }
    rep(i,n+1){
        if(sum[i] <= x){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long k, a, b; cin >> k >> a >> b;
  if (b - a <= 2 || a - 1 >= k) {
    cout << k + 1 << '\n';
    return 0;
  }
  long long kaisu = a-1, now = a;
  now += (b - a) * ((k - kaisu) / 2);
  if ((k-kaisu)&1) ++now;
  cout << now << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        
        int[] left = new int[n];
        for (int i = 0; i < n; i++) {
            left[i] = sc.nextInt();
        }
        int[] right = new int[m];
        for (int i = 0; i < m; i++) {
            right[i] = sc.nextInt();
        }
        
        long[] suml = new long[n+1];
        for (int i = 1; i <= n; i++) {
            suml[i] = suml[i-1] + left[i-1];
        }
        
        long[] sumr = new long[m+1];
        for (int i = 1; i <= m; i++) {
            sumr[i] = sumr[i-1] + right[i-1];
        }
        
        long tmpl = 0;
        int tmpi = -1;
        for (int i = 0; i < n; i++) {
            if (tmpl + left[i] <= k) {
                tmpl += left[i];
            } else {
                break;
            }
            tmpi = i;
        }
        
        int max = 0;
        for (int i = tmpi; i >= -1; i--) {
            long remain = k - tmpl;
            int j = upperBound(sumr, remain);
            j-=2;
            // System.out.println(remain + " " +i +  " "+ j);
            
            max = Math.max(max, i + 1 + j + 1);
            // System.out.println(max);
            
            if (i == -1) break;
            tmpl -= left[i];
        }
        System.out.println(max);
    }
    
    public static int upperBound(long[] array, long target) {
        // 初めてのtarget超過のindexを返す
        // {1, 3, 3, 7} target: 3 -> 3
        
        int left = 0;
        int right = array.length;
        
        while (left < right) {
            int center = (left + right) / 2;
            if (array[center] <= target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
}


Measured memory_bytes: 62860
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
template<class T>void mini(T &a,T b){a=min(a,b);}
template<class T>void maxi(T &a,T b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
void addin(){}template<class Head,class...Tail>void addin(vector<Head>&vechead,Tail&&...tail){in(Head,head);vechead.emb(head);addin(forward<Tail>(tail)...);}
template<class C>void vecout(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}

#define int int64_t
// #define double long double


signed main(){
  IOS;

  in(int,a,b);
  string ans;
  if(a>0) ans="Positive";
  elif(a<=0&&0<=b) ans="Zero";
  else ans= ((b-a)%2==0)?"Negative":"Positive";
  out(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

import java.util.Arrays;
import java.util.ArrayList;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		System.out.println(T/A * B);
	}
}	

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,x=0,mxi=0;
	cin >> N;
	char s[N];
	cin >> s;
	for(int i=0;i<N;i++){
		if(s[i]=='I'){
			x++;
			mxi= max(mxi,x);
		}else{
			x--;
		}
	}
	cout << mxi << endl;
	return 0;
}

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

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

#define EPS (1e-5)

typedef struct{
	double x,y,z;
}P;

int main(void){
	int i,j,k;
	int n,m;
	double a,b,c;
	P p[30];

	scanf("%d",&n);
	while(n--){
		scanf("%lf%lf%lf%d",&a,&b,&c,&m);
		rep(i,m) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);

		rep(i,m){
			rep(j,m){
				rep(k,m){
					if(i == j || i == k || j == k) continue;

					double ta = sqrt( pow(p[j].x - p[i].x, 2) +
														pow(p[j].y - p[i].y, 2) + 
														pow(p[j].z - p[i].z, 2));
					double tb = sqrt( pow(p[k].x - p[j].x, 2) +
														pow(p[k].y - p[j].y, 2) + 
														pow(p[k].z - p[j].z, 2));
					double tc = sqrt( pow(p[i].x - p[k].x, 2) +
														pow(p[i].y - p[k].y, 2) + 
														pow(p[i].z - p[k].z, 2));

					if(a / b - ta / tb < EPS &&
						 b / c - tb / tc < EPS &&
						 c / a - tc / ta < EPS)
						printf("%d %d %d\n",k+1,i+1,j+1);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = input()
l = list(s)
#n = len(l)
i = 0
j = n-1
cnt = 0
while(i < j):
    if l[i] == "W" and l[j] == "R":
        l[j] = 'W'
        l[i] = 'R'
        i = i+1
        j = j-1
        cnt = cnt+1
        continue

    if l[i] == "R":
        i = i+1

    if l[j] == "W":
        j = j-1


while(len(l) > 0):
    if l[-1] == "W":
        l.pop()
        continue

    if l[-1] == "R":
        break

k = "".join(l)
print(k.count("W")+cnt)

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

int main(){
    int N, M, tmp0, ac = 0, wa = 0;
    string tmp1;
    cin >> N >> M;
    int WA[N];
    bool record[N];
    for(int i = 0; i < N; ++i){
        record[i] = 0;
        WA[i] = 0;
    }
    for(int i = 0; i < M; ++i){
        cin >> tmp0 >> tmp1;
        --tmp0;
        if(!record[tmp0]){
            if(tmp1 == "WA"){
                ++WA[tmp0];
            }else{
                ++ac;
                wa += WA[tmp0];
                record[tmp0] = 1;
            }
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}

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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(size_t, N);

    vector<intmax_t> d(N);
    input(d);

    intmax_t res = 0;
    rep(i, N) reps(j, i + 1, N - 1) {
        res += d[i] * d[j];
    }

    output(res);

    return 0;
}


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

using namespace std;

int main()
{
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for(int i=0;i<N;i++)
    cin >> x[i];
  
  for(int i=0;i<M;i++)
    cin >> y[i];

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  if( x.back() < y.front()  && X<y.front() && Y>x.back())
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


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

int main() {
	int a, b, c, count;
	cin>>a>>b>>c;
	if (a == b && a == c)
	    count = 1;
	else if (b != c && a == b)
	    count = 2;
	else if (b != c && a == c)
	    count = 2;
	else if (b == c)
	    count = 2;
	else
	    count = 3;
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<ll> x(n),y(m);
    for(auto& xin:x) cin >> xin;
    for(auto& yin:y) cin >> yin;
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    ll x_sum = 0,y_sum = 0;
    for(int i = 0; i < n;i++){
        (x_sum += ((i*x[i])%MOD - (n-(i+1))*x[i])%MOD + MOD)%=MOD;
    }
    for(int i = 0; i < m;i++){
        (y_sum += ((i*y[i])%MOD - (m-(i+1))*y[i])%MOD + MOD)%=MOD;
    }
    ll res = x_sum * y_sum;
    res%=MOD;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))

mins = [a[0]]
for i in range(1, N):
    mins.append(min(a[i], mins[i-1]))
    
mx = -10**12
for j in range(1, N):
    mx = max(mx, a[j] - mins[j-1])
print(mx)

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

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

    int time=0;
    for(int i=0; i<60; i++){
        while(time < (i+1)*60){
            if(time%60 <= c && c <= time%60+a){
                time += c - time%60;
                cout << time << endl;
                return 0;
            }else{
                time += a+b;
            }
        }
    }
    cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 3100