akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1000000007;

//mod冪乗
ll mp(ll a,ll b) {
  ll ans = 1;
  while (b) {
  if (b % 2)
    ans *= a;
    a *= a;
    a %= MOD;
    ans %= MOD;
    b /= 2;
  }
  return ans;
}

//mod割り算
ll moddiv(ll a,ll b) {
  a %= MOD;
  return (a*mp(b, MOD - 2)) % MOD;
}

int main(){
  ll H,W,A,B,ans=0,cnta=1,cntb=1;
  cin>>H>>W>>A>>B;
  vector<ll> XB(H,1);
  vector<ll> XW(H,1);
  for(int i=1;i<H;i++){
    cnta*=moddiv(B+i-1,i);
    cnta%=MOD;
    cntb*=moddiv(W-B+i-1,i);
    cntb%=MOD;
    XB[i]=cnta;
    XW[H-1-i]=cntb;
    //cout<<cnta<<" "<<cntb<<endl;
  }
  for(int i=0;i<H-A;i++){
    ans+=XB[i]*XW[i];
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();

        String result;
        if(c > b && b > a) {
            result = "Yes";
        } else {
            result = "No";
        }

        System.out.println(result);
    }

}

Measured memory_bytes: 17160
/*
 * FileName:     A_fix
 * CreatedDate:  2020-02-22 19:50:24 +0900
 * LastModified: 2020-02-24 18:47:09 +0900
 */

#include <stdio.h>
#include"stdlib.h"

#define inf 10000000000
int min(int s, int t){
    if(s<t){
        return s;
    }
    else{
        return t;
    }
}
int main(void){
    int N;
    scanf("%d",&N);
    int i,h[N],dp[N];
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
        dp[i] = inf;
    }
    dp[0] = 0;
    for(i=0;i<N-2;i++){
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    dp[i+1] = min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    printf("%d\n",dp[N-1]);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
#define NIL -1
#define MAX 100005
typedef long long ll;
using namespace std;

struct Node { int p, l, r;};

Node T[MAX];
int n,D[MAX],H[MAX],pmax=0;

int rec(int m,int p){
  D[m]=p;
  pmax=max(p,pmax);
  if(T[m].l!=NIL)rec(T[m].l,p+1);
  if(T[m].r!=NIL)rec(T[m].r,p+1);
}

int dep(int u){
  int h1=0,h2=0;
  if(T[u].l!=NIL)h1=dep(T[u].l)+1;
  if(T[u].r!=NIL)h2=dep(T[u].r)+1;
  return H[u]=(h1 > h2 ? h1 : h2);
}

int main(){
  int l,r,id;
  cin >> n;
  r(i,n)T[i].p=NIL;
  T[NIL].l=T[NIL].r=NIL;
  r(i,n){
    cin >> id;
    cin >> T[id].l >> T[id].r;
    if(T[id].l!=NIL)T[T[id].l].p=id;
    if(T[id].r!=NIL)T[T[id].r].p=id;
  }
  
  r(i,n){
    if(T[i].p==NIL)r=i;
  }
  rec(r,0);
  dep(r);
  
  r(i,n){
  cout<<"node "<<i<<": parent = "<<T[i].p<<", sibling = ";
    if(T[T[i].p].l==i)cout<<T[T[i].p].r;
    else cout<<T[T[i].p].l;
    cout<<", degree = ";
    if(T[i].l==NIL&&T[i].r==NIL)cout<<0;
    else if(T[i].l!=NIL&&T[i].r!=NIL)cout<<2;
    else cout<<1;
    cout<<", depth = "<<D[i] <<", height = "<<H[i]<<", ";
    if(T[i].p==NIL)cout<<"root"<<endl;
    else if(T[i].l==NIL&&T[i].r==NIL)cout<<"leaf"<<endl;
    else cout<< "internal node"<<endl;
  }
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRRAY = 1;
static const int BLACK = 2;

int n;
int M[100][100];

int dijkstra(){
  int u,minv,i,v;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(M[u][v] != INFTY && color[v] != BLACK){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRRAY;
	}
      }
    }
  }
    for(i=0;i<n;i++){
      cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main(){
  int i,j;

  cin >> n;
 
 for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

 int k,c,u,v;
 for(i=0;i<n;i++){
   cin >> u >> k;
   for(j=0;j<k;j++){
     cin >> v >> c;
     M[u][v]=c;
   }  
     }
 dijkstra();
 
 return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <string.h>
              
int beta (int x ) { 
  return (x > 0) ? x : -1*x; 
}             
              
int main () {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  if(beta(a-c) <= d || (beta(a-b) <= d && beta(b-c) <= d)) {
    std::cout << "Yes" << std::endl;  
  }           
  else {   
    std::cout << "No" << std::endl;  
  }           
  return 0;                                                                     
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in); 
		int n=sc.nextInt();
		int[][] graph=new int[n+1][n+1];
		for(int i=0;i<n;i++){
			int u=sc.nextInt();
			int k=sc.nextInt();
			for(int j=0;j<k;j++){
			int v=sc.nextInt();
			graph[u][v]++;
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(j==n) System.out.println(graph[i][j]);
				else System.out.print(graph[i][j]+" ");
			}
		}
	}
}

Measured memory_bytes: 23908
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	m := make([]int, 3)
	for i := 0; i < n; i++ {
		m[score(a, b, getNextInt(scanner))]++
	}
	ans := n
	for i := 0; i < 3; i++ {
		if ans > m[i] {
			ans = m[i]
		}
	}
	fmt.Fprintln(writer, ans)
}

func score(a, b, p int) int {
	if p <= a {
		return 0
	}
	if p <= b {
		return 1
	}
	return 2
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<iostream>

using namespace std;

struct Node {
	int key;
	Node* prev, * next;
};

Node* nil;

//初期化
void init() {
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

//挿入
void Insert(int key) {
	Node *x = (Node*)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

void PrintList() {
	Node *r = nil->next;
	int i = 0;
	while (true) {
		if (r == nil) {
			break;
		}
		if (i != 0) {
			cout << " ";
		}
		cout << r->key;
		r = r->next;
		i += 1;
	}
	cout << endl;
}

void  deleteNode(Node *t) {
	if (t == nil) {
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deletekey(int x) {
	Node* cl;
	cl = nil->next;
	while (cl!=nil && cl->key!=x) {
		cl = cl->next;
	}
	deleteNode(cl);
}


int main() {
	init();
	int n;
	scanf("%d", &n);
	char c[20];
	int key;
	for (int i = 0; i < n; i++) {
		cin >> c;
		if (c[0] == 'i') {
			cin >> key;
			Insert(key);
		}
		else if (c[0] == 'd') {
			
			if (c[6] == 'F') {
				deleteFirst();
			}
			else if (c[6] == 'L') {
				deleteLast();
			}
			else {
				cin >> key;
				deletekey(key);
			}


		}
	}
	PrintList();
	
}


Measured memory_bytes: 34408
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
    int n,x,t;
    cin>>n>>x>>t;
    int ans = (n/x)*t;
    if(n%x)
       ans += t;
    cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  /* int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3648
package main
import (
  "fmt"
  "math"
)
func createPrimes(n int) []bool {
  r := make([]bool, n+1)
  for i := 2; i <= n; i++ {
    r[i] = true
  }
  root := int(math.Sqrt(float64(n)))
  for i := 2; i <= root; i++ {
    for j := i+1; j <= n; j++ {
      if r[j] && j%i == 0 {
        r[j] = false
      }
    }
  }
  return r
}
func main() {
  var n int
  fmt.Scan(&n)
  ps := createPrimes(n)
  result := 1
  for i := 2; i <= n; i++ {
    if !ps[i] {
      continue
    }
    cnt := 0
    for j := i; j <= n; j++ {
      num := j
      for 0 < num && num%i == 0 {
        num /= i
        cnt++
      }
    }
    result *= cnt+1
    result %= 1000000007
  }
  fmt.Println(result)
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

void solve() {
    ll a, b, c; cin >> a >> b >> c;
    ll tak, aok;
    tak = max(0LL, a-c);
    aok = tak > 0LL ? b : max(0LL, b - (c - a));
    cout << tak << " " << aok;
}

signed main() {
    solve();
    return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int X[100000];
    for (int i = 0; i < M; i++){
        cin >> X[i];
    }
    sort(X, X + M);

    int dif[100000];
    for (int i = 0; i < M - 1; i++){
        dif[i] = abs(X[i + 1] - X[i]);
    }
    sort(dif, dif + M - 1);
    int total = 0;
    for (int i = 0; i < M - 1 - N + 1; i++){
        total += dif[i];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
using namespace std;
int main(){
    string o,e;
    cin >> o >> e;
    string ans="";
    for(int i=0;i<e.length();i++){
        ans+=o.substr(i,1);
        ans+=e.substr(i,1);
    }
    if(o.length()-e.length()==1){
        ans+=o.substr(o.length()-1,1);
    }
    cout << ans << endl;
}

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

int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if((b-a)>f){
		cout<<":(";
		return 0;
	}
	if((c-a)>f){
		cout<<":(";
		return 0;
	}
	if((d-a)>f){
		cout<<":(";
		return 0;
	}
	if((e-a)>f){
		cout<<":(";
		return 0;
	}
	if((c-b)>f){
		cout<<":(";
		return 0;
	}
	if((d-b)>f){
		cout<<":(";
		return 0;
	}
	if((e-b)>f){
		cout<<":(";
		return 0;
	}
	if((d-c)>f){
		cout<<":(";
		return 0;
	}
	if((e-c)>f){
		cout<<":(";
		return 0;
	}
	if((e-d)>f){
		cout<<":(";
		return 0;
	}
	cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
#include<math.h>
using namespace std;
//char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int main(){
int k,s;cin>>k>>s;int ans=0;
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
	int m=s-(i+j);
	if((i+j+m)==s&&m>=0&&m<=k)ans++;
}}
cout<<ans<<endl;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define inf 1e9

using namespace std;
typedef pair<int, int> P;

struct SegTree{
	int size;
	vector<P> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = make_pair(inf, i);
	}
	
	void update(int i, P val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}

	P query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return make_pair(inf, inf);
		if(a <= l && r <= b) return seg[k];
		P lval = query(a, b, k*2, l, (l+r)/2);
		P rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	P query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

int n, k;
string s, t;
bool Left[500005];
int sumB[500005], sumW[500005];
int dp[500005];
SegTree segW(19), segB(19);

int main(void)
{
	cin >> n >> k;
	cin >> s >> t;
	s = "#" + s, t = "#" + t;
	
	for(int i = 1; i <= n; i++){
		if(t[i] != t[i-1]) Left[i] = true;
	}
	for(int i = 1; i <= n; i++){
		sumB[i] = sumB[i-1];
		if(Left[i] && t[i] == 'B') sumB[i]++;
		sumW[i] = sumW[i-1];
		if(Left[i] && t[i] == 'W') sumW[i]++;
	}
	
	segB.init(), segW.init();
	segB.update(0, make_pair(0, 0)), segW.update(0, make_pair(0, 0));
	
	for(int i = 1; i <= n; i++){
		if(s[i] == t[i]) dp[i] = dp[i-1];
		else if(t[i] == 'W'){
			P p = segW.query(max(0, i-k), i-1);
			dp[i] = dp[p.second] + sumB[i] - sumB[p.second] + 1;
		}
		else if(t[i] == 'B'){
			P p = segB.query(max(0, i-k), i-1);
			dp[i] = dp[p.second] + sumW[i] - sumW[p.second] + 1;
			
		}
		if(i < n && t[i+1] == 'W' && s[i+1] == 'B') segW.update(i, make_pair(dp[i]-sumB[i], i));
		if(i < n && t[i+1] == 'B' && s[i+1] == 'W') segB.update(i, make_pair(dp[i]-sumW[i], i));
	}
	
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 26804
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    var s: string = "";
    var ans: string = "";
    // init
    s = input.shift();
    // solve
    function isreverse(s: string) {
        return s.split("").reverse().join("") == s;
    }
    if (isreverse(s) &&
        isreverse(s.substring(0, (s.length - 1) / 2)) &&
        isreverse(s.substring((s.length + 3) / 2 - 1, s.length))) {
        ans = "Yes";
    } else {
        ans = "No";
    }

    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        var input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29652
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W;
    cin >> H >> W;
    map<int,int>Mp;
    multiset<int>st;
    for(int i = 0; i < W; i++) {
        Mp[i] = i;
        st.insert(0);
    }
    for(int i = 0; i < H; i++) {
        int A,B;
        cin >> A >> B;
        A--;B--;
        auto it = Mp.lower_bound(A);
        int mx = -1;
        while (it != Mp.end() && it->first <= B+1) {
            st.erase(st.find(it->first-it->second));
            mx = max(mx,it->second);
            Mp.erase(it++);
        }
        if(B+1 != W && mx != -1) {
            Mp[B+1] = mx;
            st.insert(B+1-Mp[B+1]);
        }
        if(st.size() == 0) {
            cout << -1 << endl;
        }
        else {
            cout << *st.begin()+i+1 << endl;
        }
    }
}

Measured memory_bytes: 25476
otoshidama = list(map(int,input().split()))
flg = True
for i in range(otoshidama[0]+1):
    yukichi =i
    for n in range(otoshidama[0]-yukichi+1):
        higuchi =n
        noguchi = otoshidama[0]-yukichi - higuchi

        if 10000*yukichi+5000*higuchi+1000*noguchi==otoshidama[1]:
            print("{} {} {}".format(yukichi,higuchi,noguchi))
            flg = False
            break
    if flg == False:
        break

if flg:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long int dp[1001][1001];
long long int path(string s[],int i,int j,int h){
if(i>=s[0].size()||j>=h||s[j][i]=='#')return 0;
if(dp[j][i]!=-1)return dp[j][i];
if(i==(s[0].size()-1)&&j==h-1)return  1;
dp[j][i]=path(s,i+1,j,h)+path(s,i,j+1,h);
//cout<<dp[j][i]<<endl;
return dp[j][i]%(1000000000+7);
}



main(){
long long int h,w;
cin>>h>>w;
string s[h];
for(int i=0;i<h;i++)cin>>s[i];
memset(dp,-1,sizeof(dp));
cout<<path(s,0,0,h);


}


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

int main() {
	string integer;
	cin >> integer;
	char check = integer[1];

	if ((integer[0] == check && integer[2] ==check|| integer[3] == check && integer[2]==check)) {
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,i=0,x=1;
    cin>>a>>b;
    while(x<b){
        x=x-1+a;
        i++;
    }
    cout<<i<<endl;
}

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int a, b;
    ci >> a >> b;

    int tmp = (b + a) / 2;

    if(abs(a - tmp) == abs(b - tmp)) co << tmp << en;
    else co << "IMPOSSIBLE" << en;
    
    return 0;
}


Measured memory_bytes: 256
S = str(input())
Q = int(input())

topFlg = True

leftStr = ""
rightStr = ""

for _ in range(Q):
    query = list(map(str, input().split()))
    if query[0] == "1":
        topFlg = not (topFlg)
    else:
        if query[1] == "1":
            if topFlg:
                leftStr = query[2] + leftStr
            else:
                rightStr += query[2]
        else:
            if topFlg:
                rightStr += query[2]
            else:
                leftStr = query[2] + leftStr

print(leftStr + S +
      rightStr if topFlg else rightStr[::-1] + S[::-1] + leftStr[::-1])


Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  st S,T;
  cin >> S >> T;
  bool b=true;
  vl cnt1(26,0),cnt2(26,0);
  rep(i,(ll)S.size()){
    cnt1[S[i]-'a']++;
    cnt2[T[i]-'a']++;
  }
  sort(cnt1.begin(),cnt1.end());
  sort(cnt2.begin(),cnt2.end());
  rep(i,(ll)26){
    if(cnt1[i]!=cnt2[i]){
      b=false;
    }
  }
  if(b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        String[] strings = new String[4];
        strings = line.split(" ");
        int[] ints = new int[4];
        for (int i = 0; i < 4; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }
        int A = ints[0];

        int B = ints[1];

        int H = ints[2];

        int M = ints[3];

        H =  H % 12;
        double Hr = H * 30 + 0.5 * M;
        double Mr = M * 6.0;

        double cha = Math.abs(Hr - Mr);


        double jiaoducha = Math.toRadians(cha);
        double cq  = A*A + B*B - 2 * A * B * Math.cos(jiaoducha);

        double c = Math.sqrt(cq);
        System.out.println(c);

    }
}


Measured memory_bytes: 33196
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s[]={"Even","Odd"};
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if(c>a+b) cout<<"No";
	else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
substrs = set()
string = input()
k = int(input())

for i in range(len(string)):
	for j in range(i, i+5):
		substrs.add(string[i:j+1])

substrs = sorted(list(substrs))
for i,s in enumerate(substrs):
	if i == k-1:
		print(s)
		break


Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,M;
	cin>>N>>M;
	vector<int> H(N);
	rep(i,0,N) cin>>H[i];

	set<int> bad;
	rep(i,0,M) {
		int a, b;
		cin>>a>>b;
		a--,b--;
		if (H[a]<=H[b]) bad.insert(a);
		if (H[a]>=H[b]) bad.insert(b);
	}
	cout<<N-sz(bad)<<'\n';
}



Measured memory_bytes: 6368
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  int N, M; cin >> N >> M;

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  
  vector< pair<int,int> > CB(M);
  for (int i = 0; i < M; i++) {
    int b, c; cin >> b >> c;
    CB[i] = make_pair(c, b);
  }
  sort(CB.begin(), CB.end(), greater< pair<int,int> >());

  int ans = 0;
  for (int i = 0, j = 0; i < N; i++) {
    if (CB[j].first > A[i]) {
      ans += CB[j].first;
      CB[j].second--;
    } else {
      ans += A[i];
    }
    if (CB[j].second == 0) j++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

static const int INF = (1<<20);

int T, t[30], N, D, M, dp[101][30], m[101];

main(){
  while(cin >> T && T){
    for(int i=0;i<T;i++) cin >> t[i];
    cin >> N;
    fill(m, m+101, INF);
    for(int i=0;i<N;i++){
      cin >> D >> M;
      m[D-1] = min(m[D-1], M);
    }
    fill(dp[0], dp[101], INF);
    dp[0][0] = 0;
    for(int i=0;i<100;i++){
      for(int j=0;j<T;j++){
        if(t[j] <= m[i]){
          dp[i+1][(j+1)%T] = min(dp[i+1][(j+1)%T], dp[i][j]);
          dp[i+1][0] = min(dp[i+1][0], dp[i][j]+1);
        }
      }
    }
    int ans = INF;
    for(int i=0;i<T;i++) ans = min(ans, dp[100][i]);
    cout << ans << endl;
  }
}

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

int bubbleSort(int A[], int N){
  int sw = 0;
  bool flag = 1;
  for(int i = 0; flag ; i++){
    flag = 0;
    for(int j = N-1; j>= i+1;j--){
      if(A[j] < A[j-1]){
        swap(A[j],A[j-1]);
        flag = 1;
        sw++;
      }
    }    
  }
  return sw;
}


int main(){
  int A[100], N, sw;
  cin >> N;
  for(int i = 0;i<N;i++) cin >> A[i];

  sw = bubbleSort(A,N);

  for(int i = 0;i<N;i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
 }


Measured memory_bytes: 3092
/*input
happy,newyear,enjoy
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	a=(a+11)%13;
	b=(b+11)%13;
	if(a==b) cout<<"Draw";
	else if(a>b) cout<<"Alice";
	else cout<<"Bob";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n, m, d;
    cin >> n >> m >> d;
    if(d == 0){
        printf("%.10f\n", float(m - 1) / n);
    }else{
        printf("%.10f\n", float(2 * (m - 1) * (n - d)) / n / n);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <list>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static int count = 0;
void merge(vector<int>& list, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1);
    vector<int> R(n2 + 1);
    for(int i = 0; i < n1; i++){
        L[i] = list[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = list[mid + i];
    }
    L[n1] = std::numeric_limits<int>::max();
    R[n2] = std::numeric_limits<int>::max();

    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
        count++;
        if(L[i] <= R[j]){
            list[k] = L[i];
            i++;
        }else{
            list[k] = R[j];
            j++;
        }
    }
}

void mergeSort(vector<int>& list, int left, int right){
    // printf("left:%d right:%d\n", left, right);
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(list, left, mid);
        mergeSort(list, mid, right);
        merge(list, left, mid, right);
    }
}
void solve() {
    int n;
    scanf("%d", &n);
    vector<int> list(n);
    for(int i = 0; i < n; i++){
        int v;
        scanf("%d", &v);
        list[i] = v;
    }
    mergeSort(list, 0, list.size());
    printList(list);
    printf("%d\n", count);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


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

using namespace std;

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

int main() {
	string s;
	cin >> s;
	long long cnt = 0, ans = 0;
	for(char c : s) if(c == 'B') cnt++; else ans += cnt;
	cout << ans << endl;
}


Measured memory_bytes: 640
#D問題
N = int(input())
A = list(map(int,input().split()))

B = []
for i in range(N):
    if i == N-1:
        B.append(A[0]-A[N-1])
    else:
        B.append(A[i+1]-A[i])
        
X = [0 for i in range(N)]
for i in range(N-1):
    oind = (2*i)%N
    nind = (2*(i+1))%N
    X[nind] = X[oind] + 2*B[oind]
    
SX = sum(X)
SA = sum(A)
d = (SA-SX)//N
for i in range(N):
    X[i]+=d
    print(X[i],end=" ")

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

template<typename T>
unsigned int index_of_max(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] > arr[idx])
			idx = i;
	}
	return idx;
}

template<typename T>
unsigned int index_of_min(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] < arr[idx])
			idx = i;
	}
	return idx;
}

bool isPalindrome(string s, int l, int r) {
	for (; l <= r; ++l, --r) {
		if (s[l] != s[r])
			return false;
	}
	return true;
}

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif	
	FAST_IO;
	string s;
	cin >> s;
	int n = s.size();
	if (isPalindrome(s, 0, n-1) && isPalindrome(s, 0, n / 2 - 1) && isPalindrome(s, n / 2 + 1, n - 1)) {
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}




Measured memory_bytes: 384
//0321 部活動調査
//UF木
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
int root(int x){
	if(x!=node[x]){
		node[x] = root(node[x]);
		return node[x];
	}
	else return x;
}
int main(void)
{
	LL i,j,n,m,k;
	cin>>n>>m>>k;
	for(i=0;i<k;i++) cin>>bol[i]>>r1[i]>>r2[i];
	for(i=0;i<n;i++) club[i]=0,node[i]=i,size[i]=1;
	for(i=0;i<k;i++) {
		int x,y,c,s;
		if(bol[i]==1) {
			x=r1[i],y=r2[i];
			x=root(x);
			y=root(y);
			if(club[x]!=0&&club[y]!=0&&club[x]!=club[y]) {
				cout<<i+1<<endl;
				break;
			}
			else if(club[x]!=0&&club[y]==0) club[y]=club[x];
			else if(club[x]==0&&club[y]!=0) club[x]=club[y];
			if(x!=y) {
				if(size[x]>size[y]) node[y]=x;
				else if(size[y]>size[x]) node[x]=y;
				else node[y]=x,size[x]++;
			}
		}
		else {
			s=r1[i],c=r2[i];
			s=root(s);
			if(club[s]==0) club[s]=c;
			else if(club[s]!=c) {
				cout<<i+1<<endl;
				break;
			}
		}
	}
	if(i==k) cout<<"0"<<endl;
}

Measured memory_bytes: 10112
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> H >> W;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	vector<vector<int>>h(H, vector<int>(W));
	vector<vector<int>>w(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			h[i][j] = w[i][j] = s[i][j] == '.';
		}
	}
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++) {
			h[i][j] = h[i][j] * h[i - 1][j] + h[i][j];
		}
	}
	for (int i = H - 2; i >= 0; i--) {
		for (int j = 0; j < W; j++) {
			if (h[i][j])h[i][j] = max(h[i][j], h[i + 1][j]);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 1; j < W; j++) {
			w[i][j] = w[i][j] * w[i][j - 1] + w[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = W - 2; j >= 0; j--) {
			if (w[i][j])w[i][j] = max(w[i][j], w[i][j + 1]);
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			ans = max(ans, -1 + h[i][j] + w[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
   
    cin>>a;
    int k=0;  
    for(int i=0;i<a.size();i++)
	{
        if(a[i]=='C')
		{
            k=1;
        }
        if(a[i]=='F'&&k==1)
		{
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define double long double
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  
#define pi 3.14159265358979323846 

int solve(){
    int x,y,a,b,c,m,s=0,z=0;
    cin>>x>>y>>a>>b>>c;
    vii v;
    rep(i,0,a){
        cin>>m;
        v.pb({m,1});
    }
    rep(i,0,b){
        cin>>m;
        v.pb({m,2});
    }
    rep(i,0,c){
        cin>>m;
        v.pb({m,3});
    }
    sort(all(v));
    int i=a+b+c-1;
    while(x>0||y>0){
        if(v[i].S==1&&x>0) {s=s+v[i].F;x--;}
        else if(v[i].S==2&&y>0) {s=s+v[i].F;y--;}
        else if(v[i].S==3){
            s=s+v[i].F;
            z++;
        }
        i--;
        if(x+y==z||i<0) break;
    }
    cout<<s;
    return 0;
}   
     
signed main(){
    IOS;
   // freopen("input.txt", "r" , stdin);
    //freopen("output4.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
template <class T>
bool chmax(T &a, const T &b){if (a < b){a = b;return 1;}return 0;}
template <class T>bool chmin(T &a, const T &b){if (b < a){a = b;return 1;}return 0;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

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

    string s;
    cin >> s;
    bool flag = true;

    rep(i,s.length()/2){
        if(s[i]!=s[s.length()-1-i]){
            flag = false;
            break;
        }
    }

    int ex1 = (s.length() - 1) / 2;
    int ex2 = (s.length() + 3) / 2;
    rep(i,ex1/2){
        if(s[i]!=s[ex1-1-i]){
            flag = false;
            break;
        }
    }
    rep(i,ex1/2){
        if(s[ex2-1+i]!=s[s.length()-1-i]){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;
vi L(N);
rep(i,N) cin >> L[i];

int MAX = 0,sum = 0;
rep(i,N) {
    sum += L[i];
    MAX = max(MAX,L[i]);
}
sum -= MAX;
if(MAX < sum) puts("Yes");
else puts("No");

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int x = 0;
  string b = "CODEFESTIVAL2016";
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      x++;
    }
  }
  cout << x;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <sstream>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int in[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << in[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque

N,M = map(int,input().split())

data = [[] for _ in range(3*N)]

for i in range(M):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    data[3*u].append(3*v+1)
    data[3*u+1].append(3*v+2)
    data[3*u+2].append(3*v)

S,T = map(int,input().split())
S -= 1
T -= 1

inf = 10**6
stack = deque([[3*S,0]])
time = [inf] * (3*N)

while stack:
    x = stack.popleft()
    for y in data[x[0]]:
        if time[y] > x[1] + 1:
            time[y] = x[1] + 1
            stack.append([y,x[1] + 1])

if time[3*T] == inf:
    print(-1)
else:
    print(time[3*T]//3)

Measured memory_bytes: 60164
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <cstdint>

using i64 = std::int64_t;

int main() {
	i64 n, d, a;
	std::cin >> n >> d >> a;
	d *= 2;

	using Pair = std::pair<int, int>;
	std::vector<Pair> vec(n);
	for (auto&& p : vec) {
		std::cin >> p.first >> p.second;
		p.second = (p.second + a - 1) / a;
	}

	std::sort(vec.begin(), vec.end());

	std::map<i64, i64> acc;
	acc[vec[0].first + d] = vec[0].second;

	for (int i = 1; i < n; ++i) {
		auto x = vec[i].first, h = vec[i].second;
		auto last = acc.rbegin()->second;

		if (x > acc.rbegin()->first) {
			acc[x + d] = last + h;
			continue;
		}

		i64 sub = 0;
		if (x > acc.begin()->first)
			sub = (--acc.lower_bound(x))->second;

		i64 damage = last - sub;

		if (damage < h)
			acc[x + d] = last + h - damage;
	}

	std::cout << acc.rbegin()->second << std::endl;
}

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

# define ll long long
# define mod 1000000007
# define MAX 100005
# define PI 3.141592653589793238                                                                                  //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fr(i,a,b) for(int i=a;i<=b;i++)

# define decimal(k) fixed<<setprecision(k)
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;

int main()
{
   ll x,k,d;cin>>x>>k>>d;
   
   ll dis=abs(x);
   ll a=dis%d;
   ll moves=dis/d;
   ll ans;
   if(moves>=k){
   	 ll z=k*d;
   	if(x>0)ans=x-z;
   	else ans=x+z;
   	
   }
   else{
   	 ll z=moves*d;
   	if(x>0)ans=x-z;
   	else ans=x+z;
   	ll se;
   	if(x>0)se=ans-d;
   	else se=ans+d;
   	ll dif=(k-moves);
   	if(dif%2==1)ans=se;
   }
   cout<<abs(ans)<<'\n';
   return 0;
	 
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}	

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_SIZE 100

int main(void)
{
    int n, d[MAX_SIZE];
    int i,j,tmp;
    int exec_rslt;

    exec_rslt = 1;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &d[i]);
    }

    //sort
    for(i=0; i<(n-1); i++){
        for(j=(n-1); j>i; j--){
            if(d[j-1]<d[j]){
                tmp = d[j-1];
                d[j-1]=d[j];
                d[j]=tmp;
            }
        }
    }

    for(i=0; i<n-1; i++){
        if(d[i]>d[i+1]){
            exec_rslt++;
        }
    }

    printf("%d\n", exec_rslt);
}

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

using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pii;
string s;
int maxV = 0;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> s;
    int st = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] != s[st]) st = i;
        if (s[i] == 'R') maxV = max(maxV, i - st + 1);
    }
    cout << maxV;
    return 0;
}


Measured memory_bytes: 3584
PROGRAM WaterBottle
      IMPLICIT NONE
      integer,parameter :: prec = 8
      real(prec) :: a,b,x,ans
      
      read*,a,b,x
      
      x = x / a
      if( x<=a*b/2. )then
        a = 2.*x/b
    !    print*,'before'
    !    print*,a
        
        ans = asin( b/sqrt(a**2.+b**2.) )
      else
        b = 2.*b - 2.*x/a
     !   print*,'after'
        
        ans = asin( b/sqrt(a**2.+b**2.) )
      end if
      
      
      print*,ans/(2._prec*3.1415926535897932_prec)*360._prec
      
      stop
    !  print*,a,b,x
      
      END PROGRAM

Measured memory_bytes: 256