akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	     public static void main(String[] args) throws IOException {
	            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	            int n = Integer.parseInt(br.readLine());
	            int i;
	            String[] su=br.readLine().split(" ");
	                         
	            StringBuilder outArray = new StringBuilder();
	             
	            for( i=n-1;i>0;i--){
	            	System.out.print(su[i]+" ");
	            }
	            System.out.print(su[i]+"\n");
	    }
	}

Measured memory_bytes: 16900
#include <stdio.h>

int main() {
  int n;
  int i;
  int dx, dy;
  int nx, ny;
  int maxdist2;
  int tx, ty;
  int temp;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    nx = ny = 0;
    maxdist2 = -1;
    while(1) {
      scanf("%d %d", &dx, &dy);
      if(dx == 0 && dy == 0) break;
      nx += dx;
      ny += dy;
      temp = nx*nx + ny*ny;
      if(temp > maxdist2) {
	maxdist2 = temp;
	tx = nx;
	ty = ny;
      } else if(temp == maxdist2) {
	if(nx > tx) {
	  maxdist2 = temp;
	  tx = nx;
	  ty = ny;
	}
      }
    }
    printf("%d %d\n", tx, ty);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) {
    cin >> vec[i];
  }
  int b = vec[0];
  for(int i = 1; i < n; i++) {
    b = lcm(b, vec[i]);
  }
  int d = 0;
  rep(i, n) {
    d += b / vec[i];
  }
  double c = d * 1.0;
  printf("%.8f", b / c);
  return 0;
}

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

int main()
{
  char s[201],p[100];
  int i,j,str1,str2,judge=0;
  scanf("%s",s);
  scanf("%s",p);
  str1=strlen(s);
  str2=strlen(p);
  for(i=0;i<str1;i++) s[str1+i]=s[i];
  s[str1+i]='\0';
  //printf("%s\n",s);
  for(i=0;i<strlen(s);i++){
    if(s[i]==p[0]){
      judge=1;
      for(j=1;j<str2;j++){
      //  printf("s[%d]=%c,p[%d]=%c\n",i+j,s[i+j],j,p[j]);
        if(s[i+j]!=p[j]) judge=0;
      }
    }
    if(judge==1) break;
  }

  if(judge==1) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>

int main(void){

	int t, n;
	int up, down;

	std::cin >> t;

	for(int i=0; i<t; i++){
		std::cin >> n;
		std::vector<int> h(n);
		for(int i=0; i<n; i++){
			std::cin >> h[i];
		}
		up = down = 0;

		for(int i=1; i<n; i++){
			if(h[i]>h[i-1]){
				if(up<(h[i]-h[i-1])) up = h[i]-h[i-1];
			}
			else if(h[i]<h[i-1]){
				if(down<h[i-1]-h[i]) down = h[i-1]-h[i];
			}
		}
		std::cout << up << " " << down << std::endl;
	}

	return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(x == 0 && y ==0){
                break;
            }
            for(int k=0;k<x;k++){
                if(k == 0 || k == x-1){
               for(int j=0;j<y;j++){
                    System.out.print("#");
                }
               System.out.println();
            }else{
                System.out.print("#");
                for(int l=0;l<y-2;l++){
                    System.out.print(".");
                }
                System.out.print("#\n");
                }
            }
            System.out.println();
        }
            sc.close();
    }
}


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

using namespace std;

int a, b;

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

    cin >> a >> b;

    if(b % a == 0)
        cout << a + b;
    else
        cout << b - a;

    return 0;
}


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

using ll=long long;

int main() {
  int M1,D1; cin >>M1 >>D1;
  int M2,D2; cin >>M2 >>D2;
  cout <<(M1!=M2 ? 1:0) <<endl;
  return 0;
}


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

int main() {
    int d;
    cin >> d;
    map<int, string> mp;
    mp[25] = "Christmas";
    mp[24] = "Christmas Eve";
    mp[23] = "Christmas Eve Eve";
    mp[22] = "Christmas Eve Eve Eve";
    cout << mp[d] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
int main()
{
	int n,x,v,ans = 0,i;
	int sz = 0;
	cin >> n >> x;
	int f[n];
	f[0] = 0;
	for(i = 0; i < n; i ++) {
		cin >> v;
		f[i + 1] = f[i] + v;
	}
	for(i = 0; i <= n; i ++) {
		if(f[i] <= x) {
			ans ++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void	ft_sort(int *d, int n)
{
	int i = 0;
	int j;
	int tmp;
	while (i < n - 1)
	{
		j = i + 1;
		while (j < n)
		{
			if (d[i] < d[j])
			{
				tmp = d[i];
				d[i] = d[j];
				d[j] = tmp;
			}
			j++;
		}
		i++;
	}
}

int		main(void)
{
	int	n;
	scanf("%d", &n);
	int d[n];
	int i = 0;
	int count = 0;
	while (i < n)
		scanf("%d", &d[i++]);
	ft_sort(d, n);
	i = 0;
	while (i < n)
	{
		if (d[i] != d[i + 1])
		{
			count++;
		}
		i++;
	}
	printf("%d", count);
	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <cstdio>
#include <numeric>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int N, K;
    cin >> N >> K;

    double ans = 0.;
    for(int n = 1; n <= N; n++){
        double tmp = 1.0;
        for(int count = n; count < K; count *= 2) tmp /= 2.;
        ans += tmp;
    }

    printf("%.15f", ans / N);

    return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 505;
const ll INF = 1LL << 60;

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



// Main Code

int arr[N][N];
int trcnt[3][35];
ll cost[3][35];
vector<pair<ll,int>> v[3];
int dist[35][35];

int main()
{
	int n, c;
	cin>>n>>c;
	repn(i, 1, c)
		repn(j, 1, c)
			cin>>dist[i][j];
	repn(i, 1, n)
		repn(j, 1, n){
			cin>>arr[i][j];
			int x = (i+j)%3;
			trcnt[x][arr[i][j]]++;
		}
	repn(i, 0, 2)
	{
		repn(j, 1, c)
		{
			repn(k, 1, c)
			{
				cost[i][j] += ((dist[k][j])*trcnt[i][k]);
			}
		}
	}
	repn(i, 0, 2)
	{
		repn(j ,1 ,c)
		{
			v[i].pb({cost[i][j], j});
		}
		sort(all(v[i]));
	}
	pair<ll, int> f1, f2, f3;
	ll ans = LONG_MAX;
	rep(i, 0, c)
	{
		rep(j, 0, c)
		{
			rep(k, 0, c)
			{
				f1 = v[0][i];
				f2 = v[1][j];
				f3 = v[2][k];
				if(f1.s == f2.s || f2.s == f3.s || f1.s == f3.s)
					continue;
				chmin(ans, (f1.f+f2.f+f3.f));
			}
		}
	}
	cout<<ans<<endl;

}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int A, B;
    std::cin >> A >> B;
    auto ans = A - (B * 2);
    std::cout << (ans < 0 ? 0 : ans) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>  
#include<cmath>
#include<string>
using namespace std;
int main(){ 
	int arr[3][3];
	int bingo[3][3];
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			cin>>arr[i][j];
			bingo[i][j]=0;
		}
	int n;
	cin>>n;
	int m;
	for(int p=1;p<=n;p++){
		cin>>m;
		for(int i=0;i<3;i++)
		for(int j=0;j<3;j++){
			if(arr[i][j]==m)
				bingo[i][j]=1;
		}
	}
	int count=0;
	for(int i=0;i<3;i++)
		if(bingo[i][0]+bingo[i][1]+bingo[i][2]==3)
			count++;
	for(int i=0;i<3;i++)
		if(bingo[0][i]+bingo[1][i]+bingo[2][i]==3)
			count++;
	if(bingo[0][0]+bingo[1][1]+bingo[2][2]==3)
			count++;
	if(bingo[0][2]+bingo[1][1]+bingo[2][0]==3)
			count++;
	if(count>=1)
		cout<<"Yes";
	else
		cout<<"No";
}





 




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define dbg(x) cout<<#x<<" : "<<x<<endl;
#define dl(x) cout<<"LINE "<<__LINE__<<endl;
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n>=1800){cout<<1<<endl;return 0;}
	if(n>=1600){cout<<2<<endl;return 0;}
	if(n>=1400){cout<<3<<endl;return 0;}
	if(n>=1200){cout<<4<<endl;return 0;}
	if(n>=1000){cout<<5<<endl;return 0;}
	if(n>=800){cout<<6<<endl;return 0;}
	if(n>=600){cout<<7<<endl;return 0;}
	if(n>=400){cout<<8<<endl;return 0;}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
  int n, m, q, cnt = 0;
  vector<int> S, T;
  
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> m;
    S.push_back(m);
  }

  cin >> q;

  for (int i = 0; i < q; i++) {
    cin >> m;
    T.push_back(m);
  }

  for (int i = 0; i < q; i++) {
    if (*lower_bound(S.begin(), S.end(), T[i]) == T[i])
      cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}



Measured memory_bytes: 3580
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int data[]  = new int[3];
      int min = 0;

      for(int i = 0;i<3;i++){
        data[i] = sc.nextInt();
      }

      Arrays.sort(data);

      System.out.println(data[0] + data[1]);


}
}


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

int main()
{
    string s, p;
    cin >> s >> p;
    for (unsigned int i = 0; i < s.size(); i++) {
        if (s[i] == p[0]) {
            bool ans = true;
            for (unsigned int j = 1; j < p.size(); j++) {
                if (p[j] != s[(i + j) % s.size()]) {
                    ans = false;
                    break;
                }
            }
            if (ans) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3212
import itertools
def main():
    S = input()
    ans = 0
    plus = itertools.product([0,1], repeat=len(S)-1)
    for pl in plus:
        now = '0'
        for p, s in zip(pl+(1,), S):
            now += s
            if p:
                ans += int(now)
                now = '0'
    print(ans)
main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int mod = 1000000007;
int n;
vector<int> et[200000];
int ans = 0;
int p2[200001];

int dfs(int p, int v) {
	int i;
	
	int sz = 1;
	int cnt = 1;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		int res = dfs(v, nv);
		sz += res;
		cnt += (p2[res] - 1);
		cnt %= mod;
	}
	cnt += (p2[n - sz] - 1);
	cnt %= mod;
	ans += p2[n - 1] + mod - cnt;
	ans %= mod;
	
	return sz;
}

signed main() {
	int i;
	
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	p2[0] = 1;
	rep(i, n) p2[i + 1] = (p2[i] * 2) % mod;
	
	dfs(-1, 0);
	cout << (ans * powmod(p2[n], mod - 2, mod) % mod) << endl;
	return 0;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int64_t GCD(int64_t a,int64_t b){
    return b == 0 ? a : GCD(b, a % b);
   
}
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i];
    set<int64_t> s;
    bool pc = true;
    rep(i,n){
        if(!pc)break;
        if(a[i]!=1 && s.count(a[i])){
            pc = false;
            break;
        }
        s.insert(a[i]);
        //O(√N)で約数列挙
        for(int64_t j=2;j*j<=a[i];j++){
            if(a[i]%j==0){
                if(s.count(j)||s.count(a[i]/j)){
                    pc = false;
                    break;
                }
                s.insert(j);
                s.insert(a[i]/j);
            }
        }
    }
    if(pc){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    int gcd=a[0];
    for(int i=1;i<n;i++){
        gcd = GCD(gcd,a[i]);
    }
    if(gcd==1){
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
}

Measured memory_bytes: 11120
from functools import reduce
from collections import defaultdict
from collections import deque
import math

def btf(i,d,N):
    q = deque()
    q.append(i)
    dist = [-1]*N
    dist[i] = 0
    i = 1
    while q:
        l = len(q)
        for j in range(l):
            next_node = q.popleft()
            for succ in d[next_node]:
                if dist[succ] == -1:
                    dist[succ] = i
                    q.append(succ)
        i +=1
    return dist

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    d = defaultdict(list)
    
    for i in range(M):
        s1,s2 = (int(_) for _ in input().split())
        d[s1-1].append(s2-1)
        d[s2-1].append(s1-1)

    dist = btf(0,d,N)

    if dist[N-1] == 2:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 59752
#! python3
# exhaustiveSearch.py - 総当りの計算

import itertools

n = int(input())
A = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]

def generateCombo(A):
    combo_set = []
    for i in range(len(A)):
        combo_set.extend(list(itertools.combinations(A, i+1)))
    return combo_set

combo_set = generateCombo(A)

sum_list = []
for combo in combo_set:
    sum_num = sum(combo)
    sum_list.append(sum_num)

for num in m:
    if num in sum_list:
        print('yes')
    else :
        print('no')
        


Measured memory_bytes: 189300
import java.util.Scanner;

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




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

struct map{int row,column;};
stack<map> st;
int board[8][8]={};
bool flag=0;

void printQueen(){
	int queen[8][8]={};
	while(!st.empty()){
		map m=st.top();
		st.pop();
		queen[m.row][m.column]=1;
	}
	
	for (int i=0;i<8;i++){
		for (int j=0;j<8;j++){
			if(queen[i][j]==1){
				cout << "Q";
			}else{
				cout << ".";
			}
		}
		cout << endl;
	}
}

void changeBoard(int r,int c,int d){
	int i,j;
	for (i=0;i<8;i++){
		board[r][i]+=d;
	}
	for (j=0;j<8;j++){
		board[j][c]+=d;
	}
	
	i=r,j=c;
	while((i<8)&&(j<8)){
		board[i][j]+=d;
		i++;j++;
	}
	
	i=r,j=c;
	while((i>=0)&&(j>=0)){
		board[i][j]+=d;
		i--;j--;
	}
	
	i=r,j=c;
	while((i<8)&&(j>=0)){
		board[i][j]+=d;
		i++;j--;
	}
	
	i=r,j=c;
	while((i>=0)&&(j<8)){
		board[i][j]+=d;
		i--;j++;
	}
}

void eightQueen(){
	if(st.size()==8){
		printQueen();
		flag=true;
		return;
	}
	for (int i=0;i<8;i++){
		for (int j=0;j<8;j++){
			if(board[i][j]==0){
				map m={i,j};
				st.push(m);
				changeBoard(i,j,1);
				eightQueen();
				if(flag==1)break;
				st.pop();
				changeBoard(i,j,-1);
			}
			if (flag==1) break;
		}
	}
}

int main(){
	int n,r,c,i;
	cin >> n;
	for (i=0;i<n;i++){
		cin >> r >> c;
		map m={r,c};
		st.push(m);
		changeBoard(r,c,1);
	}
	eightQueen();
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> city(N);
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    city.at(a-1) += 1;
    city.at(b-1) += 1;
  }
  for(int i = 0; i < N; i++){
    cout << city.at(i) << endl;
  }
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265359
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double larg = 6*m; 
    double sarg = 30*h + 0.5*m;

    double diff = abs(larg-sarg);

    double ans = pow(a, 2) + pow(b, 2) - (2*a*b)*cos(diff*PI/180);

//    cout << sqrt(ans) << endl;

    printf("%10.11f", sqrt(ans));
}




Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin>>S>>T;
    vector<string> A;
    int N = S.size();
    int M = T.size();
    for(int i = 0; i+M-1 < N; ++i){
        //iが始まりで、そこから含まれているとすることができるか
        string x = "";
        bool flag = true;
        rep(j,N){
            if(i<=j&&j<i+M){
                if(S[j] == T[j-i]){
                    x.push_back(S[j]);
                }
                else if(S[j] == '?'){
                    x.push_back(T[j-i]);
                }
                else{
                    flag = false;
                    break;
                }
            }
            else{
                if(S[j] == '?'){
                    x.push_back('a');
                }
                else{
                    x.push_back(S[j]);
                }
            }
        }
        if(flag){
            A.push_back(x);
        }
    }
    sort(all(A));
    //print(A);
    if(A.size()){
        cout<<A[0]<<endl;
    }
    else{
        cout<<"UNRESTORABLE"<<endl;
    }
}

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

int n, T, s, g;
ll ans;
int t[200010];

int main(){
  cin >> n >> T;
  rep(i,n) cin >> t[i];
  rep(i,n){
    if(s<=t[i]&&t[i]<=g)ans += t[i] + T - g;
    else ans += T;
    s = t[i];
    g = t[i] + T;
  }
  cout << ans << endl;
}

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

#define MAX 200001

int main(int, char**)
{
    int n;
    int a[MAX] = {0};

    cin >> n;
    int tmp;
    for (int i = 2; i <= n; i++) { cin >> tmp; a[tmp]++; }
    for (int i = 1; i <= n; i++) { cout << a[i] << endl; }

    return 0;
}

Measured memory_bytes: 4404
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] d = new int[n];
        Arrays.setAll(d, i -> scanner.nextInt());
        Arrays.sort(d);
        int m = scanner.nextInt();
        int[] t = new int[m];
        Arrays.setAll(t, i -> scanner.nextInt());
        Arrays.sort(t);
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (d[i] == t[j]) {
                i++;
                j++;
            } else if (d[i] < t[j]) {
                i++;
            } else {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

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

typedef long long ll;

const int MOD = (int)(1e+9) + 7;
const int INV = (MOD + 1) / 2;
int N;
ll sum, pow_A;
vector<int> A;

void input_init(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	sum = (ll)0;
	for (int i = 0; i < N; ++i) {
		sum += A[i];
		sum %= MOD;
	}
}

ll solve(void) {
	pow_A = (ll)0;
	for (int i = 0; i < N; ++i) {
		ll p2 = (ll)A[i] * A[i];
		p2 %= MOD;
		pow_A += p2;
		pow_A %= MOD;
	}
	ll val = (sum * sum) % MOD;
	val = ((val + MOD) - pow_A) % MOD;
	val *= INV;
	val %= MOD;
	return val;
}

int main(void) {
	input_init();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3908
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    while 1:
        n = int(readline())
        if not n:
            exit()

        pre = [0] * (n+1)
        now = [0] * (n+1)
        maximum = 0

        for _ in range(n):
            for x, c in enumerate(readline().rstrip(), 1):
                if c == '.':
                    now[x] = min(pre[x-1], pre[x], now[x-1]) + 1
                    if maximum < now[x]:
                        maximum = now[x]
            pre = now
            now = [0] * (n+1)

        print(maximum)


main()

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

long long l,r;
int main(){
  cin>>l>>r;
  int ans = 2018;
  for(long long i=l;i<r;i++){
    for(long long j=i+1;j<=r;j++){
      int t=(i%2019)*(j%2019)%2019;
      ans = min(ans,t);
  //   cout <<i<<' '<<j<<' '<<t<<endl;
     
      if(ans==0){
        cout <<0<<endl;
        return 0;
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/

#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>

ll power(ll x,ll y,ll p);
int Bit(ll x);
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}

const int N=1e5 + 5;
ll arr[N];
ll MOD=1e9 + 7;

ll n,m;
int main(){
	scanf("%d%d",&n,&m);
	n*=pow(10,(int(log10(m))+1));
	n+=m;
	if(1.0*sqrt(n) == int(sqrt(n)))
		puts("Yes");
	else
		puts("No");
}










ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}


int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}










Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] m = new int[N];
        
        //初期化
        for(int i = 0; i < N; i++){
            m[i] = sc.nextInt();
        }
        
        //お菓子を最低一種類ずつ作り、Xの残りを算出
        for(int i = 0; i < N; i++){
            X -= m[i];
        }
        
        //m[i]の中で一番少ない量で出来るドーナツを抽出。
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < N; i++){
            min = Math.min(min,m[i]);
        }
    
        //最初に作った各一個を忘れないようにカウント。
        System.out.println(N + (X / min));
    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    string T;
    cin >> T;

    string S = "";
    REP(i, T.size()){
        if(T[i]=='?') S += 'D';
        else S += T[i];
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 3888
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll i,n,m,s=0,c=0;cin>>n>>m;vi v(n);for(i=0;i<n;i++) cin>>v[i],s+=v[i];
	s=s/(4*m)+((s%(4*m))>0);
	for(i=0;i<n;i++) if(v[i]>=s) c++;
	if(c<m) cout<<"No\n"; else cout<<"Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

string K[4] = {"AC", "WA", "TLE", "RE"};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> mp;
    rep(i, N) {
        string S; cin >> S;
        mp[S]++;
    }
    rep(i, 4) {
        cout << K[i] << " x " << mp[K[i]] << endl;
    }


    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  
  vector <int64_t> l(n+1);
  l.at(0)=2;
  l.at(1)=1;
  
  for(int i=2;i<n+1;i++)
  {
    l.at(i)=l.at(i-2)+l.at(i-1);
  }
  
  cout<<l.at(n)<<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007

int i,j,k;

struct edge {
    int to;
    int cost;
};

typedef long long ll;
using namespace std;
using P = pair<int, int>;

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    ll n,m;
    ll f[100050];
    f[0]=1;
    f[1]=1;
    for(i=2;i<100050;i++){
        f[i]=(f[i-1]+f[i-2])%MOD;
    }
    f[0]=1;
    cin >> n >> m;
    ll nex=0;
    ll ans=1;
    for(i=0;i<m;i++){
        ll d;
        cin >> d;
        if(d-1-nex>=0){
            ans *= f[d-1-nex];
        }else{
            ans = 0;
        }
        ans %= MOD;
        nex = d+1;
    }
    ans *= f[n-nex];
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <atcoder/all>

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define REP(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using namespace atcoder;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, m, a, b;
	cin >> n >> m;
	dsu d(n);
	rep(i, m) {
		cin >> a >> b;
		a--, b--;
		d.merge(a, b);
	}
	auto g = d.groups();
	cout << g.size() - 1 << endl;
}



Measured memory_bytes: 8972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int A,B,C,D;
  	cin>>A>>B>>C>>D;
  
  	if(A+B>C+D){
      cout<<"Left"<<endl;}
  
  else	if (A+B<C+D){
      cout<<"Right"<<endl;}
       
     else  
     { cout<<"Balanced"<<endl;}
}

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

int a, b;

main()
{
    for (int i = 0; i < 4; i++)
    {
        int p;
        cin >> p;
        a += p;
    }
    for (int i = 0; i < 4; i++)
    {
        int p;
        cin >> p;
        b += p;
    }
    cout << max(a, b) << endl;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int a,b;
    cin >> a >> b;
    if(a+b < 10) cout << a + b << endl;
    else cout << "error" << endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int n;
  string s,t;
  cin >> n;
  cin >> s >> t;

  rep(i,0,n) {
    cout << s[i] << t[i];
  }
  cout <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c;
    int cnt=1;
    scanf("%d %d %d",&a,&b,&c);

    if(a!=b){
        cnt++;
    }
    if(!(a==c||b==c)){
        cnt++;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll res = 0;
  res += a[0] / 2;
  for(int i = 1;i < n;i++)res += a[i];
  cout << res << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//ダイクストラ法
vll dijkstra(ll n, vector<vll> &c, ll start) {
  vll minc(n, inf);
  minc[start] = 0;

  for (ll i = 0; i < n - 1; i++) {
    priority_queue<vll, vector<vll>, greater<vll>> pq;
    for (ll j = 0; j < n; j++) {
      if (minc[j] == inf) continue;
      for (ll k = 0; k < n; k++) {
        if (minc[k] < inf) continue;
        pq.push({minc[j] + c[j][k], k});
      }
    }
    vll v = pq.top();
    minc[v[1]] = v[0];
  }

  return minc;
}

int main() {
  ll h, w;
  cin >> h >> w;
  vector<vll> c(10, vll(10)), a(h, vll(w));
  for (ll i = 0; i < 10; i++) {
    for (ll j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  vll v(10);
  for (ll i = 0; i < 10; i++) v[i] = dijkstra(10, c, i)[1];
  ll ans = 0;
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      if (a[i][j] == -1) continue;
      ans += v[a[i][j]];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (int T = 1;; T++) {
			int W = sc.nextInt();
			if (W == 0) return;
			int N = sc.nextInt();
			int[] v = new int[N];
			int[] w = new int[N];
			for (int i = 0; i < N; i++) {
				String[] in = sc.next().split(",");
				v[i] = Integer.valueOf(in[0]);
				w[i] = Integer.valueOf(in[1]);
			}

			int maxCost = 0;
			int minWeight = Integer.MAX_VALUE / 2;
			int[][] dp = new int[2][W + 1];
			for (int i = 0; i < N; i++) {
				for (int j = 0; j <= W; j++) {
					if (j - w[i] >= 0) dp[(i + 1) & 1][j] = Math.max(dp[i & 1][j], dp[i & 1][j - w[i]] + v[i]);
					else dp[(i + 1) & 1][j] = dp[i & 1][j];

					if (dp[(i + 1) & 1][j] == maxCost && j < minWeight) {
						minWeight = j;
					} else if (dp[(i + 1) & 1][j] > maxCost) {
						maxCost = dp[(i + 1) & 1][j];
						minWeight = j;
					}
				}
			}
			System.out.println("Case " + T + ":");
			System.out.println(maxCost + "\n" + minWeight);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 24936
h,w = map(int,input().split())
A = [list(input()) for i in range(h)]
White_rows = []
for i in range(h):
    if A[i] == ['.' for j in range(w)]:
        White_rows += [i]
White_rows.sort(reverse=True)
for row in White_rows:
    A.pop(row)
White_cols = []
for i in range(w):
    if all([A[j][i] == '.' for j in range(len(A))]):
        White_cols += [i]
White_cols.sort(reverse=True)
for col in White_cols:
    for j in range(len(A)):
        A[j].pop(col)
for a in A:
    print(*a,sep='')

Measured memory_bytes: 4596
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

A,B=rl()
yn(A%2==1 and B%2==1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s,c[4]={"dream","dreamer","erase","eraser"};
  bool f;
  int p,ans=0,l;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<4;j++){
      f=1;
      p=0;
      for(int k=0;k<c[j].size();k++){
        if(s[s.size()-1-i-k]!=c[j][c[j].size()-1-k]){
          f=0;
          break;
        }
      }
      if(f){
        i=i+c[j].size()-1;
        ans+=c[j].size();
        break;
      }
    }
  }
  if(ans==s.size()) cout<<"YES\n";
  else cout<<"NO\n";
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
const int lim = 50;

int N,M;
int a[lim] , b[lim];

bool graph[lim][lim];
bool visited[lim];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < N; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}
int main(){
    cin >> N >> M;

    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < M; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int k = 0; k < N; ++k) {
            visited[k] = false;
        }

        dfs(0);

        bool bridge = false;
        for (int k = 0; k < N; ++k) {
            if (visited[k] == false) {
                bridge = true;
            }
        }
        if (bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
void fastio(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
}
struct obj{
	ll r,a,w,t;
	obj(){}
	obj(ll r,ll a,ll w,ll t):r(r),a(a),w(w),t(t){}
	bool operator < (const obj& a) const{
		return (r+t) < (a.r+a.t);
	}
};
int N;
obj xs[2010];
ll dp[2010][4010];
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		ll a,b,c,d;
		cin >> a >> b >> c >> d;
		xs[i] = obj(a,b,c,d);
	}
	sort(xs,xs+N);
	for(int i=0;i<=N;i++){
		for(int j=0;j<=4000;j++){
			dp[i][j] = -LLINF;
		}
	}
	dp[0][0] = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=4000;j++){
			if(j+xs[i].r<=4000&&j<xs[i].t)chmax(dp[i+1][j+xs[i].r],dp[i][j]+xs[i].a);
		}
		for(int k=0;k<=4000;k++){
			if(k+xs[i].r<=4000&&k<xs[i].t)chmax(dp[i+1][k+xs[i].r],dp[i+1][k]+xs[i].w);
		}
		for(int j=0;j<=4000;j++){
			chmax(dp[i+1][j],dp[i][j]);
		}
	}	
	ll ans = 0;
	for(int i=0;i<=4000;i++){
		ans = max(ans,dp[N][i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 65856
n,c,k = map(int,input().split())
t = []
cnt,ans = 0,0
bt = 10**10
btl = []
for i in range(n):
    t.append(int(input()))

t.sort()

for i in range(n):
    if (t[i] > bt)|(cnt == c):
        ans += 1
        cnt,bt = 0,10**10
    if (bt == 10**10):
        bt = t[i]+k
        cnt += 1
    else:
        cnt += 1
        
if (cnt != 0):
    ans += 1

print(ans)

Measured memory_bytes: 7388
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li unsigned long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s1 second
const ll INF=(1LL<<60)-1;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s1 > j.s1;
    else
    return i.f<j.f;
    
}

void solve()
{
    li n,m,k;
    cin>>n>>m>>k;
    vector<li>a(n),b(m);
    rep(i,n)
    {
        cin>>a[i];
        if(i>0)
        a[i]+=a[i-1];
    }
    rep(i,m)
    {
        cin>>b[i];
        if(i>0)
        b[i]+=b[i-1];
    }
    li ans=upper_bound(b.begin(),b.end(),k)-b.begin();
    rep(i,n)
    {
        if(a[i]>k)
        break;
        li c=i+1;
        c+=upper_bound(b.begin(),b.end(),k-a[i])-b.begin();
        ans=max(ans,c);
    }
    cout<<ans;
    
}
int main()
{
    FAST_IO;
    li t;
    t=1;
    while(t--)
    solve(),cout<<endl;
    
}


Measured memory_bytes: 6376
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << 0 << endl;
  } else {
    cout << min(a * b, min(b * c, c * a)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
vector<ll>v[200005];
bool visited[200005] = {false};

ll dfs(ll p){
    queue<ll>q;
    q.push(p);
    visited[p]=true;
    ll count=0;
    while(!q.empty()){
        ll i;
        ll p1=q.front();
        q.pop();
        for(i=0;i<v[p1].size();i++){
            if(visited[v[p1][i]]==false){
                visited[v[p1][i]]=true;
                count++;
                q.push(v[p1][i]);
            }
        }
    }
    return count+1;
}

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll n,m;
    cin >> n >> m;
    ll i;
    for(i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll ans=dfs(1);
    for(i=1;i<=n;i++){
        if(visited[i]==false){
            ll d=dfs(i);
            ans=max(ans,d);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17452
# def solve(dp,L,i,j):
#     if i==len(dp):
#         return 0

#     else:
#         temp=0
#         for k in range(3):
#             if j!=k:
#                 temp=max(temp,L[i][k]+solve(dp,L,i+1,k))
#         dp[i]=temp
#         return dp[i]

T=int(input())
A=[]
for x in range(T):
    l=[int(i) for i in input().split()]
    A.append(l)
A.append([0,0,0])

for i in range(T-1,-1,-1):
    for j in range(3):
        temp=0
        for k in range(3):
            if j!=k:
                temp=max(temp,A[i][j]+A[i+1][k])

        A[i][j]=max(A[i][j],temp)
    # print(A)
    

print(max(A[0]))



Measured memory_bytes: 90420