akhauriyash/Code-Regression huggingface dataset:
N = input()
A = map(int , raw_input().split())

min_div = float("inf")
for i in range(N):
	c = 0
	while A[i] % 2 == 0:
		A[i] /= 2
		c += 1
	if min_div > c:
		min_div = c
print min_div


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

using namespace std;

typedef long long ll;

const int MAX = 107;

int a[MAX];
int g[MAX*MAX*MAX];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,k;cin>>n>>k;
	for(int i = 0; i<n; ++i)
		cin>>a[i];	
	for(int i = 1; i<=k; ++i)g[i]=-1;
	for(int i = 1; i<=k; ++i)
	{
		for(int j = 0; j<n&&a[j]<=i; ++j)
			if(g[i-a[j]]==0)g[i] = 1;
		if(g[i]==-1)g[i] = 0;
	}
	if(g[k]==1)cout << "First\n";
	else cout << "Second\n";
	
	
	return 0;
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

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

    int n,k,ans=0;
	
	cin >> n >> k;

	
	if(n < k){
	cout << "0"<< endl;
	}
	else{
		cout << "10" << endl;
	}
	
}

Measured memory_bytes: 888
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()

sign = 0
for i in range(N):
    if A[i] < 0:
        sign += 1
        A[i] *= -1
sign %= 2
A.sort()
if sign == 0:
    print(sum(A))
else:
    print(sum(A[1:])-A[0])

Measured memory_bytes: 14412
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   bitcount(x)  (int)__builtin_popcount(x)
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 




int bigmod(int a, int p, int m){ 
    if (p == 0)  return (1 % m) ; 
    if (p & 1){ 
        int p1 = a % m ;
        int p2 = bigmod( a, p-1, m ); 
        return  (p1 * p2) % m; 
    }
    int p1 = bigmod( a, p/2, m ); 
    return  (p1 * p1) % m; 
}


inline void solve(){
    int  n, bit = 0, l = 0, r = 0, in=-1 ; 
    string  x ; 
    cin >> n >> x ; 
    for (int i=0;i<n;i++) {
        bit += (x[i]=='1') ; 
        if (x[i] == '1') in = n-i-1; 
    }
    for (int i=n-1,j=0;i>=0 && bit>1;i--,j++) {
        if (x[i] == '1'){
            l += bigmod(2,j,bit-1); 
            r += bigmod(2,j,bit+1); 
            l %= bit-1; 
            r %= bit+1; 
        }
    }
    for (int  i = 0 ; i < n  ; i++ ) { 
        int num=0,cnt=1;
        if (bit == 1){
            if (x[i] == '1')  num = 0,cnt--; 
            else  num = bigmod(2,n-i-1,2)+bigmod(2,in,2) ; 
        }
        else if (bit == 0) {
            num = bigmod(2,n-i-1,1); 
        }
        else if (x[i] == '1'){ 
            num = l; 
            num -= bigmod(2,n-i-1,bit-1); 
            if (bit-1 == 0) cnt = 0 ;  
            if (num<0) num += bit-1; 
            num %= bit-1; 
        }
        else { 
            num = r ; 
            num += bigmod(2,n-i-1,bit+1) ; 
            num %= bit+1; 
        } 
        while (num){
            num = num % bitcount(num);
            cnt++;
        }
        co(cnt); 
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3764
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,i;
    int tmp1,tmp2;
    int abs_min;
    int t[101];
    
    scanf("%d",&n);
    for(i = 1; i <= n; i++) scanf("%d",&t[i]);
    
    //それぞれの和の初期化
    tmp1 = t[1];
    for(i = 2; i <= n; i++) tmp2 += t[i];
    abs_min = abs(tmp1-tmp2);
    
    for(i = 2; i <= n; i++){
        tmp1 += t[i];
        tmp2 -= t[i];
        if(abs(tmp1-tmp2) < abs_min) {
            abs_min = abs(tmp1-tmp2);
//            printf("new abs is %d\n",abs(tmp1-tmp2));
        }
    }
    printf("%d\n",abs_min);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const int INF = INT_MAX / 2;

vector<vector<int>> ds;
vector<vector<int>> cs;

map<int, int> gs[3];

int calc(const int c1, const int c2, const int c3, const int N, const int C) {
    int ans = 0;

    vector<int> colors = {c1, c2, c3};

    for (int i = 0; i < 3; i++) {
        int to = colors[i];
        for (auto p : gs[i]) {
            int from = p.first;
            int cnt = p.second;
            // printf("from: %d, to: %d, cnt: %d\n", from, to, cnt);
            ans += ds[from][to] * cnt;
        }
    }

    return ans;
}

int solve(const int N, const int C) {
    int ans = INF;
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if (i == j || i == k || j == k) {
                    continue;
                }
                chmin(ans, calc(i, j, k, N, C));
            }
        }
    }
    return ans;
}

int main(void) {
    int N, C;
    cin >> N >> C;

    ds.resize(C, vector<int>(C));
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> ds[i][j];
        }
    }

    cs.resize(N, vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int c;
            cin >> c;
            c--;
            cs[i][j] = c;
            gs[(i + j) % 3][c]++;
        }
    }

    cout << solve(N, C) << endl;

    return 0;
}


Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
//#define int long long
int n;
long long INF = 1234567890123456789;
long long krat[301][301];
long long get(int f, int s) {
	if (s < f) swap(f, s);
	return krat[f][s];
}
signed main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (i != j) krat[i][j] = INF;
		}
	}
	vector <pair <int, pair <int, int> > > go;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			int cur;
			scanf("%d", &cur);
			if (i > j) {
				go.push_back(make_pair(cur, make_pair(j, i)));
			}
		}
	}
	sort(go.begin(), go.end());
	long long ans = 0;
	for (auto it : go) {
		pair <int, int> cur = it.second;
		int dist = get(cur.first, cur.second);
		if (dist < it.first) return 0 * printf("-1");
		if (dist == it.first) continue;
		ans += it.first;
		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				krat[i][j] = min(krat[i][j], get(i, cur.first) + it.first + get(j, cur.second));
				krat[i][j] = min(krat[i][j], get(j, cur.first) + it.first + get(i, cur.second));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=(a[i]*a[j]);
        }
    }
    cout<<sum;
    return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0; i<n; i++) cin>>a[i];
	int winner[k+5][2];
	winner[0][0] = 1;
	winner[0][1] = 0;
	for(int i=1; i<=k; i++){
		int win0 = 1, win1 = 0;
		for(int j=0; j<n; j++){
			if(a[j] <= i){
				if(winner[i-a[j]][1]==0) win0=0;
				if(winner[i-a[j]][0]==1) win1=1;
			}
		}
		winner[i][0]=win0;
		winner[i][1]=win1;
	}
	int an = winner[k][0];
	if(an==0) cout<<"First";
	else cout<<"Second";
}

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

int selectionSort(int A[], int N){
  int minj, sw = 0;
  
  for ( int i = 0; i < N; i++ ){
  	minj = i;
  	for ( int j = i; j < N; j++ ){
  	  if ( A[j] < A[minj] ) minj = j;
  	}
  	if ( A[i] != A[minj] ){
  	  swap(A[i], A[minj]);
  	  sw++;
    }
  }
  
  return sw;
}

int main(){
  int N, A[100],sw;
  
  cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> A[i];
  
  sw = selectionSort(A, N);
  
  for ( int i = 0; i < N; i++ ){
  	if (i) cout << " ";
  	cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  
  return 0;
}


Measured memory_bytes: 3108
#include <iostream>

int main(){
    long int h,w;
    std::cin>>h>>w;
    if(h==1 || w==1)
        std::cout << 1;
    else{
        long int x,y;
        x = w % 2;
        y = h % 2;
        if(x==0){
            x = w / 2;
        }
        else{
            x = w /2 + 1;
        }
        if(y==0){
            y = h / 2;
        }
        else{
            y = h /2 + 1;
        }
        std::cout << x*y + (w-x)*(h-y);
    }
    return 0;
    
}

Measured memory_bytes: 256
/*  ex4_1
    potter0723sw  */

#include <stdio.h>
#include <math.h>

int main(void) {
    float num,d;//小数点以下も考えたいのでfloat型
    int answer;
    scanf("%f %f",&num ,&d);
    answer = ceil(num/(d * 2 + 1));
	//監視員が見れるのは自分がいる木と周囲d本だから2d+1本見れる。
	//監視範囲が被ってもいいことを考慮し小数以下切り上げ
    printf("%d\n", answer);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int a = 0;
  
  if (N <= 1000) {
  	a = 1000 - N;
  } else if ( N <= 2000) {
  	a = 2000 - N;
  } else if (N <= 3000) {
  	a = 3000 - N;
  } else if (N <= 4000) {
  	a = 4000 - N;
  } else if (N <= 5000) {
  	a = 5000 - N;
  } else if (N <= 6000) {
  	a = 6000 -N;
  } else if (N <= 7000) {
  	a = 7000 - N;
  } else if (N <= 8000) {
  	a = 8000 - N;
  } else if (N <= 9000) {
  	a = 9000 -N;
  } else {
    a = 10000 - N;
  }

  cout << a << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
#include <cmath>
 
using namespace std;
 
int main(){
    int n;
    double x[100] = {0},y[100] = {0},p_1 = 0,p_2 = 0,p_3 = 0,p_infinity = -1;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%lf",&x[i]);
    for(int i = 0; i < n; i++) scanf("%lf",&y[i]);
 
    for(int i = 0; i < n; i++){
        p_1 += abs(x[i] - y[i]);
        p_2 += (x[i] - y[i])*(x[i] - y[i]);
        p_3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
        p_infinity = (p_infinity >= abs(x[i] - y[i]))? p_infinity:abs(x[i] - y[i]);
    }
    printf("%.6lf\n",p_1);
    printf("%.6lf\n",sqrt(p_2));
    printf("%.6f\n",cbrt(p_3));
    printf("%.6lf\n",p_infinity);
 
}


Measured memory_bytes: 2924
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
    int n,m;
    int k,s,p[20]={},lamp[20]={},tmp,ans=0;
    bool jud;
    cin>>n>>m;
    for (int im = 0; im < m; im++) {
        cin>>k;
        for (int ik = 0; ik < k; ik++) {
            cin>>s;
            lamp[im]+=1<<(s-1);
        }
    }
    for (int i = 0; i < m; i++) {
        cin>>p[i];
    }

    for (int swt = 0; swt < (1<<n); swt++) {
        jud=true;
        for (int ilamp = 0; ilamp < m; ilamp++) {
            tmp=0;
            for (int i = 0; i < n; i++) {
                if(swt&lamp[ilamp]&(1<<i))tmp++;
            }
            if(tmp%2!=p[ilamp])jud=false;
        }
        if(jud)ans++;
    }



    cout<<ans<<"\n";

    

    return 0;
}

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

static const int N = 100;
static const int INF = (1 << 30);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n;
int m[N][N];

int prim(){
    int u,min_val;
    int d[N],p[N],color[N];

    for(int i=0;i<n;i++){
        d[i] = INF;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;
    while(1){
        min_val = INF;
        u = -1;
        for(int i=0;i<n;i++){
            if(min_val > d[i] && color[i] != BLACK){
                u = i;
                min_val = d[i];
            }
        }

        if(u == -1) break;
        color[u] = BLACK;
        for(int v=0;v<n;v++){
            if(color[v] != BLACK && m[u][v] != INF){
                if(d[v] > m[u][v]){
                    d[v] = m[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for(int i=0;i<n;i++){
        if(p[i] != -1) sum += m[i][p[i]];
    }

    return sum;
}


//mainは問題なし
int main(){
    int in_val;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> in_val;
            if(in_val == -1)
                in_val = INF;
            m[i][j] = in_val;
        }
    }

    cout << prim() << endl;

}



Measured memory_bytes: 3092
n,m = map(int,input().split())
a = [list(input()) for i in range(n) ]
b = [list(input()) for i in range(m) ]
ans = 0
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if ans == 0:
            count = 0
            for k in range(m):
                for l in range(m):
                    if b[k][l] == a[i+k][j+l]:
                        count = count + 1
            if count == m*m:
                ans = 1
if ans == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mx = 1e5+5;
ll knapsack[mx];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,W;
    cin>>n>>W;
    for(int i=0;i<n;i++)
    {
        int wei,val;
        cin>>wei>>val;
        for(int i = W;i>=wei;i--)
            knapsack[i] = max(knapsack[i],knapsack[i-wei]+val);
    }
    ll ans =0;
    for(int i=0;i<=W;i++)
    ans = max(ans,knapsack[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

int n;
int f[15][15];

int main() {
    scanf("%d", &n);
    for (int i = 0; i <= 9; ++i) f[1][i] = 1;
    for (int i = 2; i <= 10; ++i)
        for (int j = 0; j <= 9; ++j) {
            if (!j) f[i][j] = f[i - 1][0] + f[i - 1][1];
            else if (j == 9) f[i][j] = f[i - 1][8] + f[i - 1][9];
            else f[i][j] = f[i - 1][j - 1] + f[i - 1][j] + f[i - 1][j + 1];
        }
    int sum = 0, ok = 0, cnt, now;
    for (int i = 1; i <= 10; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (sum + f[i][j] >= n) {
                printf("%d", j);
                n -= sum;
                now = j;
                ok = 1;
            }
            if (ok) break;
            sum += f[i][j];
        }
        if (ok) {
            cnt = i;
            break;
        }
    }
    for (int i = cnt - 1; i; --i) {
        sum = 0;
        if (now) {
            if (sum + f[i][now - 1] >= n) {
                printf("%d", --now);
                n -= sum;
                continue;
            }
            sum += f[i][now - 1];
        }
        if (sum  + f[i][now] >= n) {
            printf("%d", now);
            n -= sum;
            continue;
        }
        sum += f[i][now];
        if (now != 9) {
            if (sum + f[i][now + 1] >= n) {
                printf("%d", ++now);
                n -= sum;
                continue;
            }
            sum += f[i][now + 1];
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int d,e;
	while(cin>>d>>e,d||e){
		double g;
		rep(i,d+1){
			int x=i,y=d-i;
			if(i==0)g=abs(sqrt(x*x+y*y)-e);
			else g=min(g,abs(sqrt(x*x+y*y)-e));
		}
		printf("%.9f\n",g);
	}
	return 0;
}

Measured memory_bytes: 3152
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    std::vector<int> V(3);
    std::cin >> V[0] >> V[1] >> V[2];

    std::sort(std::begin(V), std::end(V));

    cerr << V[0] << " " << V[1] << " " << V[2] << endl;
    auto d2 = V[2] - V[0];
    auto d1 = V[2] - V[1];

    if (((d2 % 2) == 0 && (d1 % 2) == 0) || ((d1 % 2) != 0 && (d2 % 2) != 0)) {
        std::cout << (d1 + d2) / 2 << std::endl;
    }
    else {
        std::cout << (d1 + d2 + 1)/2 + 1 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    print("#" * W)
    for i in range(H-2):
        if i != 0 or i != H-1:
            print("#"+"." * (W-2)+"#")
    print("#" * W)
    print()


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

int main(){
  int X,N;cin>>X>>N;
  vector<int> p(N);rep(i,N)cin>>p[i];
  vector<int> ans(500,1000);
  rep(i,500){
    int tmp = i - 250;
    if(find(all(p),tmp)!=p.end()) continue;
    ans[i] = abs(X - tmp);
  }
  ll m = 1000,tmp;
  rep(i,500){
    if(m>ans[i]){
      m=ans[i];
      tmp = i-250;
    }
  }
  cout<<tmp<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#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 Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int table[510][510];

int main(void)
{
    int N,M,Q;
    cin >> N >> M >> Q;

    REP(i, M){
        int l,r;
        cin >> l >> r;
        table[l][r]++;
    }
    Rep(i, 1, N+1){
        Rep(j, 1, N+1){
            table[i][j] += (table[i-1][j] + table[i][j-1] - table[i-1][j-1]);
        }
    }

    vector<int> ans(Q);
    REP(i, Q){
        int p,q;
        cin >> p >> q;
        ans[i] = table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1];
    }

    for(auto&& a : ans) pr(a);
}

Measured memory_bytes: 2304
n = int(input())
lista = []
xy = []
for i in range(n):
    a = int(input())
    lista.append(a)
    s = [list(map(int, input().split())) for _ in range(a)]
    xy.append(s)
ans = 0
for j in range(2**n):
    num = 0
    d = []
    for k in range(n):
        if((j >> k) & 1) == 1:
            d.append(1)
        else:
            d.append(0)
    c = 0
    for l in range(n):
        cnt = 0
        if d[l] == 1:
            if lista[l] != 0:
                for m in range(lista[l]):
                    if xy[l][m][1] == d[xy[l][m][0] - 1]:
                        cnt += 1
                        if cnt == lista[l]:
                            c += 1
                    else:
                        break
            else:
                c += 1
    if c == d.count(1):
        num = c
    ans = max(num, ans)
print(ans)

Measured memory_bytes: 9160
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        
        int now = 7;
        now %= k;
        Set<Integer> set = new HashSet<Integer>();
        int count = 1;
        
        int oldsize = 0;
        while (true) {
            if (now == 0) break;
            
            now *= 10;
            now += 7;
            now %= k;
            
            count++;
            
            set.add(now);
            if (oldsize == set.size()) {
                System.out.println(-1);
                return;
            }
            oldsize = set.size();
        }
        System.out.println(count);
    }
}


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

int main() {
	
	while(1){
		int n, x;
		cin >> n >> x;
		if(n==0 && x==0) break;
		int cnt=0;
		for(int i=1; i<=n-2; i++){
			for(int j=i+1; j<=n-1; j++){
				for(int k=j+1; k<=n; k++) if(i+j+k==x) cnt++;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3112
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int dp[310][310][310];
int main(){
	int n,m,MOD=1000000007;
	cin>>n>>m;
	vvp in(n+1);
	rep(i,m){
		int a,b,c;cin>>a>>b>>c;
		in[b].pb({a,c});
	}
	
	dp[0][0][0]=1;
	rep(i,n+1)rep(j,n+1)rep(k,n+1)if(dp[i][j][k]){
		int t=max(i,max(j,k));
		rep(l,in[t].size())if(dp[i][j][k]){
			int co=0;
			if(in[t][l].first<=i)co++;
			if(in[t][l].first<=j)co++;
			if(in[t][l].first<=k)co++;
			if(co!=in[t][l].second)dp[i][j][k]=0;
		}
		(dp[t+1][j][k]+=dp[i][j][k])%=MOD;
		(dp[i][t+1][k]+=dp[i][j][k])%=MOD;
		(dp[i][j][t+1]+=dp[i][j][k])%=MOD;
	}
	int out=0;
	rep(i,310)rep(j,310)rep(k,310)if(max(i,max(j,k))==n)
		(out+=dp[i][j][k])%=MOD;
	cout<<out<<endl;
}










Measured memory_bytes: 114944
//package Dynamic;
import java.io.*;
import java.util.*;
class Main 
{
    static public void main(String[] args) throws IOException 
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        
        int n=Integer.parseInt(br.readLine());
        //long n=Long.parseLong(br.readLine());
        StringTokenizer st=new StringTokenizer(br.readLine());
        int ar[]=new int[n];
        int x=0;
        long s=0l;
        while(st.hasMoreTokens())
        {
        	ar[x]=2*Integer.parseInt(st.nextToken());
        	if(x%2==0)
        		s+=ar[x];
        	else
        		s-=ar[x];
        	x++;
        	//System.out.println(s);
        }
        s/=2;
        System.out.print(s+" ");
        for(int xx=0;xx<n-1;xx++)
        {
        	s=ar[xx]-s;
        	System.out.print(s+" ");
        }
    }
}

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

const int N = 1000;

class Stack {
  int top;
  int S[N];

public:
  Stack() { top = 0; }

  void push(int x) {
    S[top++] = x;
  }

  int pop() {
    return S[--top];
  }
};

int main() {
  int x, y;
  char symbol[10];
  Stack st;

  while (cin >> symbol) {
    char s = symbol[0];
    if (s == '+') {
      x = st.pop();
      y = st.pop();
      st.push(x + y);
    } else if (s == '-') {
      x = st.pop();
      y = st.pop();
      st.push(y - x);
    } else if (s == '*') {
      x = st.pop();
      y = st.pop();
      st.push(x * y);
    } else {
      x = atoi(symbol);
      st.push(x);
    }
  }

  cout << st.pop() << endl;

  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    for (auto &&i : v) scanf("%lld", &i);
    v.emplace_back(INF<ll>);
    auto u = make_v(20, n+1, n);
    ll l, q;
    cin >> l >> q;

    for (int i = 0; i < n; ++i) {
        u[0][i] = static_cast<int>(lower_bound(v.begin(), v.end(), v[i] + l+1) - v.begin()-1);
    }
    for (int i = 1; i < 20; ++i) {
        for (int j = 0; j < n; ++j) {
            u[i][j] = u[i-1][u[i-1][j]];
        }
    }
    for (int i = 0; i < q; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        if(a > b) swap(a, b);
        a--, b--;
        int ng = 0, ok = n+1;
        while(ok-ng > 1){
            int cur = a, mid = (ok+ng)/2;
            for (int j = 0; j < 20; ++j) {
                if(mid & (1<<j)){
                    cur = u[j][cur];
                }
            }
            if(cur >= b) ok = mid;
            else ng = mid;
        }
        printf("%d\n", ok);
    }
    return 0;
}


Measured memory_bytes: 9840
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main(){
  string s;
  cin>>s;
  int l=s.length();
  int b=1;
  if(s[0]!='A'){
    b=0;
  }
  int a=0;
  for(int i=2;i<l-1;i++){
    if(s[i]=='C'){
      a=i;
    }
  }
  if(a==0){
    b=0;
  }
  for(int i=1;i<l;i++){
    if(i==a){
      i++;
    }
    if(static_cast<int>(s[i])<'a'||'z'<static_cast<int>(s[i])){
      b=0;
    }
  }
  if(b==1){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> a;
bool ok[1000010];

bool check_pairwise() {
    for (int i=1;i<=1000000;i++) ok[i] = true;
    for (auto x: a) {
        if (x==1) continue;
        if (!ok[x]) return false;
        for (int i=2;i*i<=x;i++) {
            if (x%i==0) {
                if (!ok[i]||!ok[x/i]) return false;
                ok[i] = false;
                ok[x/i] = false;
            }
        }
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) {
        int x; cin >> x;
        a.pb(x);
    }
    sort(a.begin(), a.end());
    a.resize(unique(a.begin(), a.end())-a.begin());
    reverse(a.begin(), a.end());

    bool w = check_pairwise();
    if (w&&(a.size()>1||a[0]==1)) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int gcd = a[0];
    for (auto x: a) gcd = __gcd(x, gcd);
    cout << (gcd==1? "setwise": "not") << " coprime" << endl;
}


Measured memory_bytes: 8124
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	static int max=0;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		long X=sc.nextLong();
		for (long i = -200; i <= 300; i++) {
			for (long j = -200; j <= 300; j++) {
				if ((long)(Math.pow(i, 5)-Math.pow(j,5))==X) {
					System.out.println(i+" "+j);
					return;
				}
			}
		}
	}
	
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 36704
#include <cstdio>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int H, W, a[2009][2009], t[2009][2009], dp[2009][2009], pl[2009], pr[2009];
int main() {
	scanf("%d %d", &H, &W);
	int vl = inf, vr = -1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%d", &a[i][j]);
			vl = min(vl, a[i][j]);
			vr = max(vr, a[i][j]);
		}
	}
	int ret = inf;
	for (int i = 0; i < 4; i++) {
		pr[W] = 0;
		for (int j = 0; j < H; j++) {
			for (int k = 1; k <= W; k++) pl[k] = max(pl[k - 1], a[j][k - 1] - vl);
			for (int k = W - 1; k >= 0; k--) pr[k] = max(pr[k + 1], vr - a[j][k]);
			int curmin = inf;
			for (int k = 0; k <= W; k++) {
				curmin = min(curmin, dp[j][k]);
				dp[j + 1][k] = max({ curmin, pl[k], pr[k] });
			}
		}
		ret = min(ret, *min_element(dp[H], dp[H] + W + 1));
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				t[k][H - j - 1] = a[j][k];
			}
		}
		swap(H, W);
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				a[j][k] = t[j][k];
			}
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 49864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f,g,h;
  cin>>a>>b>>c>>d;
  e=c-d+b;
  f=d+c-a;
  g=e-c+a;
  h=f-d+b;
  cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;
}

Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 1000_000usize;
  let mut h = vec![0usize; nmax + 1];
  for i in 0..N {
    h[A[i]] += 1;
  }
  let mut mx = 0;
  let mut isprime = vec![true; nmax + 1];
  isprime[0] = false;
  isprime[1] = false;
  let mut i = 2;
  while i * i <= nmax {
    if isprime[i] {
      let mut j = 2;
      while i * j <= nmax {
        isprime[i * j] = false;
        j += 1;
      }
    }
    i += 1;
  }
  let mut pflag = true;
  for p in 2..=nmax {
    debug!(p);
    if isprime[p] {
      let mut f = 0usize;
      for q in 1..=nmax / p {
        let a = p * q;
        f += h[a];
      }
      mx = max(mx, f);
    }
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}
fn gcd(a: usize, b: usize) -> usize {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}
fn issetwise(A: Vec<usize>) -> bool {
  let mut a = A[0];
  for i in 1..A.len() {
    a = gcd(a, A[i]);
    if a == 1 {
      return true;
    }
  }
  return false;
}


Measured memory_bytes: 25088
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

tw :: (a -> Bool) -> [a] -> [a]
tw _ [] = []
tw p (x:xs)
  | p x = x:tw p xs
  | otherwise = []


main = do
  [n,k] <- getIntList
  p <- V.fromList . map (+(-1)) <$> getIntList
  c <- V.fromList <$> getIntList
  let acc i = tail $ scanl' (+) 0 $ map ((c V.!).(p V.!)) $ tw (/=i) (iterate (p V.!) (p V.! i)) ++ [i]
      ans i = 
        if val > 0
          then
            if rem /= 0
              then num * val + maximum (take (fromIntegral rem) list)
              else (num-1) * val + maximum list
          else maximum list
        where list = acc i
              val = last list
              len = fromIntegral $ length list
              num = k `div` len
              rem = k `mod` len
  print $ maximum $ map ans [0..n-1]


Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int64_t len = S.size();
    vector<int64_t> v(len + 1, 0);
    for (int64_t i = 0, cnt = 0; i < len; ++i) v[i + 1] = cnt = S[i] == '<' ? cnt + 1 : 0;
    for (int64_t i = len - 1, cnt = 0; i >= 0; --i) v[i] = max(v[i], cnt = S[i] == '>' ? cnt + 1 : 0);
    cout << accumulate(v.begin(), v.end(), 0LL) << endl;
}


Measured memory_bytes: 4740
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    double ans=0.0;
    rep(i, n) {
        rep(j, n) {
            ans += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        }
    }

    ans /= n;

    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
cc=0
if cc==0:
    n=int(input())
    xyh=[[0]*3 for i in range(n)]
    for i in range(n):
        xyh[i]=list(map(int,input().split()))
        if xyh[i][2]>=1:
            px=xyh[i][0]
            py=xyh[i][1]
            ph=xyh[i][2]
else:
    n=4
    px=3
    py=2
    ph=5
    xyh=[[0]*3 for i in range(n)]
    xyh[0]=[2,3,5]
    xyh[1]=[2,1,5]
    xyh[2]=[1,2,5]
    xyh[3]=[3,2,5]
        
yn=""
for cx in range(102):
    for cy in range(102):
        h=ph+abs(px-cx)+abs(py-cy)
        yn=""
        for i in range(n):
            if xyh[i][2]!=max(0,h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)):
                yn="No"
                break
        if yn=="No":
#            print(cx,cy,h,i,xyh[i][2],h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy))
            continue
        else:
#            print("1:",cx,cy,i,xyh[i][2],h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy))
            yn="Yes"
            break
#    print("2:",yn,cx,cy,h,i,xyh[i][2],h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy))
    if yn=="Yes":
        break
    
print(cx,cy,h)
    
    

Measured memory_bytes: 3064
from collections import deque
s = deque(list(input()))
q = int(input())
# -1がnotReverse, 1がReverser
isR = -1
for i in range(q):
    line = list(input().split())
    t = int(line[0])
    if t == 1:
        isR *= -1
    else:
        f = int(line[1])
        if isR + f == 0 or isR + f == 3:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    if i == q-1 and isR == 1:
        s.reverse()
print("".join(s))

Measured memory_bytes: 14236
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	string s;
	cin>>s;
	string d1="dream",d2="dreamer",e1="erase",e2="eraser";
	string t;
	for(int i=0;i<s.length();i++)
	{
	//	dbg(i);
		if(s[i]=='d') 
		{
			t+=d1;
			i+=5;
			if(i>=s.length())
				break;
			if(s[i]=='d')
			{
				i--;
				continue;
			}
			if(i+2>=s.length())
			{
				t+="er";
				break;
			}
			if(s[i+2]!='a')
			{
				t+="er";
				i+=2;
			}
			i--;
		}
		else if(s[i]=='e')
		{
			t+=e1;
			i+=5;
			if(i>=s.length()) break;
			if(s[i]=='r') {
				i++;
				t+='r';
			}
			i--;
		}
		else break;
	}
	if(s==t) cout<<"YES\n";
	else cout<<"NO\n";
}


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

#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
priority_queue<pll,vector<pll>,greater<pll> >pq;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>dp(k+1,0),arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[arr[0]]=1;
    int p=1;
    for(int j=arr[0]+1;j<=k;j++){
        if(p<n && j==arr[p]){
            dp[j]=1;
            p++;
            continue;

        }
        for(int i=0;i<n;i++){
            if(arr[i]<=j){
                if(dp[j-arr[i]]==0){
                    dp[j]=1;
                    break;
                }
            }
            else
                break;
        }
    }
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
int main() {
	string str;
	cin>>str;

	int N=0;
	for(auto c:str) {
		if(c=='+')++N;
		else --N;
	}
	cout<<N<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
int main(){
    int a=in(),b=in();
    cout<<max(a+b,max(a-b,a*b))<<endl;
}


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

cnt = int(input())
mochi_list = []
for i in range(cnt):
    mochi_list.append(int(input()))
# 餅リストから重複を削除
res_list = list(set(mochi_list))
# 結果リストの長さを出力
print(len(res_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int d,t,s;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>d>>t>>s;
	if(t*s>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3648
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,b,a[li],k,flag,cev;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld %lld",&n,&m,&k);
	for(lo i=1;i<=10;i++){
		k*=n;
		k-=m;
		printf("%lld\n",k);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

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

    cout << 3 * pow(r, 2) << 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)
typedef long long ll;

bool graph[50][50];
bool visited[50];

int a[50],b[50];

int n,m;

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(void){
   cin>>n>>m;
   rep(i,m){
      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;
   rep(j,n) visited[j]=false;
   dfs(0);
   bool bridge = false;
   rep(j,n) if(visited[j]==false)bridge=true;
   if(bridge) ans+=1;

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

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    cout << (a*b % 2 == 1 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    sys.exit()
for b in range(k+1,n+1):
    ans_per_loop = b - k
    loop, r = divmod(n,b)
    new = ans_per_loop*loop
    if r >= k:
        new += r-k+1
    ans += new
print(ans)


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

long long N;
map<string, long long> num;
int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		string s;
		cin >> s;
		num[s]++;
	}

	long long maxi = 0;
	for(auto item: num) {
		maxi = max(maxi, item.second);
	}

	vector<string> ans;
	for(auto item: num) {
		if(item.second == maxi) {
			ans.push_back(item.first);
		}
	}

	sort(ans.begin(), ans.end());
	for(long long i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int sum = 0, min_value = 1e9;

    int s[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> s[i];
        sum += s[i];
    }

    sort(s, s+N);

    int ans;
    if (sum % 10 != 0)
        ans = sum;
    else
    {
        ans = 0;
        for (int i = 0; i < N; ++i)
        {
            if ((sum - s[i]) % 10 != 0)
            {
                ans = sum - s[i];
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
# the max value with less than or equal to j weight
dp = [0] * (W+1)
for i in range(N):
    for j in range(w[i], W+1)[::-1]:
        dp[j] = max(dp[j], dp[j-w[i]] + v[i])
print(dp[W])

Measured memory_bytes: 41324
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
MOD = 998244353

if D[0] != 0:
    print(0)
else:
    c = Counter(D)
    c = sorted(c.items(), key=lambda x: x[0])
    ans = 1
    prev = 1
    dist = [False] * (N + 1)
    dist[0] = True
    for k, v in c:
        if k == 0:
            if v > 1:
                print(0)
                break
        else:
            if dist[k - 1] is not True:
                print(0)
                break
            dist[k] = True
            ans *= prev ** v
            ans %= MOD
            prev = v
    else:
        print(ans % MOD)


Measured memory_bytes: 21980