akhauriyash/Code-Regression huggingface dataset:
Public Class Program
  Shared Sub Main()
    Dim st As String() = Cin.StrArr()
    Dim s As String = st(0)
    Dim t As String = st(1)
    Dim ab As Integer() = Cin.IntArr()
    Dim a As Integer = ab(0)
    Dim b As Integer = ab(1)
    Dim u As String = Cin.Str()
    If u = s Then
      a -= 1
    ElseIf u = t Then
      b -= 1
    End If
    Console.WriteLine(a.ToString() & " " & b.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 20432
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  REP(i, n) {
    cin >> a[i] >> b[i];
  }
  ll ans = 0;
  REP(i, n) {
    ll tmp = (a[n-i-1] + ans) % b[n-i-1];
    if(tmp == 0) continue;
    ans += b[n-i-1] - tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int p[1005];
	for(int i=0;i<n;i++) cin>>p[i];
	sort(p,p+n);
	int cost=0;
	for(int i=0;i<k;i++) cost+=p[i];
	cout<<cost;
	return 0;
}


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

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

bool kaibun(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return t==s;
}

int main(void)
{
    int a[5];
    rep(i,5) cin>>a[i];
    rep(i,5){
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

const int NullIndex = -1;
vector<int> heap;

int get_parent_index(int index) {
  int parent_index = index / 2;

  if(parent_index < 1) {
    return NullIndex;
  }

  return parent_index;
}

int get_left_index(int index) {
  int heap_size = heap.size() - 1;
  int left_index = index * 2;

  if(left_index > heap_size) {
    return NullIndex;
  }

  return left_index;
}

int get_right_index(int index) {
  int heap_size = heap.size() - 1;
  int right_index = index * 2 + 1;

  if(right_index > heap_size) {
    return NullIndex;
  }

  return right_index;
}

void swap (int& a, int& b) {
  int tmp = a;
  a = b;
  b = tmp;
}

void max_heapify_bottom_up(int index) {
  int parent_index = get_parent_index(index);

  if(parent_index == NullIndex) {
    return;
  }

  if(heap[index] > heap[parent_index]) {
    swap(heap[index], heap[parent_index]);
    max_heapify_bottom_up(parent_index);
  }
}

void insert(int key) {
  heap.push_back(key);
  max_heapify_bottom_up(heap.size() - 1);
}

void max_heapify_top_down(int index) {
  int left_index = get_left_index(index);
  int right_index = get_right_index(index);

  if(left_index == NullIndex && right_index == NullIndex) {
    return;
  }

  int larger_child_idnex = left_index;
  if(right_index != NullIndex && heap[right_index] > heap[left_index]) {
    larger_child_idnex = right_index;
  }

  if(heap[larger_child_idnex] > heap[index]) {
    swap(heap[larger_child_idnex], heap[index]);
    max_heapify_top_down(larger_child_idnex);
  }
}

int extract() {
  int heap_size = heap.size() - 1;

  swap(heap[1], heap[heap_size]);
  int extracted = heap.back();
  heap.pop_back();

  max_heapify_top_down(1);

  return extracted;
}

int main() {
  string command;
  int key;
  heap.resize(1);


  while(true) {
    cin >> command;

    if (command == "end") {
      break;
    }

    if (command == "insert") {
      cin >> key;

      insert(key);
    } else if (command == "extract") {
      int extracted_key = extract();
      cout << extracted_key << endl;
    }
  }

}



Measured memory_bytes: 7004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		sc.close();
		long s = N/(A+B)*A;
		long k = N%(A+B);
		s += Math.min(A,k);
		System.out.println(s);
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a, s[100100], f[100100], res;

signed main() {
	reps(i,1,100100) s[i] = (s[i-1] + mop(i,mod-2)) %mod;
	f[0] = 1;
	reps(i,1,100100) f[i] = f[i-1]*i %mod;
	cin >> n;
	rep(i,n) {
		cin >> a;
		(res += (s[i+1] + s[n-i] - 1) * a) %= mod;
	}
	(res *= f[n]) %= mod;
	cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>

//const int N = 1e5;
//int a[N];

int main() {
        int h, n, a, sum;
        std::cin >> h >> n;
        sum = 0;

        for (int i = 0; i < n; ++i) {
                std::cin >> a;
                sum += a;
        }
        std::cout << (sum >= h ? "Yes" : "No");


        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
char S[100];
int main() {
	int i, ans = 0;
	cin >> N;

	for (i = 0; i < N; ++i) {
		cin >> S[i];
		if (S[i] == 'Y') {
			++ans;
			break;
		}
	}

	if (ans != 0) cout << "Four" << endl;
	else cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  a.sort();
  long res;
  foreach (i; 0..n) {
    res += a[3*n-i*2-2];
  }
  res.writeln;
}


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


int main(){
	ll count = 0, maxAb = 0;
	string s;
	cin>>s;
	for(ll i=0; i<s.length(); i++){
		if(s[i] == 'R'){
			count++;
			continue;
		}
		maxAb = max(maxAb, count);
		count = 0;
	}
	cout<<max(count, maxAb)<<endl;

	return 0;
}

Measured memory_bytes: 3628
n=int(input())
a=[int(input())for _ in range(n)]
left=[0]
for i in a:
  left.append(max(left[-1],i))
right=[0]
for i in reversed(a):
  right.append(max(right[-1],i))
right.reverse()
for i in range(n):
  print(max(left[i],right[i+1]))


Measured memory_bytes: 15636
using System;
using System.Linq;

public class Problem_D
{
  public static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var nums = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var max = nums.Max();
    var half = Math.Ceiling(max / 2d);
    var aj = 0;
    foreach (var num in nums)
    {
      aj = Math.Abs(half - num) < Math.Abs(half - aj) ? num : aj;
    }
    Console.WriteLine($"{max} {aj}");
  }
}


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

int main() {
    //freopen( "C:\\Users\\ehab\\Desktop\\problems\\in.txt" , "r" , stdin );

    int a , b , c;
    cin >> a >> b >> c;

    if ( a + b >= c )
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

int main()
{
    string s;
    rep (i, 3)
    {
        cin >> s;
        cout << s[i];
    }

    cout << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int n;
vector<int>tmp(8);
double sum = 0.0;
int division = 0;
void dfs(int len, vector<pair<int, int> >dis){
    if(len >= n){
        //sumの計算
        rep(i, n-1){
            double x = (dis[tmp[i]-1].first-dis[tmp[i+1]-1].first)*(dis[tmp[i]-1].first-dis[tmp[i+1]-1].first);
            double y = (dis[tmp[i]-1].second-dis[tmp[i+1]-1].second)*(dis[tmp[i]-1].second-dis[tmp[i+1]-1].second);
            sum += sqrt(x+y);
        }
        //debug
        //printf("n:%d\n", n);
        //rep(i, dis.size()){
        //    printf("dis[%d]:(%d, %d)\n", i, dis[i].first, dis[i].second);
        //}
        //printf("sum:%f\n", sum);
        //rep(i, n){
        //    printf("tmp[%d];%d\n", i, tmp[i]);
        //}
        division++;
        //printf("div:%d\n",division);
        //cout << endl;
    }else{
        rep(i, n){
            //重複の解消
            bool flag = false;
            rep(j, len){
                if(tmp[j] == i+1) flag = true;
            }
            if(flag)    continue;
            tmp[len] = i+1;
            dfs(len+1, dis);
        }
    }
    len--;
}

int main(){
    cin >> n;
    vector<pair<int, int> >dis(n);
    rep(i, n){
        cin >> dis[i].first >> dis[i].second;
    }
    dfs(0, dis);
    //cout << sum << endl;
    printf("%f\n", (double)sum/division);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int n;
	cin >> n;
	int min = MOD_P;
	int ans = 0;

	for (int i = 0; i < n; i++) {
		int ar;
		cin >> ar;
		if (min > ar) {
			min = ar;
			ans++;
		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[5001];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>p[i];
	sort(p+1,p+n+1);
	int sum=0;
	for(int i=1;i<=k;i++)
	sum+=p[i];
	cout<<sum<<endl;
 } 

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<ar<ll,2> >  v,t;
	map<ar<ll,2> , int> m;
	for(int i = 0,j,k; i<n; i++)
	{
		cin>>j>>k;
		v.push_back({j,k});
		t.push_back({k,j});
		m[v[i]] = i;
	}
	sort(v.begin(),v.end());
	sort(t.begin(),t.end());
	vector<ar<ll,2> > edges[n];
	for(int i = 1; i<n; i++)
	{
		auto y = v[i];
		auto y2 = v[i-1];
		edges[m[y]].push_back({m[y2],abs(y2[0]-y[0])});
		edges[m[y2]].push_back({m[y],abs(y2[0]-y[0])});
		y = t[i];
		y2 = t[i-1];
		swap(y[0],y[1]);
		swap(y2[0],y2[1]);
		edges[m[y]].push_back({m[y2],abs(y2[1]-y[1])});
		edges[m[y2]].push_back({m[y],abs(y2[1]-y[1])});
	}
	set<ar<ll,2> > st;
  auto it = *m.begin();
	st.insert({0,it.second});
	bool vis[n]={0};
	vis[it.second] = 1;
	ll dist[n];
	memset(dist,0x3f, 8*n);
	dist[it.second] = 0;
	while(!st.empty())
	{
		auto y = *st.begin();
		st.erase(st.begin());
		vis[y[1]] = 1;
		for(auto it:edges[y[1]])
		{
			if(!vis[it[0]] && dist[it[0]]>it[1])
			{
				st.erase({dist[it[0]],it[0]});
				dist[it[0]] = it[1];
				st.insert({dist[it[0]],it[0]});
			}
		}
	}
	ll ans =0;
	for(auto it:m)
		ans += dist[it.second];
  	cout<<ans<<endl;
	return 0;
}

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

int main(){
  char input[4];
  char *list[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  int I=0;
  scanf("%s",input);
  //printf("%s\n",input);
  for(int i= 0;i<7;i++){
    // printf("%s\n",list[i]);
    if(!strcmp(input,list[i])){
      I = i;
      break;
    } 
  }
 
  printf("%d\n",7-I); 
}



Measured memory_bytes: 128
s = int(input())

ls_a = [0]
ls_a[0] = s

for i in range(10**5):
    if ls_a[i] % 2 == 0:
        ls_a.append(ls_a[i] / 2)
    elif ls_a[i] % 2 == 1:
        ls_a.append(3 * ls_a[i] + 1)

    if ls_a[i+1] in ls_a[:i]:
        print(i+2)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
struct pt{
  int x,y,t;
  bool operator <(pt p)const{
    if(x!=p.x)return x>p.x;
    if(y!=p.y)return y>p.y;
    return t<p.t;
  }
};
vector<pt>all;
int main(){
  int n;
  scanf("%d",&n);
  all.resize(n+n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&all[i].x,&all[i].y);
    all[i].t=0;
  }
  for(int i=n;i<n+n;i++){
    scanf("%d %d",&all[i].x,&all[i].y);
    all[i].t=1;
  }
  sort(all.begin(),all.end());
  multiset<int>ys;
  int ans=0;
  for(auto p:all){
    if(p.t==0){
      auto it=ys.lower_bound(p.y+1);
      if(it!=ys.end()){
        ys.erase(it);
        ans++;
      }
    }
    else{
      ys.insert(p.y);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();

		String start = str.substring(0, 1);
		String end = str.substring(str.length()-1, str.length());
		int len = str.length()-2;

		String ans = start + String.valueOf(len) + end;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int a[n];
    int num[500000] = {};
    rep(i, 0, n) {
        cin >> a[i];
        num[a[i]] ++;
    }

    bool flag = true;
    if (n % 2 == 0) {
        rep(i, 0, n) {
            if (i % 2 == 0) {
                if (num[i]) {
                    flag = false;
                    break;
                }
            } else {
                if (num[i] != 2) {
                    flag = false;
                    break;
                }
            }
        }
    } else {
        rep (i, 0, n) {
            if (i == 0) {
                if (!num[i]) {
                    flag = false;
                    break;
                }
            } else if (i % 2 == 0) {
                if (num[i] != 2) {
                    flag = false;
                    break;
                }
            } else {
                if (num[i]) {
                    flag = false;
                    break;
                }
            }
        }
    }

    int ans = 1;
    int mod = 1e9 + 7;
    if (flag) rep(i, 0, n / 2) ans = ans * 2 % mod;
    else ans = 0;

    cout << ans << endl;

}


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

using namespace std;

using ll = long long;

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

    int h = 0;
    for (int i = 0; i < S.size() / 2; i++) {
        if (S[i] != S[S.size() - 1 - i]) h++;
    }

    cout << h << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=0
for i in range(n):
    if i%2==0:
        x+=a[i]
    else:
        x-=a[i]
print(x)
x//=2
for i in range(n-1):
    x=a[i]-x
    print(2*x)

Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double, ll>;

const ll INF = 1e18;

struct Barrier {
    complex<double> z;
    ll r;
};

void solve(long long x_s, long long y_s, long long x_t, long long y_t, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> r)
{
    vector<Barrier> barriers;

    // スタートとゴールも半径0のバリアとして追加する
    barriers.push_back({ { (double)x_s, (double)y_s }, 0 });
    for (ll i = 0; i < N; i++) {
        barriers.push_back({ { (double)x[i], (double)y[i] }, r[i] });
    }
    barriers.push_back({ { (double)x_t, (double)y_t }, 0 });

    priority_queue<P, vector<P>, greater<P>> que;
    vector<double> costs(N + 2, INF);

    que.emplace(0, 0);
    costs[0] = 0;

    while (!que.empty()) {
        auto a = que.top();
        que.pop();
        auto cost = a.first;
        auto v = a.second;

        if (cost > costs[v]) {
            continue;
        }

        for (ll i = 0; i <= N + 1; i++) {
            if (i == v) {
                continue;
            }
            auto nc = max(0.0, abs(barriers[v].z - barriers[i].z) - barriers[v].r - barriers[i].r);
            if (costs[i] > cost + nc) {
                costs[i] = cost + nc;
                que.emplace(cost + nc, i);
            }
        }
    }

    cout << setprecision(15) << costs[N + 1] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long x_s;
    scanf("%lld",&x_s);
    long long y_s;
    scanf("%lld",&y_s);
    long long x_t;
    scanf("%lld",&x_t);
    long long y_t;
    scanf("%lld",&y_t);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> r(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&r[i]);
    }
    solve(x_s, y_s, x_t, y_t, N, std::move(x), std::move(y), std::move(r));
    return 0;
}


Measured memory_bytes: 5892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x; cin >>x;
  int y; cin >>y;
  int prise =0;
  bool win = false;
  if(x < 4){
    if(x == 3) prise += 100000;
    if(x == 2) prise += 200000;
    if(x == 1) {prise += 300000;win=true;}
  }
  if(y < 4){
    if(y == 3) prise += 100000;
    if(y == 2) prise += 200000;
    if(y == 1) {prise += 300000;if(win==true)prise += 400000;}
  }
  cout << prise;
  return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

//BEGIN
template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T> > > G) {
	const T INF = numeric_limits<T>::max();
	const int N = G.size();
	vector<T> cost(N, INF);
	vector<int> prevr(N, -1); //経路復元用
	priority_queue < pair<T, int>, vector<pair<T, int> >, greater<pair<T, int> > > pq;
	cost[s] = 0;
	pq.push(make_pair(0, s));
	while (!pq.empty()) {
		pair<T, int> p = pq.top(); pq.pop();
		int now = p.second;
		if (cost[now] < p.first) continue;
		for (auto next : G[now]) {
			int nv = next.first, nw = next.second;
			if (cost[nv] > cost[now] + nw) {
				cost[nv] = cost[now] + nw;
				prevr[nv] = now;
				pq.push(make_pair(cost[nv], nv));
			}
		}
	}
	return cost;
}

vector<int> get_path(int t, vector<int> preve) {
	vector<int> path;
	for (; t != -1; t = preve[t]) path.push_back(t);
	reverse(path.begin(), path.end());
	return path;
}
//END

int main() {
	int V, E, r; cin >> V >> E >> r;
	vector<vector<pair<int, int> > > G(V);
	for (int i = 0; i < E; ++i) {
		int s, t, d; cin >> s >> t >> d;
		G[s].push_back(make_pair(t, d));
	}
	vector<int> ans = dijkstra(r, G);
	for (int i = 0; i < V; ++i) {
		if (ans[i] == numeric_limits<int>::max()) cout << "INF" << endl;
		else cout << ans[i] << endl;
	}

	return 0;
}


/*
	created: 2019-08-26
	https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_1_A
*/


Measured memory_bytes: 20664
s = input()
q = int(input())
hanten = True
atm = ""
kts = ""
for i in range(q):
    l = input().split()
    if l[0] == "1":
        hanten = not hanten
    else:
        if l[1] == "1":
            if hanten:
                atm = l[2] + atm
            else:
                kts = kts + l[2]
        else:
            if hanten:
                kts = kts + l[2]
            else:
                atm = l[2] + atm

ans = atm + s + kts
if hanten == False:
    print(ans[::-1])
else:
    print(ans)

Measured memory_bytes: 4580
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

template<class T>
struct MaxBIT {
    vector<T> x;
    MaxBIT(ll n) : x(n, 0) {}
    T get(ll i){
        ll s = 0;
        while(i > 0){
            s = max(s, x.at(i - 1));
            i -= i & (-i);
        }
        return s;
    }
    void set(ll i, T v){
        i += 1;
        while(i <= x.size()){
            x.at(i - 1) = max(x.at(i - 1), v);
            i += i & (-i);
        }
    }
};


int main(){
    ll n;
    cin >> n;
    vector<ll> h(n), a(n);
    for(int i = 0; i < n; ++i){
        cin >> h.at(i);
    }
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    MaxBIT<ll> bit(n);
    for(int i = 0; i < n; ++i){
        ll tmp = bit.get(h.at(i));
        bit.set(h.at(i) - 1, tmp + a.at(i));
    }

    cout << bit.get(n) << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  vector<ll>results;
  rep(i, n){
//cout<<a[i]<<endl;
    if(i==0){ results.push_back(a[i]); continue; }

    auto it = lower_bound(results.begin(), results.end(), a[i]);
    if( it==results.end() ){
      if(a[i]>results[results.size()-1])results[results.size()-1]=a[i];
      else results.insert(results.begin(), a[i]);
    }else{
//cout<<*it<<':';
      if(it==results.begin()){ results.insert(results.begin(), a[i]);
      }else{
        it--;
        *it = a[i];
      }
//cout<<*it<<'*'<<endl;
    }

//cout<<results.size()<<':';rep(i, results.size())cout<<results[i]<<' ';cout<<endl;

  }
  cout<<results.size()<<endl;

  return 0;
}

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

signed main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int> (m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int& x : a[i]) cin >> x;
  }

  int ans = 1e18;
  for (int i = 0; i < (1<<n); i++) {
    int cost = 0;
    vector<int> v(m);
    for (int j = 0; j < n; j++) {
      if ((i>>j) & 1) continue;
      cost += c[j];
      for (int k = 0; k < m; k++) {
        v[k] += a[j][k];
      }
    }
    bool f = true;
    for (int e : v) f &= e >= x;
    if (f) ans = min(ans, cost);
  }
  cout << (ans < 1e18 ? ans : -1) << endl;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin>>a>>b>>c;
    if((b>c&&c>a)||(a>c&&c>b))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int s[] = new int[N];
    int sum = 0;
    for(int i=0; i<N; i++){
      s[i] = sc.nextInt();
      sum += s[i];
    }
    int ans = 0;
    if(sum % 10 != 0) ans = sum;
    else{
      Arrays.sort(s);
      for(int i=0; i<N; i++){
        if(s[i] % 10 != 0){
          ans = sum - s[i];
          break;
        }
        if(i == N-1) ans = 0;
      }
      
    }
    out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

int main() {
    int n, dp[45];
    cin >> n;
    dp[0] = dp[1] = 1;
    for(int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

int main(){

  int a[3][3];
  bool bingo[3][3];
  REP(i,3){
    REP(j,3){
      cin>>a[i][j];
      bingo[i][j] = false;
    }
  }


  int n;cin>>n;
  REP(i,n){
    int t;cin>>t;
    REP(j,3){
      REP(k,3){
        if(a[j][k] == t){
          bingo[j][k] = true;
        }
      }
    }
  }



  bool ans = false;
  REP(i,3){
    if(bingo[i][0]&&bingo[i][1]&&bingo[i][2]){
      ans = true;
    }
    if(bingo[0][i]&&bingo[1][i]&&bingo[2][i]){
      ans = true;
    }
    if(bingo[0][0]&&bingo[1][1]&&bingo[2][2]){
      ans = true;
    }
    if(bingo[0][2]&&bingo[1][1]&&bingo[2][0]){
      ans = true;
    }
  }

if(ans){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}
 

  return 0;
}

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

int main(){
  int n,s=0;
  cin >> n;
  int a[n],b[n],c[n-1];
  rep(i,n)	cin >> a[i];
  rep(i,n)	cin >> b[i];
  rep(i,n-1) cin >> c[i];
  
  rep(i,n){
  	s+=b[a[i]];
    if(a[i]+1==a[i+1])
      s+=c[a[i]];
  
  }
  cout << s;
  
  
  return 0;

}

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

using LL = long long;
using VL = vector<LL>;
using STR = string;

#define REP(i, n) for (LL i = 0, i##_size = n; i < i##_size; ++i)
#define RREP(i, n) for (LL i = LL(n) - 1; i >= 0; --i)

template <class T> void chmin(T& a, T b) { if (b < a) { a = b; } }
template <class T> void chmax(T& a, T b) { if (b > a) { a = b; } }

#define SZ(var) (LL)(var.size())

#define IN_LL(var) LL var; cin >> var;
#define IN_LL2(var0, var1) LL var0, var1; cin >> var0 >> var1;
#define IN_LL3(var0, var1, var2) LL var0, var1, var2; cin >> var0 >> var1 >> var2;
#define IN_LL4(var0, var1, var2, var3) LL var0, var1, var2, var3; cin >> var0 >> var1 >> var2 >> var3;

#define IN_VL(var, n) VL var(n); REP(i, n) { cin >> var[i]; };
#define IN_STR(var) STR var; cin >> var;

#define OUT(var) cout << (var) << '\n';

void myMain();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(16);
	myMain();
	return 0;
}

const double PI = 3.14159265358979323846;

void myMain() {
	IN_LL4(A, B, H, M);
	
	double angleA = H / 12.0 + M / 60.0 / 12.0;
	double angleB = M / 60.0;

	double ax = A * cos(angleA * 2.0 * PI);
	double ay = A * sin(angleA * 2.0 * PI);
	double bx = B * cos(angleB * 2.0 * PI);
	double by = B * sin(angleB * 2.0 * PI);

	double sx = ax - bx;
	double sy = ay - by;
	double d = sqrt(sx * sx + sy * sy);

	OUT(d);
}

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

int main(){
  int x,y;
  cin >> x >> y;
  int a;
  if(x == 2) a = 3;
  else if(x % 2 == 0 && x < 8) a = 2;
  else if(x % 2 == 1 && x > 8) a = 2;
  else a = 1;
  int b;
  if(y == 2) b = 3;
  else if(y % 2 == 0 && y < 8) b = 2;
  else if(y % 2 == 1 && y > 8) b = 2;
  else b = 1;
  if(a == b) puts("Yes");
  else puts("No");
  return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)
#define INF 1e9

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1000000000+7;
const int MAX_N=1000;

int main(){
	int n;
	cin>>n;
	double t[n+2];
	double v[n+2];
	double T=0;
	for(int i=1;i<=n;i++){
		cin>>t[i];
		T+=t[i];
	}
	t[0]=0;
	t[n+1]=0;

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

	double f[n+2][40001];
	double tsum=0;
	for(int i=0;i<n+2;i++){
		tsum+=t[i];
		for(double j=0;j<T;j+=0.5){
			if(j<tsum-t[i]){
				f[i][(int)(j*2)]=v[i]+(tsum-t[i])-j;
			}else if(tsum-t[i]<=j && j<=tsum){
				f[i][(int)(j*2)]=v[i];
			}else{
				f[i][(int)(j*2)]=v[i]+j-tsum;
			}
		}
	}
	double sum=0;
	for(double j=0;j<T;j+=0.5){
		double min_v=1000000000;
		for(int i=0;i<n+2;i++){
			min_v=min(f[i][(int)(j*2)],min_v);
		}
		sum+=min_v*0.5;
	}
	printf("%.4f\n",sum);
	return 0;
}



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

int main() {
    int s;
    cin >> s;
    int    h = s / 3600;
    int m = (s % 3600) / 60;
    s = s % 60;
    //int m = s /60- h * 60;
    //    s = s- m * 60 -h * 3600
        
    
    cout <<h <<":" <<m <<":"<<s<< endl;
    
    return 0;
}


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

typedef long long ll;
#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    ll N;
    ll K;
    string S;

    cin >> N >> K;
    cin >> S;

    S[K-1] = S[K-1] + ('a' - 'A');

    cout << S << endl;
}


Measured memory_bytes: 256
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n;
double d, x;

int main()
{
	int i, j, k, l;
	cin>>n>>d>>x;
	double ans=0;
	int m=n;
	for(i=0;i<m;i++)
	{
		ans+=d+(2*n-1)*x/2;
		tie(d, x)=mp(((2*n+2)*d+5*x)/2/n, (double)(n+2)/n*x);
		n--;
	}
	printf("%.20lf\n", ans);
	return 0;
}
//*/

Measured memory_bytes: 256
// by azidoazideazide(C2N14)
    #include<bits/stdc++.h>
    using namespace std;
    #define pb push_back
    #define fi first
    #define se second
     
    int main(){
    	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	char c;
      	cin>>c;
      	if(islower(c)) cout<<"a\n";
      	else cout << "A\n";
    }

Measured memory_bytes: 3636
K,A,B = map(int,input().split())

c = 1
multi = 0
add = 0

if B - A <= 2:
    print(K + c)
    exit()

if B - A > 2:
    if K <= A:
        print(K + c)
        exit()

    K -= A + 1
    c = B
    multi = int((K - (K % 2)) / 2)
    add = (B - A) * multi
    c += add

    if K % 2 == 1:
        c += 1
    print(c)



Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000//10^8

/////////////////////////////////
int a[300005];

int main(){
    int k,len;cin>>k>>len;
    if(k%2==0){
        cout<<k/2;
        for(int i=1;i<=len-1;i++)cout<<" "<<k;
    }else{
        for(int i=0;i<=len-1;i++)a[i]=(k+1)/2;
        int last=len-1;
        for(int i=1;i<=len/2;i++){
            if(last==len-1){
                if(a[last]==1){
                    a[last]=0;
                    last--;
                }else{
                    a[last]--;
                }
            }else{
                if(a[last]==1){
                    a[last]=0;
                    last--;
                }else{
                    a[last]--;
                    while(last<len-1){
                    last++;
                    a[last]=k;
                    }
                }
            }
        }
        for(int i=0;i<=last;i++)cout<<a[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int a[N];
    for (int i = 0; i < N; ++i) cin >> a[i];

    int idx[N];
    iota(idx, idx + N, 0);

    vector<int> ans;
    int pass = -1;
    // 直前の周で最後に選ばれたもの
    // この周では絶対にこの箱には入っていない

    for (int k = 0; k <= K; ++k) {
        sort(idx, idx + N, [&](int i, int j) { return a[i] < a[j]; });

        int last = idx[0];
        if (last == pass) last = idx[1];
        // 残り回数が最も少ないものを最後に選ぶ
        // 2周連続で最後に選ぶことはできない

        for (int i = 0; i < N; ++i) {
            // passには入ってないので開く意味はない
            if (i != pass && i != last) {
                ans.push_back(i + 1);
                --a[i];
            }
        }

        // 最後にlastを開く
        ans.push_back(last + 1);
        --a[last];
        pass = last;
    }

    // 回数超過して開いたものがあればアウト
    if (any_of(a, a + N, [](int v) { return v < 0; })) {
        cout << -1 << endl;
    } else {
        cout << ans.size() << endl;
        for (int x : ans) cout << x << " ";
        cout << endl;
    }
    return 0;
}


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

bool can_go_all(vector<vector<int>> &map,vector<int> &path,int x){
  if(x == path.size()) return true;
  
  bool ret = false;
  if(x == 0){
    for(auto i:map.at(0)){
       if(path.at(x) == i) ret = can_go_all(map,path,x+1);
    }
    return ret;
  }
  for(auto i:map.at(path.at(x-1))){
    if(path.at(x) == i){
      ret = can_go_all(map,path,x+1);
    }
  }
  
  return ret;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> map(N);
  rep(i,M){
    int dct1,dct2;
    cin >> dct1 >> dct2;
    map.at(dct1-1).push_back(dct2-1);
    map.at(dct2-1).push_back(dct1-1);
  }
  
  vector<int> order;
  vector<vector<int>> orderindex;
  rep(i,N-1){
    order.push_back(i+1);
  }
  sort(all(order));
  do {
    orderindex.push_back(order);
  } while (next_permutation(all(order)));
  
  int cnt = 0;
  int x = 0;
  for(auto i:orderindex){
    if(can_go_all(map,i,x)) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define maxn 500005
using namespace std;
inline int read()
{
	char x = getchar();
	int lin = 0, f = 1;
	while(x < '0' || x > '9')
	{
		if(x == '-') f = -1;
		x = getchar();
	}
    while(x >= '0' && x <= '9')
	{
		lin = lin * 10 + x - '0';
		x = getchar();
	}
	return lin * f;
}
#define PII pair<int,int>
#define fir first
#define sec second
#define ma(a,b) make_pair(a,b)
int a,b;
void outz()
{
	cout << "Zero";
}
void outn()
{
	cout << "Negative";
}
void outp()
{
	cout << "Positive";
}
int main(){
	a = read(); b = read();
	if(!a || !b)
	{
		outz();
		return 0;
	}
	if(a < 0)
	{
		if(b < 0)
		{
			if(!((b - a) & 1)) outn();
			else outp();
			return 0;
		}
		if(b > 0)
		{
			outz();
			return 0;
		}
	}
	if(a > 0) outp();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

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

    int even[100200];
    int odd[100200];
    rep(i,100010){
        even[i] = 0;
        odd[i] = 0;
    }

    int maxev = 0 ,semaxev = 0;
    int maxod = 0 ,semaxod = 0;
    int numev, numod;

    //偶数入力
    for (int i = 1; i < n; i += 2) even[v[i]]++;
    //奇数入力
    for (int i = 0; i < n; i += 2) odd[v[i]]++;


    //偶数整理
    for (int i = 1; i < 100001; i++){
        if (even[i] >= maxev){
            semaxev = maxev;
            maxev = even[i];
            numev = i;
        }
        else if (even[i] >= semaxev){
            semaxev = even[i];
        }
    }

    //奇数整理
    for (int i = 1; i < 100001; i++){
        if (odd[i] >= maxod){
            semaxod = maxod;
            maxod = odd[i];
            numod = i;
        }
        else if (odd[i] >= semaxod){
            semaxod = odd[i];
        }
    }

    //回答パート
    int ans;
    if (numev != numod) ans = n - maxev - maxod;

    else ans = min(n - maxev - semaxod, n - maxod - semaxev);

    cout << ans << endl;

}

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

int main()
{
    ll a,b,c,d,e,f,g,h;
    cin>>a>>b>>c>>d;
    e=a*c;
    f=a*d;
    g=b*c;
    h=b*d;
    ll sum=max(e,f);
    sum=max(sum,g);
    sum=max(sum,h);
    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3632
short = 10
ans = 0
for i in range(5):
    n = int(input())
    if short > n%10 and n%10 > 0:
        short = n%10
    ans += (n//10)*10
    if n%10 > 0:
        ans += 10
ans -= 10 if short > 0 else 0
print(ans+short)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long h,n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>n;
    for (int i=0;i<n;i++){
        long long x;
        cin>>x;
        h-=x;
    }
    if (h>0) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
n = int(input())

dic = {}
for i in range(n):
    s = input()
    lst = [0 for j in range(30)]
    for j in range(10):
        lst[ord(s[j])-ord('a')] += 1
    string = ''.join(map(str, lst))
    if string in dic:
        dic[string] += 1
    else:
        dic[string] = 1

ans = 0
for num in dic.values():
    ans += num * (num-1) // 2

print(ans)

Measured memory_bytes: 19300
N,Q = map(int,input().split())
S = input()
r = [0 for n in range(N)]
l = [0 for n in range(N)]
cnt = 0
for s in range(N - 1):
	if S[s] == 'A':
		if S[s + 1] == 'C':
			cnt += 1
	l[s + 1] = cnt
cnt = 0
for s in range(1,N):
	if S[-s] == 'C':
		if S[-s - 1] == 'A':
			cnt += 1
	r[-s - 1] = cnt
for q in range(Q):
	L,R = map(int,input().split())
	print(cnt - l[L - 1] - r[R - 1])


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

int main(){
  long q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;
  if(n%2==0){
    cout << min(min(min(8*q, 4*h),2*s), d)*(n/2);
  }else{
    cout << min(min(4*q,2*h),s)+min(min(min(8*q, 4*h),2*s), d)*(n/2);
  }
}

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

using namespace std;

char s[50];
int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	k--;
	if (s[k]=='A') s[k]='a';
	if (s[k]=='B') s[k]='b';
	if (s[k]=='C') s[k]='c';
	printf("%s\n",s);
}

Measured memory_bytes: 256
# from time import perf_counter


def main():
    n = int(input())
    words = []
    for _ in range(n):
        words.append(input())

    categorized = []
    for word in words:
        idt = len(categorized)
        itself = word.count('AB')

        has_A_rs = word.endswith('A')
        # has_B_rs = word.endsWith('B')
        # has_A_ls = word.startsWith('A')
        has_B_ls = word.startswith('B')

        categorized.append({
            'w': word, '#': idt, 'itself': itself,
            'rA': has_A_rs, 'lB': has_B_ls
        })

    # lXrX = [w for w in categorized if not w['rA'] and not w['rB']]
    lBrA = len([w for w in categorized if w['rA'] and w['lB']])
    lBrX = len([w for w in categorized if not w['rA'] and w['lB']])
    lXrA = len([w for w in categorized if w['rA'] and not w['lB']])

    s = sum([w['itself'] for w in categorized])
    if lBrA == 0:
        s += min(lBrX, lXrA)
    elif lBrX + lXrA > 0:
        s += lBrA + min(lBrX, lXrA)
    else:
        s += lBrA - 1

    print(s)


if __name__ == '__main__':
    # s = perf_counter()
    main()
    # e = perf_counter()
    # print('process:', e - s)


Measured memory_bytes: 7156
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;

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

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long

int main() {
    int N, L;
    string S[105] = {};
    cin >> N >> L;
    rep(i, N) { cin >> S[i]; }
    sort(S, S + N);
    rep(i, N) { cout << S[i]; }
    cout << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    map<int, int> m;
    rep(i,N) {
      int a;
      cin >> a;
      if (m.count(a) > 0) m[a]++;
      else m[a] = 1;
    }
    if (m.size() <= K) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<int,int>> M2;
    for (auto x : m) M2.push_back(make_pair(x.second,x.first));
    sort(M2.begin(),M2.end());
    int M = m.size() - K;
    int c = 0;
    int i = 0;
    while (M > 0) {
        c += M2[i++].first;
        M--;
    }
    cout << c << endl;
}


Measured memory_bytes: 11768
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b){
	return b != 0 ? gcd(b, a%b) : a;
}

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

#define N_MAX 200000
#define MOD 1000000007

vector<int> edge[N_MAX];
int par[N_MAX];
int subsize[N_MAX];
int parsize[N_MAX];

void dfs(int index)
{
	for (int i = 0; i < edge[index].size(); i++){
		if (par[index] == edge[index][i]){
			continue;
		}
		par[edge[index][i]] = index;
		dfs(edge[index][i]);
	}

	return;
}

int dfs_subsize(int index)
{
	int sum = 0;
	for (int i = 0; i < edge[index].size(); i++){
		if (par[index] == edge[index][i]){
			continue;
		}
		sum += dfs_subsize(edge[index][i]);
	}
	
	return subsize[index] = sum + 1;
}

void dfs_parsize(int index)
{
	for (int i = 0; i < edge[index].size(); i++){
		if (par[index] == edge[index][i]){
			continue;
		}
		parsize[edge[index][i]] = subsize[index] - subsize[edge[index][i]] + parsize[index];
		dfs_parsize(edge[index][i]);
	}

	return;
}

lli modpow(int val)
{
	if (0 == val){
		return 1;
	}
	if (0 == val % 2){
		lli tmp = modpow(val / 2);
		return (tmp*tmp) % MOD;
	}
	else{
		return (modpow(val - 1) * 2) % MOD;
	}
}

lli modpow(lli base, lli p)
{
	if (0 == p){
		return 1;
	}
	if (0 == p % 2){
		lli tmp = modpow(base,p/2);
		return (tmp*tmp) % MOD;
	}
	else{
		return (modpow(base,p - 1) * base) % MOD;
	}
}

void solv()
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N - 1; i++){
		int A, B; scanf("%d%d", &A, &B);
		A--; B--;
		edge[A].push_back(B);
		edge[B].push_back(A);
	}

	par[0] = -1; parsize[0] = 0;
	dfs(0);
	dfs_subsize(0);
	dfs_parsize(0);

	lli sum = 0;
	sum = (sum + modpow(N - 1) - 1 + MOD) % MOD;
	for (int i = 0; i < edge[0].size(); i++){
		sum = (sum + MOD - modpow(subsize[edge[0][i]]) + 1) % MOD;
	}
	for (int i = 1; i < N; i++){
		sum = (sum + modpow(N - 1) - 1 + MOD) % MOD;
		sum = (sum + MOD - modpow(parsize[i]) + 1) % MOD;
		for (int j = 0; j < edge[i].size(); j++){
			if (par[i] == edge[i][j]){
				continue;
			}
			sum = (sum + MOD - modpow(subsize[edge[i][j]]) + 1) % MOD;
		}
	}

	printf("%lld", (sum * modpow(modpow(N), MOD - 2)) % MOD);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 20224
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String T = sc.next();
		for (int i=0;i<T.length();i++) {
			if (T.charAt(i)=='?') {
				System.out.print('D');
			} else {
				System.out.print(T.charAt(i));
			}
		}
	}
}

Measured memory_bytes: 57816