akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int k,x; cin>>k>>x;
    if (500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum= sum+A.at(i)*A.at(j);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n; cin >> n;
  vector<string> v;
  vector<int> a;
  int pts=0;
  for(int i=0;i<n;i++){
    string s; cin >> s;
    v.push_back(s);
    a.push_back(s.size());
  }
  for(int i=1;i<n;i++){
    if(v[i][0] != v[i-1][a[i-1]-1]){
      cout << "No" << endl;
      return 0;
    }else{
      for(int j=0;j<i;j++){
        if(v[i] == v[j]){
          cout << "No" << endl;
          return 0;
        }
      }
      pts++;
    }
  }
  if(pts==n-1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod=1e9+7;

int main(){
  int n, k;
  cin >> n >> k;
  deque<int> deq;
  rep(i,n){
    int tmp;
    cin >> tmp;
    deq.push_back(tmp);
  }
  int ans=0;
  for(int i=0; i<=k && i<=n; i++){
    for(int j=0; i+j<=k && i+j<=n; j++){
      if(!i && !j)
      	continue;
      multiset<int> ms;
      deque<int> d(deq);
      int sum=0;
      rep(k,i){
        int tmp=d.front();
        d.pop_front();
        sum+=tmp;
        ms.insert(tmp); 
      }
      rep(k,j){
      	int tmp=d.back();
      	d.pop_back();
      	sum+=tmp;
      	ms.insert(tmp);
      }
      int cnt=0;
      for(auto itr=ms.begin(); *itr<0; itr++){
        if(cnt == k-i-j)
        	break;
        sum-=*itr;
        cnt++;
      }
      ans=max(ans,sum);
    }
  }
  cout << ans << 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 repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int main(){
  int p;
  cin >> p;
  while(1){
    vector<int> v(4);
    rep(i,4) cin >> v[i];
    vector<int> pr={10,50,100,500};
    vector<int> ans(4);
    int mn=100000;
    rep(i,v[0]+1){
      rep(j,v[1]+1){
        rep(k,v[2]+1){
          rep(l,v[3]+1){
            int pp=i*pr[0]+j*pr[1]+k*pr[2]+l*pr[3]-p;
            if(pp<0) continue;
            int tmp=-i-j-k-l;
            per(m,4){
              while(pp>=pr[m]){
                tmp++;
                pp-=pr[m];
              }
            }
            if(tmp<mn){
              mn=tmp;
              ans={i,j,k,l};
            }
          }
        }
      }
    }
    rep(i,4){
      if(ans[i]>0) cout << pr[i] SP ans[i] << endl;
    }
    cin >> p;
    if(p==0) return 0;
    cout << endl;
  }
  return 0;
}



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

typedef pair<pair<string, int>, int> P;

bool comp(P lp, P rp) {
	if (lp.first.first != rp.first.first) {
		return lp.first.first < rp.first.first;
	}

	if (lp.first.second != rp.first.second) {
		return lp.first.second > rp.first.second;
	}

	return lp.second < rp.second;
}

int main() {
	int n;
	cin >> n;
	vector<pair<pair<string, int>, int>> vpp(n);
	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;
		vpp.at(i) = make_pair(make_pair(s, p), i);
	}

	sort(vpp.begin(), vpp.end(), comp);

	//cout << endl;
	for (int i = 0; i < vpp.size(); i++) {
		// cout << vpp.at(i).first.first;
		// cout << " ";
		// cout << vpp.at(i).first.second;
		// cout << " ";

		cout << vpp.at(i).second + 1 << endl;
	}
}

Measured memory_bytes: 256
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()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<i64>();
    let an = read_vec::<i64>();
    let m = read::<i64>();
    let bn = read_vec::<i64>();
    println!("{}",linerSearch(n,an,m,bn));
}
fn linerSearch(n:i64,an:Vec<i64>,m:i64,bn:Vec<i64>) -> i64{
    let mut ans = 0;
    for v in &bn {
        if an.contains(&v) {
            ans += 1;
        }
    }
    return ans;
}


Measured memory_bytes: 5036
lis = []

for i in range(5):
    lis.append(int(input()))

NUM = int(input())

count = 0
correct = 0
for i in range(5):
    for k in range(i + 1, 5):
        if lis[k] - lis[i] <= NUM and lis[i] - lis[k] <= NUM:
            correct += 1
        count += 1

if count == correct:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3060
N = int(input())
p = [int(input()) for i in range(N)]
x = max(p)
y = 0
for i, j in enumerate(p):
  if j == x:
    p[i] = p[i] / 2
    break
total = 0

for i in p:
  total += i
print(int(total))
    

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

def solve():
    S = input()
    return {'SUN':7, 'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1}[S]
    



if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 2940
# B - Battle

# 入力 A B C D
A, B, C, D = map(int, input().split(maxsplit=4))

while True:
    C -= B
    if C <= 0:
        answer = 'Yes'
        break

    A -= D
    if A <= 0:
        answer = 'No'
        break

print(answer)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 

signed main() {
    int n, k;
    cin >> n >> k;
    vl x(n);
    rep (i, n) cin >> x[i];

    ll ans = INF;
    for (int i = 0; i + k <= n; i++) {
        chmin(ans, abs(x[i]) + abs(x[i + k - 1] - x[i]));
        chmin(ans, abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int width, height, x, y, r;

  scanf("%d %d %d %d %d", &width, &height, &x, &y, &r);
  if((x - r) < 0 || (x + r) > width || (y - r) < 0 || (y + r) > height){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 584
package main

import "fmt"

func main() {
	var m, f, r int
	for {
		fmt.Scan(&m, &f, &r)
		if m == -1 && f == -1 && r == -1 {
			break
		}
		
		if m == -1 && f == -1 {
			fmt.Println("F")
		} else if m == -1 || f == -1 {
			fmt.Println("F")
		} else if (m + f) >= 80 {
			fmt.Println("A")
		} else if (m + f) >= 65 && (m + f) < 80 {
			fmt.Println("B")
		} else if (m + f) >= 50 && (m + f) < 65 {
			fmt.Println("C")
		} else if (m + f) >= 30 && (m + f) < 50 && r >= 50 {
			fmt.Println("C")
		} else if (m + f) >= 30 && (m + f) < 50 {
			fmt.Println("D")
		} else if (m + f) <= 30 {
			fmt.Println("F")
		}

	}	
}


Measured memory_bytes: 1124
i=0
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for j in range(H):
        for k in range(W):
            if (j+k)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print("\n",end="")
    print("\n",end="")
    i+=1


Measured memory_bytes: 7016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i] - 1;
		}
		System.out.println(ans);
	}
}


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

int main()
{
    int n,q;
    cin >> n >> q;
    vector<tuple<int, int, int>> Kouji(n);
    vector<tuple<int, int, int>> Event;
    vector<int> d(q);

    for (int i = 0; i < n; i++)
    {
        int x,s,t;
        cin >> s >> t >> x;
        Kouji[i] = make_tuple(x, s, t);
        Event.push_back(make_tuple(s - x, -1, x));//工事開始イベント : s - x時間からxで開始
        Event.push_back(make_tuple(t - x, 0, x));//工事終了イベント : t - x時間にxで終了
    }
    for (int i = 0; i < q; i++)
    {
        cin >> d[i];
        Event.push_back(make_tuple(d[i], 1, i));//出発イベント : d[i]時間にiが出発
    }
    sort(Event.begin(), Event.end());

    vector<int> ans(q);
    multiset<int> KoujiEvents;
    for(auto nowEvent : Event)
    {
        //時間を古い順から順々に処理していく
        //工事が開始したら場所をmultisetに入れる
        //工事が終了したら場所をmultisetから抜く
        //出発したらmultisetの中の一番小さい値(場所)を取る。空なら-1
        int time, type, val;
        tie(time, type, val) = nowEvent;
        if(type == -1)KoujiEvents.insert(val);
        else if(type == 0)KoujiEvents.erase(KoujiEvents.lower_bound(val));
        else ans[val] = (KoujiEvents.empty() ? -1 : *(KoujiEvents.begin()));
    }

    for (int i = 0; i < q; i++)
    {
        cout << ans[i] << endl;
    }
    
}

Measured memory_bytes: 23784
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
		  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
		   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
			   # #  # # #                   # #      ###### #    # #    # #      #####
		  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
		   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
	*/
	 
	#include<bits/stdc++.h>
	using namespace std;
	 
	typedef long long LL;
	typedef vector<LL> VLL;
	typedef vector<string> VS;
	typedef vector<pair<LL, LL> > VP;
	 
	 
	#define For(in) for (LL i = 0; i < (n); i++)
	#define FOR(in) for(LL i=1; i <= (n); i++)
	#define pb push_back
	#define sr(v) sort(v.begin(), v.end())
	#define rev(v) reverse(v.begin(), v.end())
	#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
	#define exit(); return 0;
	#define no "NO"
	#define yes "YES"
	#define con continue;
	 
	 
	LL concate(LL a, LL b)
	{
		ostringstream os;
		os <<a <<b;
		istringstream is(os.str());
		LL c;
		is>> c;
		return c;
	}
	 
	 
	LL check(char c)
	{
		return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
	}
	 
	 
	int main()
	{
		LL q,t;
		//cin>>t;
		//while(t--)
		//{
		   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
			LL aa[1000];
			LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
			LL ma=0, mi=100000000;
			LL mid=0, temp=0, stop=0, start=0;
			double pi= 3.141592653589793;
			double d1=0.0, d2, d3, d4;
			VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
			VS vs, vs1, vs2, vs3, vs4;
			VP vp, vp1,vp2;
			char ch, ch1, ch2[1001];
			string str, str1, str2, str3, str4, str5;
			pair<LL, LL> pa;
			list<LL> li, li1;
			map<LL, LL> mp, mp1;
			set<LL> st;
			map<LL ,LL> :: iterator imll;
			VLL :: iterator ivll;
			set<LL> :: iterator isll;
			VP :: iterator ivp;
	 
			
			cin>>n;
			a = n/15;
			b = n*800;
			c = b-(a*200);
			cout<<c<<endl;
			
			
			
			
		 //}
	 
		exit()
	 
	 
	}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

int N, t[50];
char s[50][101], X[101];

int main() {
        int i;
        int ret = 0;

        scanf("%d", &N);

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

        scanf("%s", X);

        for (i = 0; i < N; i++) {
                if (strcmp(s[i], X) == 0) {
                        i++;
                        break;
                }
        }

        for (; i < N; i++) {
                ret += t[i];
        }

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

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int a_sum = 0;
    rep(i, n) {
        cin >> a[i];
        a_sum+=a[i];
    }
    int sel_num = 0;
    rep(i,n) {
        if (a[i]*4*m >= a_sum) sel_num++;
    }
    if (sel_num >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int, int);
int n;
int A[2000];

int main(){
  int i, sum;
  int q, mi[2000];

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

  for(i=0; i<q; i++){
    sum = solve(0, mi[i]);
    if(sum == 1){
      printf("yes\n");
    }
    if(sum == 0){
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i, int m){
  int res;

  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

Measured memory_bytes: 588
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p[] = new int[n];
    for(int i=0;i<n;i++){
      p[i]=sc.nextInt();
    }
    Arrays.sort(p);
    int answer =0;
    for(int i=0;i<n-1;i++){
      answer = answer+p[i];
    }
    answer = answer + (p[n-1]/2);
    System.out.println(answer);
  }
  

  
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 3000


//辺を表す構造体(行先、容量、逆辺のインデックス)
struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int V,E;
int N;
map<int,int> MAP;
vector<Edge> G[NUM]; //グラフの隣接リスト表現
int dist[NUM]; //sourceからの距離
int cheked_index[NUM]; //どこまで調べ終わったか

//fromからtoへ向かう容量capacityの辺をグラフに追加する
void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1)); //逆辺の、初期容量は0
}

//sourceからの最短距離をBFSで計算する
void bfs(int source){
	for(int i = 0; i < V; i++)dist[i] = -1;
	queue<int> Q;
	dist[source] = 0;
	Q.push(source);

	while(!Q.empty()){
		int node_id = Q.front();
		Q.pop();
		for(int i = 0; i < G[node_id].size(); i++){
			Edge &e = G[node_id][i];
			if(e.capacity > 0 && dist[e.to] < 0){ //辺の容量が正で、かつエッジの行先に未訪問の場合
				dist[e.to] = dist[node_id]+1;
				Q.push(e.to);
			}
		}
	}
}

//増加パスをDFSで探す
int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow; //終点についたらflowをreturn

	for(int &i = cheked_index[node_id]; i < G[node_id].size(); i++){ //node_idから出ているエッジを調査
		Edge &e = G[node_id][i];
		if(e.capacity > 0 && dist[node_id] < dist[e.to]){ //流せる余裕があり、かつsourceからの距離が増加する方法である場合
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity)); //流せるだけ流す
			if(tmp_flow > 0){ //流せた場合
				e.capacity -= tmp_flow; //流した分、エッジの容量を削減する
				G[e.to][e.rev_index].capacity += tmp_flow; //逆辺の容量を、流した分だけ増加させる
				return tmp_flow;
			}
		}
	}
	return 0;
}


//sourceからsinkへの最大流を求める
int max_flow(int source,int sink){ //source:始点 sink:終点
	int flow = 0,add;
	while(true){ //増加パスが存在する限り、流量を追加し続ける
		bfs(source);
		if(dist[sink] < 0)break; //sourceからsinkへと辿り着く残余グラフがない、つまり増加パスが無くなった場合、break
		for(int i = 0; i < V; i++)cheked_index[i] = 0;
		while((add = dfs(source,sink,BIG_NUM)) > 0){ //増加パスが見つかる間、加算
			flow += add;
		}
	}
	return flow;
}

void func(){

	MAP.clear();
	for(int i = 0; i < NUM; i++)G[i].clear();

	int num,tmp,index = 2;
	scanf("%d",&num);

	int source = 0,sink = 1;

	for(int loop = 0; loop < num; loop++){
		scanf("%d",&tmp);
		MAP[tmp] = index;
		add_edge(source,index,1); //sourceからindexに、容量1の辺を張る
		index++;
	}

	int integrate;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&num);
		add_edge(index,sink,1); //1人の人物につき、最大流量1の集約路を張る
		integrate = index;
		index++;

		for(int i = 0; i < num; i++){
			scanf("%d",&tmp);
			auto at = MAP.find(tmp);
			if(at == MAP.end())continue; //Isaccの都合の良い日でなければ無視
			add_edge(MAP[tmp],integrate,1); //Isaccの都合の良い日から、
		}
	}

	V = index;

	printf("%d\n", max_flow(source,sink));
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3476
#include <stdio.h>
 
int main()
{
    int n;
  scanf("%d",&n);
  int a[n],i;
  for(i=0;i<n;++i)
       scanf("%d",&a[i]);
  
  int j,cnt=1;
  int flag;
  for(i=1;i<n;++i)
  {
    flag=0;
    
    for(j=0;j<i;++j)
      {
          if(a[i]>=a[j])
            continue;
            
          else
            {
                flag=1;
                break;
            }
      }
    
    if(flag==0)
        cnt++;
  }
  
  printf("%d",cnt);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <math.h>

using namespace std;

const double pi=3.1415926535897;

int main(){
    double a,h,x;
    cin>>a>>h>>x;
    if(x>(a*a*h/2)){
        printf("%.10lf\n",atan(2*(a*a*h-x)/(a*a*a))*(180.0/pi));
    }else{
        printf("%.10lf\n",90.0-atan(2*x/(a*h*h))*(180.0/pi));
    }
    return 0;
}


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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n) cin >> a[i];
    ll ans = 0;
    sort(a.begin(), a.end());
    rep(i, n) ans += a[3 * n - i * 2 - 2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,Y;
  cin>>N>>Y;
 int yukiti=-1,hiyou=-1,hide=-1;
for(int i=0;i<=N;i++){
	for(int j=0;i+j<=N;j++){
    	int k=N-i-j;
      	int total = 10000*i + 5000*j + 1000*k;
      	if(total == Y){
        yukiti=i;
         hiyou=j;
         hide=k; 
        }
    }
}  
cout<<yukiti<<" "<<hiyou<<" "<<hide;
}  
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s,sc;
  int cnt=0,c_cnt=0;
  cin >> s;
  sc = s;
  if(s[0]=='1'){
    s[0]='0';
    cnt++;
  }
  for(int i=1;i<s.length();i++){
    if(s[i]==s[i-1]){
      s[i] = (s[i-1]=='0') ? '1':'0';
      cnt ++;
    }
  }
  s = sc;
  if(s[0]=='0'){
    s[0]='1';
    c_cnt++;
  }
  for(int i=1;i<s.length();i++){
    if(s[i]==s[i-1]){
      s[i] = (s[i-1]=='0') ? '1':'0';
      c_cnt ++;
    }
  }
  cnt = min(cnt,c_cnt);
  cout << cnt << endl;
}


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

#define ll long long
#define ar array

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

	int n, p;
	string s;
	cin >> n >> p >> s;
	ll ans=0;
	if(p==2) {
		for(int i=0; i<n; ++i)
			if((s[i]-'0')%2==0)
				ans+=i+1;
	} else if(p==5) {
		for(int i=0; i<n; ++i)
			if((s[i]-'0')%5==0)
				ans+=i+1;
	} else {
		map<int, int> mp;
		++mp[0];
		int t=0, p2=1;
		for(int i=n-1; ~i; --i) {
			t=(t+(s[i]-'0')*p2)%p;
			ans+=mp[t];
			mp[t]++;
			p2=p2*10%p;
		}
	}
	cout << ans;
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int a[N];

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n;
	cin >> n;
	int mn = 1e9, mx = 0;
	forn(i, n) {
		cin >> a[i];	
		umx(mx, a[i]);
		umn(mn, a[i]);
	}
	int kolmn = 0, kolmx = 0;
	forn(i, n) {
		if (a[i] == mx) {
			kolmx++;
		} else {
			kolmn++;
		}
	}
	if (mx == mn) {
		if (mx == n - 1 || mx <= n / 2) {
			puts("Yes");
		} else {
			puts("No");
		}
		return 0;
	}
	if (mx > mn + 1) {
		puts("No");
		return 0;
	}
	int diff = mx;
	if (diff > kolmn && diff <= kolmn + kolmx / 2) {
		puts("Yes");
	} else {
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),P=gi();
	ll f[2]={1,0};
	while(n--)
		if(gi()&1){
			ll s=f[0]+f[1];
			f[0]=f[1]=s;
		}else f[0]*=2,f[1]*=2;
	printf("%lld\n",f[P]);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;

#define MAXN 4010
#define mo 1000000007

int n, m, a[MAXN];
int sum[MAXN];
int f[MAXN][MAXN];
char s[MAXN];

void Init()
{
    int i;
    scanf("%d %d", &n, &m);
    scanf("%s", s + 1);
    for(i = 1; i <= n; ++i){
        a[i] = s[i] - '0';
        sum[i] = sum[i - 1] + a[i];
    }
}

void Dp()
{
    int i, j = 1, k, l, r, R = 0, ad = 0;
    f[0][0] = 1;
    for(i = 1; i <= m; ++i){
        scanf("%d %d", &l, &r);
        for(; j < l; ++j, ad = 0){
            if(j > R){
                R = j;
                ad += a[j];
            }
            for(k = 0; k <= sum[R] && j + k <= R; ++k){
                if(k - ad >= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad]) % mo;
                if(k - ad + 1>= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad + 1]) % mo;
            }
        }
        if(r > R){
            ad += sum[r] - sum[R];
            R = r;
        }
//        for(; j < l; ++j, ad = 0){
//            for(k = 0; k <= sum[R] && j + k <= R; ++k){
//                if(k - ad >= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad]) % mo;
//                if(k - ad + 1>= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad + 1]) % mo;
//            }
//        }
    }
    for(; j <= n; ++j, ad = 0){
        if(j > R){
            R = j;
            ad += a[j];
        }
        for(k = 0; k <= sum[R] && j + k <= R; ++k){
            if(k - ad >= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad]) % mo;
            if(k - ad + 1>= 0) f[j][k] = (f[j][k] + f[j - 1][k - ad + 1]) % mo;
        }
    }
    printf("%d\n", f[n][0]);
}

int main()
{
    Init();
    Dp();

    return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>>ab(n);
  for(int i=0; i<n; i++){
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.rbegin(),ab.rend());
  cout << ab[0].first + ab[0].second << endl;
  return 0;
}

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

int main(){
	double N;
	cin >> N;
    double ans;
	(int)N%2 == 0 ? ans = ans=N/2.0/N : ans = ((int)N/2 + 1.0)/N ;
	printf("%f", ans);
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by RHelper
 * More info: https://github.com/mkc1370/RHelper
 * @author 
 */

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

public class ACoffee
{
    private readonly StringReader cin;
    private readonly StringWriter cout;
    private readonly Scanner scanner;

    public ACoffee(StringReader cin, StringWriter cout)
    {
        this.cin = cin;
        this.cout = cout;
        scanner = new Scanner(cin);
    }

    public void Solve()
    {
        var s = CINS;
        if (s[2] == s[3] && s[4] == s[5])
        {
            COUT("Yes");
        }
        else
        {
            COUT("No");
        }
    }

    private long CINL => scanner.Long();
    private double CIND => scanner.Double();
    private string CINS => scanner.String();
    private static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat(v, (int)n);
    private List<long> CINVL(long n) => Repeat(0, n).Select(_ => CINL).ToList();
    private List<double> CINVD(long n) => Repeat(0, n).Select(_ => CIND).ToList();
    private List<string> CINVS(long n) => Repeat(0, n).Select(_ => CINS).ToList();

    private void COUT(object o) => cout.WriteLine(o);
}

public class Scanner
{
    public Scanner(StringReader stringReader)
    {
        this.stringReader = stringReader;
    }

    private readonly StringReader stringReader;
    private readonly char[] buffer = new char[1024];
    private int len, ptr;
    private bool isEof;

    private char Read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = stringReader.Read(buffer, 0, 1024)) <= 0)
            {
                isEof = true;
                return '\0';
            }
        }

        return buffer[ptr++];
    }

    public char Char()
    {
        char b;
        do b = Read();
        while (b < 33 || 126 < b);
        return b;
    }

    public string String()
    {
        var sb = new StringBuilder();
        for (char b = Char(); b >= 33 && b <= 126; b = Read())
            sb.Append(b);
        return sb.ToString();
    }

    public long Long()
    {
        long ret = 0;
        char b;
        var ng = false;
        do b = Read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = Read();
        }

        for (;; b = Read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }

    public double Double()
    {
        return double.Parse(String(), CultureInfo.InvariantCulture);
    }
}


public class Output
{
	public static void Main()
	{
		var reader = new System.IO.StringReader(Console.In.ReadToEnd());
		var writer = new System.IO.StringWriter();
		var solver = new ACoffee(reader, writer);
		solver.Solve();
		System.Console.Write(writer.GetStringBuilder().ToString());
	}
}


Measured memory_bytes: 11220
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    bool bo[H][W];
    REP(i, 0, H) {
        string s;
        cin >> s;
        REP(j, 0, W) {
            if (s[j] == '.') {
                bo[i][j] = true;
            } else {
                bo[i][j] = false;
            }
        }
    }
    ll num[H][W];
    REP(i, 0, H) {
        fill(num[i], num[i] + W, inf);
    }
    if (bo[H - 1][W - 1]) {
        num[H - 1][W - 1] = 0;
    } else {
        num[H - 1][W - 1] = 1;
    }
    PER(i, H - 1, -1) {
        PER(j, W - 1, -1) {
            if (i != H - 1) {
                if (!bo[i][j] && bo[i + 1][j]) {
                    num[i][j] = min(num[i][j], num[i + 1][j] + 1);
                } else {
                    num[i][j] = min(num[i][j], num[i + 1][j]);
                }
            }
            if (j != W - 1) {
                if (!bo[i][j] && bo[i][j + 1]) {
                    num[i][j] = min(num[i][j], num[i][j + 1] + 1);
                } else {
                    num[i][j] = min(num[i][j], num[i][j + 1]);
                }
            }
        }
    }
    ll ans = num[0][0];
    cout << ans << endl;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  int d=a/b;
  int r=a%b;
  double f=(double)a/(double)b;
  cout << fixed << setprecision(5);
  cout<<d<<" "<<r<<" "<<f<<endl;
  return 0;
}


Measured memory_bytes: 3292
N = int(input())
X = list(map(int, input().split()))
a = int(sum(X) / N)
b = a + 1
A, B = 0, 0
for x in X:
    A += (x - a) ** 2
    B += (x - b) ** 2
ans = min(A, B)
print(ans)

Measured memory_bytes: 9188
#include <stdio.h>
int main (void){
	int x,y;
	while(1){
		scanf("%d %d", &x,&y);
		if(x==0 && y==0)break;
		if(x<=y){
			printf("%d %d\n",x,y);
		}
		else {
			printf("%d %d\n", y,x);
		}
		
	}

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main() {
	int x, y,z,w;
	scanf("%d %d", &x, &y);
	if (x < y) {
		z = x;
		x = y;
		y = z;
	}
	z = 0;
	w = 0;
	while(1){
		z = (x % y);
		if (z == 0) {
			break;
		}
		if (z < y) {
			w = z;
			x = y;
			y = w;
		}
		else {
			x = z;
		}
		
	}
	printf("%d\n",y);

}


Measured memory_bytes: 2120
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
#include<string>
using namespace std;
string cmd;
int main(){
    int temp;
    priority_queue <int> p;
    while(1){
    cin>>cmd;
    if(cmd[0]=='i'){
        cin>>temp;
        p.push(temp);
    }
    else if(cmd[0]=='e'&&cmd[1]=='x'){
        cout<<p.top()<<endl;
        p.pop();
    }
    else
        break;
    }
    return 0;
}



Measured memory_bytes: 6884
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int B[N]={};
  for(int i=1;i<N;i++){
    cin>>B[i];
  }
  int ans=B[1]+B[N-1];
  for(int i=2;i<N;i++){
    ans+=min(B[i-1],B[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const ll MOD = 1000000007LL;
ll dp[100005][2];

void _main()
{
    string L;
    cin >> L;
    const int N = L.length();
    dp[0][0] = 1;
    rep(i, 0, N)
    {
        // a + b = 0
        if (L[i] == '0')
        {
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1];
        }
        else
        {
            dp[i + 1][1] += (dp[i][0] + dp[i][1]) % MOD;
        }

        // a + b = 1
        if (L[i] == '0')
        {
            dp[i + 1][1] += (dp[i][1] * 2) % MOD;
        }
        else
        {
            dp[i + 1][0] += (dp[i][0] * 2) % MOD;
            dp[i + 1][1] += (dp[i][1] * 2) % MOD;
        }
    }

    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
int main()
{
	 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
     ll n,k;
     cin>>n>>k;
     ll a[n+1];
     for(ll i=1;i<=n;i++)    cin>>a[i];
     ll dp[n+1]={0};
     for(ll i=2;i<=n;i++)
     {
     	  dp[i] = dp[i-1] + abs(a[i]-a[i-1]);
     	  for(ll j = i-1;j>=max((ll)1,i-k);j--)
          {
     	     	dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
   	      }
     }
     cout<<dp[n];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int c[3][3];
  REP(i,3){
    cin >> c[i][0] >> c[i][1] >> c[i][2];
  }
  bool f = false;
  REP(i,101){
    REP(j,101){
      REP(k,101){
	if((c[0][0]-i == c[1][0]-j && c[1][0]-j == c[2][0]-k)&&(c[0][1]-i == c[1][1]-j && c[0][1]-i == c[2][1]-k)&&(c[0][2]-i == c[1][2]-j && c[0][2]-i == c[2][2]-k)){
	  f = true;
	  break;
	}
      }
      if(f)
	break;
    }
    if(f)
      break;
  }
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	
    public static void main(String[] args){
    	Scanner sc =new Scanner(System.in);
    	int n= sc.nextInt();//0<=n<=44
    	int[] list=new int[n+1];
    	Arrays.fill(list,0);
    	System.out.println(calcfib(list,n));
    }
    static int calcfib(int[] list,int i){
    	if(i==1||i==0){
    		return 1;
    	}else if(list[i]==0){
    		return list[i]=calcfib(list,i-1)+calcfib(list,i-2); 
    	}else{
    		return list[i];
    	}
    	
    }
}


Measured memory_bytes: 26296
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int a[100010];
int res=1e9;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	for (int i=0;i<n-m+1;i++)
	{
		//cout <<res<<" "<<a[i+m-1]-a[i]<<"\n";
		res=min(res,a[i+m-1]-a[i]);
	}
	cout <<res;
	return 0;
}

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

int main() {
	string s, t = "";
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		t += s[i];
		if (t == "erase") {
			if (i + 1 < n && s[i + 1] == 'r') {
				i += 1;
			}
			t = "";
		}
		else if (t == "dream") {
			if (i + 2 < n && s[i + 1] == 'e' && s[i + 2] == 'r') {
				if (i + 3 < n && s[i + 3] == 'a') {
					t = "era";
					i += 3;
				}
				else {
					t = "";
					i += 2;
				}
			}
			else {
				t = "";
			}
		}
	}
	if (t == "") {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		
		if(Character.isUpperCase(a.charAt(0))) {
			System.out.println("A");
		}
		else {
			System.out.println("a");
		}
		
	}

}


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

main(){
    char n;
    int b, r, g, c, s, t;
    while(1){
	cin >> b >> r >> g >> c >> s >> t;
	if ( b == 0 && r == 0 && g== 0 && c == 0 && s == 0 && t == 0) break;
	int nb = b*5 + r*3; // {[iXQ[Ì
	int no = t - nb;    // ÊíQ[Ì
	int cur = 100;
	int result = cur + 15*b + 15*r + 15*nb + 7*g + 2*c - 3*(no-s) - 2*nb;
	cout << result << endl;
    }
}

Measured memory_bytes: 0
n, m = map(int, input().split())

pen_cnt = [0] * n
ac_flg = [0] * n

cnt = 0
for _ in range(m):
    sub = input().split()
    p = int(sub[0]) - 1
    s = sub[1]
    if s == "WA":
        pen_cnt[p] += 1
    elif s == "AC" and ac_flg[p] == 0:
        ac_flg[p] = 1
        cnt += pen_cnt[p]

print(sum(ac_flg), cnt)

Measured memory_bytes: 4596
n = int(input())
a = [tuple(map(int, input().split())) for i in range(n)]
t = set(a)
assert len(t) == len(a)
minans = 1000000000000
for i in range(n):
    for j in range(i + 1, n):
        r = t.copy()
        p = a[i][0] - a[j][0]
        q = a[i][1] - a[j][1]
        curans = 0
        while r:
            curans += 1
            m = r.pop()
            z = m
            while (m[0] + p, m[1] + q) in r:
                m = (m[0] + p, m[1] + q)
                r.remove(m)
            m = z
            while (m[0] - p, m[1] - q) in r:
                m = (m[0] - p, m[1] - q)
                r.remove(m)
        minans = min(minans, curans)
if minans == 1000000000000:
    print(1)
else:
    print(minans)


Measured memory_bytes: 45040
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N; cin >> N;
	int ans = 0;
	rep(i,N){
		int l,r; cin >> l >> r;
		ans += r-l+1;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <typeinfo>
 
 
using namespace std; 

// ||    

// upper to lower = + 32;
// lower to upper = - 32;

int firstDigit(int n) 
{ 
    while (n >= 10)  
        n /= 10;  
    return n; 
}
int lastDigit(int n) 
{ 
    return (n % 10); 
} 
void sortString(string &str) 
{ 
   sort(str.begin(), str.end());
}
void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 
void bubbleSort(string s, int o, int n)
{  
    for(int i = 1; i <= n; i++) {
    	for(int j = 1; j <= n; j++)  {
       		if (s[o] < s[j]) {
       			swap(s[o], s[j]); 

       		}  
    	}
    }      
 
} 
bool allCharactersSame(string s) 
{ 
	int n = s.length();
    for (int i = 1; i < n; i++) 
        if (s[i] != s[0]) 
            return false; 
  
    return true; 
}
int factorial(int n) 
{ 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
}

int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2;
        if (arr[mid] == x) 
            return mid;
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x);  
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
 
int main() { 
	int a = 0, b = 0;
	cin >> a >> b;
	if(a == 1 and b == 2 or a == 2 and b == 1) {
		cout << 3 << endl;
		return 0;
	}
	if(a == 2 and b == 3 or a == 3 and b == 2) {
		cout << 1 << endl;
		return 0;
	}
	if(a == 3 and b == 1 or a == 1 and b == 3) {
		cout << 2 << endl; 
		return 0;
	}
 
    return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, x;
  cin >> n >> x;
  vi l(n);
  rep(i,n){
    cin >> l[i];
  }
  ll count = 0;
  ll b = 0;
  ll i = 0;
  while (b <= x&&count<=n){
    b += l[i];
    i++;
    count++;
  }
  print(count);
}

Measured memory_bytes: 256
use text_io::*;
use std::process::exit;

fn main(){
    let a:usize = read!();
    let mut c:u128 = 1;
    let mut v:Vec<u128> =Vec::new();
    for i in 0..a {
        let b:u128 = read!();
        v.push(b);
        if b==0 {
            println!("0");
            exit(0);
        }
    }
    for i in 0..a {
        c *= v[i];
        if c>1000000000000000000 {
            println!("-1");
            exit(0);
        }
    }
    println!("{}",c);
}

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

int main() {
  int H,W;
  cin >> H>>W;
  char vec[101][101];
  char vec_sharp[102][102];

  for(int i=0; i<H; i++){
    cin>>vec[i];
  }

  for(int h_i=0; h_i<H+2; h_i++){
    for(int w_i=0; w_i<W+2; w_i++){
      vec_sharp[h_i][w_i]='#';
    }
  }
  
  for(int h_i=0; h_i<H; h_i++){
    for(int w_i=0; w_i<W; w_i++){
      vec_sharp[1+h_i][1+w_i]=vec[h_i][w_i];
    }
  }

  for(int h=0; h<H+2; h++){
    for(int w=0; w<W+2; w++){
        cout <<vec_sharp[h][w];
    }
    cout <<endl;
  }
}

Measured memory_bytes: 256
package main

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

func main() {
	n := readI()

	//dp[i] = i円引き出す際の最低操作回数
	dp := make([]int, n+1)

	for i := 1; i <= n; i++ {
		m := make([]int, 1)
		m[0] = dp[i-1]
		y := 6
		for y <= i {
			m = append(m, dp[i-y])
			y *= 6
		}
		y = 9
		for y <= i {
			m = append(m, dp[i-y])
			y *= 9
		}
		dp[i] = min(m...) + 1
	}

	fmt.Println(dp[n])
}

func min(a ...int) int {
	m := a[0]
	for i := 1; i < len(a); i++ {
		if m > a[i] {
			m = a[i]
		}
	}
	return m
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 6188