akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn],sum[2][MAXn];
ll add(ll a,ll b){
    ll ret = a + b;
    if (ret >= MOD) ret -= MOD;
    return ret;
}
int main(){
    IOS();
    ll S;
    cin >> S;
    bool roll = true;
    sum[0][0] = 1;
    for (int j=1;j<=S;++j) {
        sum[0][j] = 1;
    }
    for (int i=1;i<=S/3;++i) {
        sum[roll][0] = sum[roll][1] = sum[roll][2] = 1;
        for (int j=3;j<=S;++j) {
            dp[j] = sum[!roll][j-3];
            sum[roll][j] = add(sum[roll][j-1],dp[j]);
        }
        roll = !roll;
    }
    cout << dp[S] << endl;
}


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

int main() {
	int N;
	cin >> N;
	int divisor[25], prime[25] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}; // 約数の素因数分解結果
	memset(divisor, 0, sizeof(divisor));
	for (int i = 2, j, tmp;i <= N;++ i) for (j = 0, tmp = i;tmp > 1;++ j) for (int p = prime[j];tmp % p == 0;tmp /= p) ++ divisor[j]; // 素因数分解していくよー
	
	int ans = 0;
	for (int i = 0;i < 25;++ i) {
		if (divisor[i] >= 74) ++ ans; // a^74の形
		for (int j = 0;j < 25;++ j) {
			if (i == j) continue;
			if (divisor[i] >= 4 && divisor[j] >= 14) ++ ans; // a^4*b^14の形
			if (divisor[i] >= 2 && divisor[j] >= 24) ++ ans; // a^2*b^24の形
			for (int k = j + 1;k < 25;++ k) if (i != k && divisor[i] >= 2 && divisor[j] >= 4 && divisor[k] >= 4) ++ ans; // a^2*b^4*c^4の形
		}
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

約数を75=3*5*5個持つ→a^2*b^4*c^4、あるいはa^4*b^14、あるいはa^2*b^24、あるいはa^74の形
それぞれについて成立するか考えていくと良い
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  int now = 0, cnt = 1, ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if(a == now)
      cnt++;
    else {
      ans += cnt / 2;
      cnt = 1;
    }
    now = a;
  }
  ans += cnt / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[128];
int main() {
	a['N'] = 0;
	a['S'] = 1;
	a['E'] = 2;
	a['W'] = 3;

	string s;
	cin >> s;
	vector<bool> r(4);
	for (char c : s) r[a[c]] = true;
	cout << ((r[0] == r[1] && r[2] == r[3]) ? "Yes" : "No") << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	int answer = v[N/2]-v[N/2-1];

	cout << answer << endl;
}


Measured memory_bytes: 640
N, C, K = map(int, input().split())
users = []
for i in range(N):
    users.append(int(input()))

users = sorted(users, reverse=False)

ans = 0
pos = 0
start = 0

while True:
    count = 0

    if pos == N:
        break
        
    start = users[pos]
#     print("start:{}".format(start))
    for i in range(C):
        if pos+i < N and users[pos+i] <= start+K:
            count += 1
        else:
            break
    pos += count
#     print("pos:{}".format(pos))
    ans += 1
#     print("ans:{}".format(ans))

print(ans)

Measured memory_bytes: 8280
w, h, x, y = [int(i) for i in input().split()]

count = 0
tate_flag = False
yoko_flag = False

#縦のチェック
if (w/2 == x):
    tate_flag = True
    
#横のチェック
if (h/2 == y):
    yoko_flag = True
    

if tate_flag == True and yoko_flag == True:
    count = 1

print(w * h / 2, count)

Measured memory_bytes: 3060
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInts() (int,int) {
  var x,y int
  var s []string = strings.Split(NextLine()," ")
  x,_ = strconv.Atoi(s[0])
  y,_ = strconv.Atoi(s[1])
  return x,y
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var a []int = make([]int,len(s))
  for i:=0;i<len(s);i++ {
    a[i],_ = strconv.Atoi(s[i])
    a[i]--
  }
  return a
}

var par,rank []int
func main() {
  var n,m int = NextInts()
  var p []int = NextIntArray()
  var x,y int
  initialize(n)
  for i:=0;i<m;i++ {
    x,y = NextInts()
    unite(x-1,y-1)
  }
  var s int
  for i:=0;i<n;i++ {
    if same(i,p[i]) { s++ }
  }
  fmt.Println(s)
}
func initialize(n int) {
  par = make([]int,n)
  rank = make([]int,n)
  for i:=0;i<n;i++ {
    par[i] = i
  }
}
func root(i int) int {
  if par[i] == i { return i }
  par[i] = root(par[i])
  return par[i]
}
func same(i,j int) bool {
  return root(i) == root(j)
}
func unite(i,j int) {
  i = root(i)
  j = root(j)
  if i == j { return }
  if rank[i] < rank[j] {
    par[i] = j
  } else {
    par[j] = i
    if rank[i] == rank[j] { rank[i]++ }
  }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  int Q;
  cin >> Q;
  vector<int> x(Q), y(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> x[i] >> y[i];
    --x[i], --y[i];
  }

  vector<int> aa = a;
  sort(aa.begin(), aa.end());

  int same = 0;
  for (int i = 0; i < N; ++i)
    if (a[i] == aa[i])
      ++same;

  int ans = -1;
  if (same == N)
    ans = 0;
  for (int i = 0; i < Q && ans == -1; ++i) {
    swap(a[x[i]], a[y[i]]);

    if (a[y[i]] != aa[x[i]] && a[x[i]] == aa[x[i]])
      ++same;
    if (a[y[i]] == aa[x[i]] && a[x[i]] != aa[x[i]])
      --same;
    if (a[x[i]] != aa[y[i]] && a[y[i]] == aa[y[i]])
      ++same;
    if (a[x[i]] == aa[y[i]] && a[y[i]] != aa[y[i]])
      --same;

    if (same == N)
      ans = i + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 7640
#include <stdio.h>
 
int main(){
    int i, j, a;
    for(i = 1; i < 10; i++){
        for(j = 1; j < 10; j++){
            a = i * j;
            printf("%dx%d=%d\n", i, j, a);
        }
    }
    return 0;
} 

Measured memory_bytes: 2508
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<malloc.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, w[1010], to[10100], a[1010];
vector<int> G[10100];
bool used[10100];

signed main(){
    cin >> N;
    int mn = INF;
    for(int i = 0; i < N; i++){
        cin >> w[i];
        a[i] = w[i];
        mn = min(mn, w[i]);
    }
    sort(a, a + N);
    for(int i = 0; i < N; i++){
        to[a[i]] = i;
        //printf("%d to %d\n", a[i], w[i]);
    }
    for(int i = 0; i < N; i++){
        if(i != to[w[i]]){
            G[w[i]].push_back(w[to[w[i]]]);
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(used[w[i]])continue;
        used[w[i]] = true;
        queue<int> que;
        que.push(w[i]);
        int V = 0, m = INF, S = 0;
        while(!que.empty()){
            int pos = que.front();
            que.pop();
            V++;
            S += pos;
            m = min(m, pos);
            //printf("%d: %d\n", i, pos);
            for(int j = 0; j < (int)G[pos].size(); j++){
                int eto = G[pos][j];
                if(!used[eto]){
                    que.push(eto);
                    used[eto] = true;
                }
            }
        }
        //printf("%d: V:%d m:%d S:%d res:%d\n", i, V, m, S, (V - 1) * m + S - m);
        int res1 = (V - 1) * m + S - m;
        int res2 = (V - 1) * mn + S - m + (m + mn) * 2;
        ans += min(res1, res2);
    }
    cout << ans << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 3444
package main

import "fmt"
import "strconv"

func main() {
	var S string
	var s1 int // 1st half
	var s2 int // 2nd half
	fmt.Scan(&S)

	s1, _ = strconv.Atoi(S[0:2])
	s2, _ = strconv.Atoi(S[2:4])

	var yymm, mmyy bool

	if s2 < 13 && s2 > 0 {
		yymm = true
	}
	if s1 < 13 && s1 > 0 {
		mmyy = true
	}

	if yymm && mmyy {
		fmt.Println("AMBIGUOUS")
	} else if yymm && !mmyy {
		fmt.Println("YYMM")
	} else if !yymm && mmyy {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}

}


Measured memory_bytes: 1772
As=[]
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
N=int(input())
is_bingo=False
n=0
while n<N:
  n+=1
  b=int(input())
  for i in range(3):
    for j in range(3):
      if As[i][j] == b:
        As[i][j]=0
  for _ in range(1):
    if As[0][0]+As[0][1]+As[0][2]==0:
      is_bingo=True
      break
    if As[1][0]+As[1][1]+As[1][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[2][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][0]+As[2][0]==0:
      is_bingo=True
      break
    if As[0][1]+As[1][1]+As[2][1]==0:
      is_bingo=True
      break
    if As[0][2]+As[1][2]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[1][1]+As[0][2]==0:
      is_bingo=True
      break

if is_bingo:
  print('Yes')
else:
  print('No')



Measured memory_bytes: 3064
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = sc.nextInt();
        }
        a[0] = b[0];
        for (int i = 1; i < n - 1; i++) {
            a[i] = Integer.min(b[i - 1], b[i]);
        }
        a[n - 1] = b[n - 2];
        System.out.println(IntStream.of(a).sum());
    }
}


Measured memory_bytes: 28104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		int[] a = new int[n];
		int[] b = new int[n];
		int count = 0;
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if(a[i]>=h && b[i]>=w) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 25700
#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

int swap(int &a,int &b){
	int c;
	c=a;
	a=b;
	b=c;

	return 0;
}


int main(){
	int x,y,z;
	cin>>x>>y>>z;
	if(x>y){
		swap(x,y);
	}
	if(y>z){
		swap(y,z);
	}
	if(x>y){
		swap(x,y);
	}
	cout<<x<<" "<<y<<" "<<z<<endl;
	return 0;
}

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

#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;for(int cc=1;cc<=tt;cc++)

signed main()
{
    int n,m,i;
    cin>>m>>n;
    int a[n],sum=0;
    for(i=0;i<n;i++) {cin>>a[i];sum+=a[i];}
    if(sum>m) cout<<-1;
    else cout<<m-sum;
}


Measured memory_bytes: 3672
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    Q = input()
    x = tuple(map(int,input().split()))
    for k in x:
        d,m,dm,dmc = 0,0,0,0
        for i in range(N):
            st = S[i]
            if st == "D":
                d += 1
            elif st == "M":
                m += 1
                dm += d
            elif st == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 51520
N, K = map(int, input().split())

def calculate_Expectation(n):
    n = int(n)
    p = 1/n
    e = p * (n*(n+1)/2)
    return e

E = list(map(calculate_Expectation, input().split()))
if N == K:
    print(sum(E))
else:
    S = [0]
    for i, e in enumerate(E):
        S.append(S[i]+e)

    sum_of_E = []
    for left in range(1, N+1-K):
        right = left + K
        sum_of_E.append(S[right]-S[left])
    print(max(sum_of_E))

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

int n, m;
string a, b;
int dp[3001][3001];

void rec(int m, int n)
{
	if(m == 0) return;
	if(dp[n][m] == dp[n][m - 1]) rec(m - 1, n);
	else if(dp[n-1][m] == dp[n][m]) rec(m, n - 1);
	else rec(m - 1, n - 1), cout << b[m];
}

main()
{
	ios::sync_with_stdio(0);
	cin >> a >> b;
	
	a = " " + a; b = " " + b;
	n = a.size() - 1, m = b.size() - 1;
	//cout << "  ";
	for(int i = 1; i < a.size(); i++)
	{
		//cout << a[i] << "|";
		for(int j = 1; j < b.size(); j++)
		{
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(a[i] == b[j])
				dp[i][j] = dp[i - 1][j - 1] + 1;
		}
	}
	
	//cout << endl;
	//for(int i = 1; i <= m; i++)
	//{
		//cout << b[i] << "|";
		//for(int j = 1; j <= n; j++)
		//{
			//cout << dp[j][i] << "|";
		//}
		
		//cout << endl;
		//for(int j = 1; j <= n * 2 + 2; j++)
			//cout << "-";
		//cout << endl;
	//}
	
	rec(m, n);
}


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

using namespace std;

const int MAX = 51;
typedef pair<int,int> PP;
typedef pair<int,PP> P;
 
int main(){
    int t,p,r,tID,pID,time;
    string judge;
 
    while(cin >> t >> p >> r ,t + p + r){
	int ans[MAX][MAX] = {{0}},pe[MAX][MAX] = {{0}},AC[MAX]={0};
	while(r--){
	    cin >> tID >> pID >> time >> judge;
 
	    if(judge == "CORRECT"){
		ans[tID][pID] += time+pe[tID][pID];
		AC[tID]++;
	    }
	    else{
		pe[tID][pID] += 1200;
	    }
	}
 
	vector<P> v(t);
	for(int i = 0 ; i < t ; i++){
	    for(int j = 0 ; j < p ; j++){
		v[i].second.first += ans[i+1][j+1];
	    }
	    v[i].first = -AC[i+1];
	    v[i].second.second = i+1;
	}
	sort(v.begin(),v.end());
	for(int i = 0 ; i < t ; i++){
	    cout << v[i].second.second << ' ' << -v[i].first 
		 << ' ' << v[i].second.first << endl; 
	}
    }
    return 0;
}

Measured memory_bytes: 3004
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 27;
string s;
bool vis[26];
set<int> st;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>s;
    rep(i,0,26)st.insert(i);
    rep(i,0,s.size())
    {
        if(!vis[s[i]-'a'])st.erase(s[i]-'a');
        vis[s[i]-'a']=1;
    }
    if(s.size()<26)
    {
        s.pb(*st.begin()+'a');
        cout<<s;
        return 0;
    }
    rrep(i,s.size()-1,0)
    {
        rep(j,s[i]-'a'+1,26)
        {
            if(!vis[j])
            {
                st.insert(s[i]-'a');
                st.erase(j);
                s[i] = j+'a';
                rep(k,0,i+1)
                {
                    cout<<s[k];
                }
                return 0;
            }
        }
        vis[s[i]-'a']=false;
        st.insert(s[i]-'a');
    }
    cout <<-1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin>>A>>B;
  if((B-1)%(A-1)==0){
    cout<<(B-1)/(A-1)<<endl;
  }
  else{
    cout<<(B-1)/(A-1)+1<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  float d, t, s;
  scanf("%f %f %f", &d, &t, &s);
  if (d / s <= t)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1728
# 参考:http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3286382#1

while 1:
    n = int(input())
    if n == 0:
        break

    words,dic = [],[]
    for i in range(n):
        data = list(input().split())
        for d in data:
            words.append(d)

    k = input()
    setWords = list(set(words))

    for w in setWords:
        if w[0] == k:
            dic.append([w, words.count(w)])

    dic = sorted(dic, key=lambda x: (-x[1], x[0]))
    if dic == []:
        print("NA")
    else:
        print(' '.join(d[0] for d in dic[:5]))


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<bool>> graph(n,vector<bool> (n,false));
  for(int i = 0; i < m ; ++i){
    int a,b;
    cin >> a>>b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }
  vector<int> v(n);
  for( int i = 0; i<n; ++i) v[i] = i;
  int ans = 0;
  do{
    bool ok = true;
    for( int i = 1;i < n;++i) if(graph[v[i-1]][v[i]] == false) ok = false;
    if(ok) ans++;
    } while ( next_permutation(++v.begin(),v.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final boolean[] acArray = new boolean[n + 1];
        final int[] waArray = new int[n + 1];
        for (int i = 0; i < m; i++) {
            final int p = scanner.nextInt();
            final String result = scanner.next();
            if (acArray[p]) {
                continue;
            }

            if ("WA".equals(result)) {
                waArray[p]++;
            } else {
                acArray[p] = true;
            }
        }

        int acceptedCount = 0;
        int wrongAnswerCount = 0;
        for (int i = 1; i < n + 1; i++) {
            if (!acArray[i]) {
                continue;
            }

            acceptedCount++;
            wrongAnswerCount += waArray[i];
        }

        System.out.println(acceptedCount + " " + wrongAnswerCount);
    }
}


Measured memory_bytes: 63732
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<string.h>
using namespace std;

struct node
{
    double x,y;
};

double PI=acos(-1.0);
int n;
node p[111];
double ans[111];

void merge(double &from,double &to,double ff,double tt)
{
    if(from>ff)
    {
        swap(from,ff);
        swap(to,tt);
    }
    
    
    if(to==-2.0*PI)
    {
        from=ff;to=tt;
        return ;
    }
    
    double f0,t0;
    
    
    f0=max(from,ff);
    t0=min(to,tt);
    
    if(f0<=t0)
    {
         from=f0;to=t0;
         return ;
    }
    
    if(tt>PI)
    {
        ff-=2.0*PI;
        tt-=2.0*PI;
        f0=max(from,ff);
        t0=min(to,tt);
    }
    
    from=f0;to=t0;
    return ;
}


int main()
{
    int i,j,k;
    double from,to;
    
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>p[i].x>>p[i].y;
    }
    for(i=1;i<=n;i++)
    {
        from=-PI*4.0;
        to=-PI*2.0;
            
        for(j=1;j<=n;j++)
        {
            if(i==j)continue;
            
            
            node l;
            l.x=p[j].x-p[i].x;
            l.y=p[j].y-p[i].y;
            
            double e=atan2(l.x,l.y);
            //cout<<atan2(0,-1)<<endl;
            e+=PI/2.0;
            if(e>PI)e-=2.0*PI;
            double ff,tt;
            ff=e;tt=e+PI;
            
            //cout<<ff<<' '<<tt<<"   %%%"<<endl;
            merge(from,to,ff,tt); 
            //cout<<from<<' '<<to<<endl;
        }
        
        cout.precision(7);
        cout.setf(ios::fixed);
        cout<<max((to-from)/(PI*2.0),0.0)<<endl;
    }
    return 0;
}


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

struct katana
{
    int a,b;
};
bool cmp (katana a, katana b)
{
    if(a.a>b.a)
        return true;
    return false;
}
katana v[200010];
int main()
{
    long long n,h,i,j,s=0,cnt=1;
    cin>>n>>h;
    for(i=1; i<=2*n; i++)
    {
        cin>>v[i].a>>v[i+1].a;
        v[i+1].b=1;
        i++;
    }
    sort(v+1,v+2*n+1,cmp);
    n=n*2;
    i=1;
    while(v[i].b==1 && s<h)
    {
        s+=v[i].a;
        i++;
    }
    h-=s;
    if(h>0)
    {
        if(h%v[i].a==0)
            cout<<i-1+h/v[i].a;
        else
            cout<<i-1+h/v[i].a+1;
    }
    else
        cout<<i-1;
    return 0;
}

Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut ans = 1000 - n % 1000;
    if ans == 1000 {
        ans = 0;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2164
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    vector<int> nums;
    int now = 1;
    int cnt = 0;
    for (int i = 0; i < N; i++){
        if (S[i] == (char)(now + '0')) cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
            now = 1 - now;
        }
    }
    if (cnt != 0) nums.push_back(cnt);
    
    if (nums.size() % 2 == 0) nums.push_back(0);
    
    vector<int> sums(nums.size() + 1);
    for (int i = 0; i < nums.size(); i++){
        sums[i + 1] = sums[i] + nums[i];
    }
    
    int Add = 2 * K + 1;
    int ans = 0;
    for (int i = 0; i < nums.size(); i += 2){
        int left = i;
        int right = min(i + Add, (int)nums.size());
        int tmp = sums[right] - sums[left];
        ans = max(tmp, ans);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
long long n,k;
cin>>n>>k;
vector<long long> v(n);

for(int i=0;i<n;i++){
    cin>>v[i];
}
vector<bool> dp(k+1,0);
for(int i=1;i<=k;i++){
    for(auto val : v){
        if(val > i)
            continue;
        dp[i]=dp[i]||(!dp[i-val]);
    }

}
if(dp[k])
    cout<<"First\n";
else
    cout<<"Second\n";

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N-1):
    if A[i+1] - A[i] == 1:
        ans += C[A[i]-1]

print(ans+sum(B))

Measured memory_bytes: 3064
// ALDS1_12_A: Minimum Spanning Sort
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
bool debug = false;
const int INF = 100000;
// const int BK = 0, GR = 1, WT = 2;

std::vector<std::vector<int>> adjacency_list;
std::vector<int> node_stats;
std::vector<std::pair<int, int>> weight_memo;

int PrimAlgorithm(int weight, int vertex) {
    node_stats.at(vertex) = 1;
    
    for (int i=0; i<adjacency_list.at(vertex).size(); i++) {
        int tmp_vertex = i;
        if (adjacency_list.at(vertex).at(tmp_vertex) != -1) {
            std::pair<int,int> tmp = std::make_pair(tmp_vertex, adjacency_list.at(vertex).at(tmp_vertex));
            weight_memo.push_back(tmp);
        }
    }
    
    int minimum_weight = INF, next_vertex = -1;
    for (int i=0; i<weight_memo.size(); i++) {
        int tmp_vertex = weight_memo.at(i).first, tmp_weight = weight_memo.at(i).second + weight;
        if (tmp_weight < minimum_weight) {    
            if (node_stats.at(tmp_vertex) == 0) {
                next_vertex = tmp_vertex;
                minimum_weight = tmp_weight;
            }
        }
    }
    if (debug) std::cout << "next_vertex = " << next_vertex << ", minimum_weight = " << minimum_weight << "\n";
    if (next_vertex == -1) {
        return weight;
    }
    return PrimAlgorithm(minimum_weight, next_vertex);
}

int main() {
    int total_num; std::cin >> total_num;
    adjacency_list.resize(total_num);
    for (int i=0; i<adjacency_list.size(); i++) adjacency_list.at(i).resize(total_num);
    for (int i=0; i<total_num; i++) {
        for(int j=0; j<total_num; j++) {
            std::cin >> adjacency_list.at(i).at(j);
        }
    }

    node_stats.resize(total_num);
    for (int i=0; i<node_stats.size(); i++) node_stats.at(i) = 0;

    int result = PrimAlgorithm(0, 0);
    std::cout << result << "\n";
}


Measured memory_bytes: 3144
def II(H, W):
    return 0 if W%3 == 0 else H

def T(H, W):
    if W%2 == 0:
        return W/2
    a = (H-1)/3 if H%3==1 else (H+1)/3
    b = (W+1)/2 * (H-a)
    c = (W-1)/2 * (H-a)
    a = a*W
    return max(a, b, c) - min(a, b, c)

H,W = map(int, raw_input().split())
print min(II(H, W), II(W, H), T(H, W), T(W, H))

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int n,a[N];
bool check(int x){
	map<int,int> M;
	For(i,2,n){
		if(a[i]<=a[i-1]){
			M[a[i]]++;
			while(1){
				auto it=M.end();
				it--; if(it->fi>a[i])M.erase(it); else break;
			}
			int len=a[i]; //cout<<len<<" "<<M[len]<<endl;
			while(M[len]==x){
				if(len==1||x==1)return 0;
				M.erase(len); M[--len]++;
			}
		}
	}
	return 1;
}
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	//cout<<check(2)<<endl; return 0;
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1; 
		if(check(mid))r=mid; else l=mid+1;
		//cout<<l<<" "<<r<<endl;
	}
	cout<<l<<endl;
}

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

int main(){
    char str[11];
    scanf("%s", str);
    int len = strlen(str);
    char stro[11];
    int k = 0;
    for(int i = 0; i<len; i++){
        if(str[i] == 'B'){
        	if(i < len-1){
        		if(k>0){
            		k--;
        		}
            }
            else{
            	k--;
            	str[k] = '\b';
            }
        }
        else{
            stro[k] = str[i];
            k++;
        }
    }
    stro[k] = '\0';
    printf("%s\n", stro);
    
    return 0;
}

Measured memory_bytes: 1632
n, m = map(int, input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]

ans = 'No'
for i in range(n - m + 1):
    C = []
    for j in range(n):
        C.append(A[j][i : i + m])
    for k in range(n - m +1):
        if B == C[k : k + m]:
            ans = 'Yes'
            break
            
print(ans)

Measured memory_bytes: 3064
// AGC27A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
	int N, x;
	int a[101];
	cin >> N >>x;
	for (int i = 1; i <= N; i++) cin >> a[i];
	sort(a + 1, a + N + 1);
	//for (int i = 1; i <= N; i++) cout<< a[i];
	
	int count = 0;
	int sum = 0;
	for (int i = 1; i <= N; i++) 
	{
		if (x <a[i]) break;
		if (i == N && a[i] != x)break;
		x = x - a[i];
		//sum += a[i];
		count++;
		//cout << sum;
	}

	cout << count << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int H,N,i,asum=0,Ai;
    scanf("%d %d",&H,&N);
    for(i=0;i<N;i++){
        scanf("%d",&Ai);
        asum+=Ai;
    }
    if(asum>=H)printf("Yes\n");
    if(asum<H)printf("No\n");
}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc169/tasks/abc169_c
 * Multiplication 3
 */
public class Main {
	public static void main(String...args) {
		try (Scanner sc= new Scanner(System.in)) {
			BigDecimal a = BigDecimal.valueOf(sc.nextLong());
			BigDecimal b = BigDecimal.valueOf(sc.nextDouble());
			BigInteger ans = a.multiply(b).toBigInteger();
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 29232
/******************************************************************************

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

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

#include <bits/stdc++.h>

using namespace std;

int main()
{   
    long long a,b,x,g1,g2,cnt=0,w,ra1=500,ra2=500;
    cin>>a>>b>>x;
    if(a%x==0){g1=a/x;}
    else{g1=(a/x)+1;}
    g2=b/x;
    cout<<g2-g1+1;
    return 0;
}


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

int main(void) {
  char X, Y;
  cin >> X >> Y;
  if (X < Y)
    cout << '<' << endl;
  else if (X > Y)
    cout << '>' << endl;
  else
    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 inf 10000000000000;
typedef long long ll;



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

    unordered_map<string,int>mp={};

    rep(i,n){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
        
    }


    ll ans =0;

    for(auto & m :mp){
        ll s = m.second;
        ans += s*(s-1)/2;
    }

    
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
const int INF=LLONG_MAX;
const int N_MAX=100000;
int N,K;
vector<int> h;
int dp[N_MAX];

signed main(){
    cin>>N>>K;
    h.resize(N);
    REP(i,N) cin>>h[i];
    dp[N-1]=0;
    for(int i=N-2;i>=0;--i){
        int ret=INF;
        for(int j=1;j<=K;++j){
            if(i+j<N) ret=min(ret,dp[i+j]+llabs(h[i+j]-h[i]));
        }
        dp[i]=ret;
    }
    cout<<dp[0]<<endl;
}

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

using namespace std;
typedef vector<int> vi;
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORE(x,xs) for (auto x : xs)

const int MAX = 1e5+10;

int N;
vi child[MAX];

int dfs(int n) {
    if (child[n].size() == 0) return 0;
    vi sub;
    FORE (c, child[n]) {
        sub.push_back(dfs(c));
    }
    sort(sub.rbegin(), sub.rend());
    int mx = 0;
    FOR (i, 0, sub.size()) {
        mx = max(mx, sub[i] + i+1);
    }
    return mx;
}

int main() {
    cin >> N;
    FOR (i, 1, N) {
        int a;
        cin >> a;
        child[--a].push_back(i);
    }

    cout << dfs(0) << endl;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1000000007;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
 
}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 
}
 
 
int main()
{
    fast();
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans1=a*c,ans2=b*d,ans3=a*d,ans4=b*c;
    cout<<max(max(ans1,ans2),max(ans3,ans4));
 
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
long p[100003];
long solve(const string& S,long o){
  if(S.length()-o==1)return 2*(S[o]=='1')+1;
  if(S[o]=='0')return solve(S,o+1);
  return (p[S.length()-o-1]+2*solve(S,o+1))%M;
}void init(){long x=1;for(long i=0;i<100003;i++){p[i]=x;x=x*3%M;}}
int main(){init();string S;cin>>S;cout<<solve(S,0);}

Measured memory_bytes: 2816
#include <stdio.h>

int main(void){
int i=1,a,b;
while(i){
scanf("%d",&a);
scanf("%d",&b);
if(a==0&&b==0){
break;
     } 
if(a>b) printf("%d %d\n",b,a);
else if(a<=b) printf("%d %d\n",a,b);
}
return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(x - a - (((x - a) / b) * b));

  }
}

Measured memory_bytes: 35648
N, Q = map(int, input().split())
S = input()
 
C = [0]
 
cnt = 0
flg = False
for s in S:
  if flg:
    if s == 'C':
      cnt += 1
    flg = False
  if s == 'A':
    flg = True
  C.append(cnt)
 
for i in range(Q):
  l, r = map(int, input().split())
  ans = C[r] - C[l-1]
  if l-2 >= 0 and S[l-1] == 'C' and S[l-2] == 'A':
    ans -= 1
  print(ans)

Measured memory_bytes: 6148
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A;
int X[50];
long long dp[5001];
long long nx[5001];
int main(){
  int i, k, m;
  long long res;
  rd(N);
  rd(A);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
    }
  }
  dp[2500] = 1;
  for(m=0;m<(N);m++){
    k = X[m] - A;
    for(i=(100);i<(4901);i++){
      nx[i] = dp[i] + dp[i+k];
    }
    for(i=0;i<(5001);i++){
      dp[i] = nx[i];
    }
  }
  res = dp[2500] - 1;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190829-1

// --- original code ---
// int N, A, X[50];
// ll dp[5001], nx[5001];
// {
//   int i, k, m;
//   ll res;
//   rd(N,A,X(N));
//   dp[2500] = 1;
//   rep(m,N){
//     k = X[m] - A;
//     rep(i,100,4901) nx[i] = dp[i] + dp[i+k];
//     rep(i,5001) dp[i] = nx[i];
//   }
//   res = dp[2500] - 1;
//   wt(res);
// }


Measured memory_bytes: 384
import java.util.*;
class Main{
    public static void main(String[] args){
      	Scanner sc=new Scanner(System.in);
        String S=sc.next();
      	boolean f= (S.charAt(0)==S.charAt(1))&&(S.charAt(2)==S.charAt(1));
      	System.out.println(f?"No":"Yes");
    }
}

Measured memory_bytes: 35736
# coding: utf-8
#lines = <<'EOS'
#4
#1 2 2 4
#2 1 4
#3 0
#4 1 3
#EOS

def fib(n)
  if n == 1 or n == 2
    1
  else
    n_1 = 1
    n_2 = 1
    tmp = 0
    for x in 3..n
      tmp = n_1 + n_2
      n_2 = n_1
      n_1 = tmp
    end
    tmp
  end
end

lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i

puts fib(N+1)

Measured memory_bytes: 6860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	public static void main(String[] args){
		try(final Scanner sc = new Scanner(System.in)){
			final String s = sc.next();
			
			final String expr = "^A?KIHA?BA?RA?$";
			
			System.out.println(s.matches(expr) ? "YES" : "NO");
		}
	}
	
	public static class Scanner implements AutoCloseable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n){
			int[] ret = new int[n];
			for(int i = 0; i < n; i++){ ret[i] = nextInt(); }
			return ret;
		}
		public long[] nextLongArray(int n){
			long[] ret = new long[n];
			for(int i = 0; i < n; i++){ ret[i] = nextLong(); }
			return ret;
		}
		public double[] nextDoubleArray(int n){
			double[] ret = new double[n];
			for(int i = 0; i < n; i++){ ret[i] = nextDouble(); }
			return ret;
		}

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}


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

int main () {
    
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" <<endl;

    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using lint = long long;

struct point {
    lint x, y;
    point(lint x_ = 0, lint y_ = 0): x(x_), y(y_) { }
    point operator- (const point &p) const {
        return point(x - p.x, y - p.y);
    }
    long double sz() { return sqrt(x * x + y * y); }
    void scan() {
        scanf("%lld%lld", &x, &y);
    }
};

const int N_ = 1050;
int N;
point D[N_]; int R[N_];

long double tb[N_];
bool vis[N_];

int main() {
    D[0].scan();
    D[1].scan();
    scanf("%d", &N); N+=2;
    for(int i=2; i<N; i++) {
        D[i].scan();
        scanf("%d", &R[i]);
    }
    
    // from 0 to 1
    fill(tb, tb+N, 1e18);
    tb[0] = 0;
    for(int rep = 0; rep < N; rep++) {
        int u = -1;
        for(int i = 0; i < N; i++) {
            if(!vis[i] && (u == -1 || tb[u] > tb[i])) u = i;
        }
        assert(u >= 0);
        vis[u] = true;
        for(int v = 0; v < N; v++) if(!vis[v]) {
            long double c = max((long double)0.0, (D[u] - D[v]).sz() - R[u] - R[v]);
            tb[v] = min(tb[v], tb[u] + c);
        }
    }
    
    printf("%.20Lf\n", tb[1]);
    
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int p, q; cin >> p >> q;
		if (p == 0 && q == 0) break;
		vector<int> a(p), r(p + 1), c(p + 1), s(p + 1);
		for (int i = 0; i < p; i++) {
			string S; cin >> S;
			for (int& j = a[i]; S[j] == '.'; j++);
			r[i + 1] = r[i];
			c[i + 1] = c[i];
			s[i + 1] = s[i];
			for (int j = 0; j < S.length(); j++)
				switch (S[j]) {
				case '(': r[i + 1]++; break;
				case ')': r[i + 1]--; break;
				case '{': c[i + 1]++; break;
				case '}': c[i + 1]--; break;
				case '[': s[i + 1]++; break;
				case ']': s[i + 1]--; break;
				}
		}
		int _r = 0, _c = 0, _s = 0;
		while (q--) {
			set<int> st;
			for (int R = 1; R <= 20; R++)
				for (int C = 1; C <= 20; C++)
					for (int S = 1; S <= 20; S++) {
						bool flag = true;
						for (int i = 0; i < p; i++)
							if (r[i] * R + c[i] * C + s[i] * S != a[i])
								flag = false;
						if (flag) st.insert(_r * R + _c * C + _s * S);
					}
			cout << (st.size() == 1 ? *st.begin() : -1);
			cout << (q ? ' ' : '\n');
			string S; cin >> S;
			for (int j = 0; j < S.length(); j++)
				switch (S[j]) {
				case '(': _r++; break;
				case ')': _r--; break;
				case '{': _c++; break;
				case '}': _c--; break;
				case '[': _s++; break;
				case ']': _s--; break;
				}
		}
	}
}

Measured memory_bytes: 1212
import operator
from functools import reduce
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

positives = [a for a in A if a > 0]
negatives = [a for a in A if a < 0]
positive_cnt = len(positives)
negative_cnt = len(negatives)
zero_cnt = A.count(0)


if 2 * min(K // 2, negative_cnt // 2) + positive_cnt >= K:
    ans = 1
    positives.sort(key=lambda x: abs(x), reverse=True)
    negatives.sort(key=lambda x: abs(x), reverse=True)

    if K % 2 == 1:
        ans *= positives.pop(0)
        K -= 1

    X = []
    for pair in zip(*[iter(positives)] * 2):
        X.append(reduce(operator.mul, pair, 1))
    for pair in zip(*[iter(negatives)] * 2):
        X.append(reduce(operator.mul, pair, 1))
    X.sort(reverse=True)

    ans *= reduce(lambda a, b: a * b % MOD, X[:K // 2], 1)
    print(ans % MOD)

elif zero_cnt:
    print(0)

else:
    A.sort(key=lambda x: abs(x))
    print(reduce(lambda a, b: a * b % MOD, A[:K], 1) % MOD)


Measured memory_bytes: 32424
module solution;
import std.stdio;

int ds (int a, int b)
{
	return (a % b == 0) ? 1 + ds (a / b, b) : 0;
}

void main ()
{
	int d, n;
	while (readf (" %s %s", &d, &n) > 0)
	{
		for (int v = 1; ; v++)
		{
			auto t = ds (v, 100);
			if (t == d)
			{
				n -= 1;
				if (n == 0)
				{
					writeln (v);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int isprime(int);

int main(){
  int num,i,n[10000],sum = 0;

  scanf("%d",&num);
  if(num < 1 || num > 10000) exit(1);

  for(i = 0;i < num;i++){
    scanf("%d",&n[i]);
    if(n[i] < 2 || n[i] > 100000000) exit(2);
  }

  for(i = 0;i < num;i++) sum += isprime(n[i]);

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

  return 0;
}

int isprime(int x){
  int i = 3;

  if(x == 2) return 1;
  if(x % 2 == 0) return 0;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i += 2; 
  }

  return 1;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    long long N; cin >> N;
    vector<string> s(N); REP(i, N) cin >> s[i];

    map<string, long long> um;

    // まずは要素ごとにソートする
    long long result = 0;
    REP(i, N) {
        sort(s[i].begin(), s[i].end());
        if(um[s[i]] > 0) {
            result += um[s[i]];
            um[s[i]]++;
        } else {
            um[s[i]] = 1;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
#define mod 1000000007

int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n+10];
	for(int i=0;i<n;i++) cin>>a[i];
	ll sum=0;
	for(int i=0;i<n-1;i++)
	{
		sum+=min(k,a[i+1]-a[i]);
	}
	cout<<sum+k<<endl;
}

Measured memory_bytes: 1792
n=int(input())
T=list(map(int,input().split()))
m=int(input())
PX=[list(map(int,input().split())) for _ in range(m)]

for i in range(m):
  ans=0
  for j in range(n):
    if j==PX[i][0]-1:
      ans+=PX[i][1]
    else:
      ans+=T[j]
  print(ans)

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

int main()
{
    LL n;
    cin>>n;
    LL ans=0;
    for(LL tmp1=1; tmp1<=9; tmp1++)
    {
        for(LL tmp2=1; tmp2<=9; tmp2++)
        {
            LL a=0;
            LL b=0;
            for(int i=1; i<=n; i++)
            {
                LL len=0;
                LL k=i;
                do
                {
                    k/=10;
                    len++;
                }
                while(k>0);
                LL kk=pow(10,len-1)+0.0001;
                if(i%10==tmp1)
                {
                    if((i/kk)==tmp2)
                        a++;
                }
                if(i%10==tmp2)
                {
                    if((i/kk)==tmp1)
                        b++;
                }
            }
            ans+=a*b;
        }
    }
    cout<<ans;
}


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

string s;
int n,m,h[200000],z[200000],a[200000],b[200000],ans;

int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>h[i];
        z[i]=1;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        if(h[a[i]-1]<h[b[i]-1]){
            z[a[i]-1] = 0;
        }
        if(h[a[i]-1]>h[b[i]-1]){
            z[b[i]-1] = 0;
        }
        if(h[a[i]-1]==h[b[i]-1]){
            z[a[i]-1] = 0;
            z[b[i]-1] = 0;
        }
    }

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

    cout<<ans<<endl;





}


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

int main(){
	int H,W;
	cin >> H >> W;
	
	int field[H+2][W+2];
	
	for(int i=0;i<H;i++){
		string line;
		cin >> line;
		for(int s=0;s<W;s++){
			field[i+1][s+1] = line.at(s);
		}
	}

	for(int i=1;i<H+1;i++){
		for(int s=1;s<W+1;s++){
			
			if(field[i][s] == '#'){
				cout << '#';
			}else{
				int count = 0;
				
				if(field[i-1][s-1] == '#'){count++;};
				if(field[i-1][s] == '#'){count++;};
				if(field[i-1][s+1] == '#'){count++;};
				if(field[i][s-1] == '#'){count++;};
				if(field[i][s] == '#'){count++;};
				if(field[i][s+1] == '#'){count++;};
				if(field[i+1][s-1] == '#'){count++;};
				if(field[i+1][s] == '#'){count++;};
				if(field[i+1][s+1] == '#'){count++;};

				cout << count;
			}
		}
		cout << endl;
	}
}

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

int main(){
    int N, A[100001], B[100000];
    cin >> N;
    for(int i=0; i<=N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        for(int k=0; k<2; k++){
            int d = min(A[i+k], B[i]);
            ans += d;
            A[i+k] -= d;
            B[i] -= d;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024