akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayDeque<Integer> stack = new ArrayDeque<>(); //Stack???????????£????????§?????????
		
		Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lineArr = line.split(" ");
        
        
		for(String item: lineArr){
			if (item.equals("+")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second + first);
			}else if (item.equals("-")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second - first);
			}else if (item.equals("*")) {
				int first = stack.pollFirst();
				int second = stack.pollFirst();
				stack.offerFirst(second * first);
			}else { // ??°???
				stack.offerFirst(Integer.parseInt(item));
			}
		}
		System.out.println(stack.pollFirst());
		sc.close();
	}

	
}

Measured memory_bytes: 26240
package main

import (
  "fmt"
)

var group = []int{1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1}

func main() {
  var x, y int; fmt.Scan(&x, &y)
  ans := "No"; if group[x-1] == group[y-1] {ans = "Yes"}
  fmt.Println(ans)  
}

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

int		main(void)
{
	char contest[5];

	scanf("%s", contest);
	if (strcmp(contest, "ABC") == 0)
	{
		printf("ARC");
		return (0);
	}
	else
	{
		printf("ABC");
		return (0);
	}
}

Measured memory_bytes: 1728
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
#define rep(i,N) for(int i = 0;i < N; ++i)
int main()
{
	int n;
	cin>>n;
	vector<long long> S(n + 1);
	vector<int> X(n + 1);
	vector<int> a(n);
	for(int i = 0;i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	for(int i = 0;i < n; ++i)
	{
		S[i + 1] = S[i] + a[i];
		X[i + 1] = X[i] ^ a[i];
	}
	long long ans = 0;
	for(int i = 0;i < n; ++i)
	{
		int lb = i + 1,ub = n + 1;
		while(ub - lb > 1)
		{
			int mid = (lb + ub) / 2;
			if((X[mid] ^ X[i]) == (S[mid] - S[i]))
			{
				lb = mid;
			}
			else
			{
				ub = mid;
			}
		}
		// printf("lb = %d,rb = %d\n",lb,rb);
		ans += lb - i;
		// printf("ans = %lld\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  int now = 0;
  for (int i = 0; i < s.size(); i++) {
    now += s[i] - '0';
  }
  
  if (now % 9 == 0) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 3736
#include <iostream>

using namespace std;

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

int main() {
  string s;
  cin >> s;
  rep(i,3) {
    if(s[i] == '1') s[i] = '9';
    else s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    int r, D, x2000;
    scanf("%d %d %d", &r, &D, &x2000);
    for(int i = 0;i < 10;i++){
        printf("%d\n", r*x2000-D);
        x2000 = r*x2000-D;
    }
    return 0;
}

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

int main() {
    int W, H, x, y, r;
    cin>>W>>H>>x>>y>>r;
    if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int main() {
    int w, h, n, w_min = 0, h_min = 0;
    cin >> w >> h >> n;

    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            if (x > w_min)
                w_min = x;
        } else if (a == 2) {
            if (x < w)
                w = x;
        } else if (a == 3) {
            if (y > h_min)
                h_min = y;
        } else if (a == 4) {
            if (y < h)
                h = y;
        }
    }

    int res_w = w - w_min;
    int res_h = h - h_min;
    if (res_w < 0 || res_h < 0) {
        cout << 0 << endl;
    } else {
        cout << res_w * res_h << endl;
    }
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N,Y;
    cin >> N >> Y;

    rep(x,0,10000){
        if(x*10000>Y or x>N) break;
        rep(y,0,10000){
            if(x*10000+y*5000>Y or x+y>N) break;
            int z=N-x-y;
            if(x*10000+y*5000+z*1000!=Y) continue;
            cout << x << " " << y << " " << z << endl;
            return;
        }
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void){
  int N,r,q;

  scanf("%d",&N);
  int a[N];
  for(int i=0;i<N;i++)
    a[i]=0;
  for(int i = 0; i< N-1; i++){
    scanf("%d",&r);
//    printf("%d/",r);
    q = a[r-1];
    q++;
    a[r-1] = q;
  }
  for(int i=0;i<N;i++)
    printf("%d\n",a[i]);
 
  return 0;
  
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,M,z=0;
	cin>>N>>M;
	vector<int> A(M);
	for(int i=0;i<M;i++)
	cin>>A[i];
	for(int j=0;j<M;j++)
	z+=A[j];
	if  (z>=N)
	cout<<"Yes\n";
	else cout<<"No\n";
	
	
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,sum,sub;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op=='+'){
         sum= a+b;
	printf("%d", sum);
}
	else if(op=='-'){
        sub= a-b;
	printf("%d", sub);
}
	
	return 0;
}

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


vector<vector<long long>> edges;
vector<long long> udistance;
vector<long long> vdistance;

void udfs(long long u){
    for(long long to:edges[u]){
        if(udistance[to] == -1){
            udistance[to] = udistance[u] + 1;
            udfs(to);
        }
    }
}

void vdfs(long long v){
    for(long long to:edges[v]){
        if(vdistance[to] == -1){
            vdistance[to] = vdistance[v] + 1;
            cerr <<"to=" << to <<"distance=" <<vdistance[to] << endl;
            vdfs(to);
        }
    }
}


void solve(long long N, long long u, long long v){
    udistance[u] =0;
    vdistance[v] = 0;
    udfs(u);
    vdfs(v);

    long long maxv = 0;
    for(long long i=0; i<N;i++){
        if(udistance[i] <vdistance[i]){
            maxv = max(vdistance[i],maxv);
        }
    }
    cout << maxv-1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long u;
    scanf("%lld",&u);
    long long v;
    scanf("%lld",&v);
    edges.resize(N);
    udistance.resize(N,-1);
    vdistance.resize(N,-1);
    std::vector<long long> A(N-1);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--;
        B[i]--;
        edges[A[i]].push_back(B[i]);
        edges[B[i]].push_back(A[i]);
    }
    solve(N, u-1, v-1);
    return 0;
}


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

int a[550][550];
int h, w;
vector<pair<int, int>> v;

int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w - 1; j++)
        {
            if (a[i][j] % 2 == 1)
            {
                a[i][j + 1]++;
                pair<int, int> p = make_pair(i + 1, j + 1), q = make_pair(i + 1, j + 2);
                v.push_back(p);
                v.push_back(q);
            }
        }
    }
    for (int i = 0; i < h - 1; i++)
    {
        if (a[i][w - 1] % 2 == 1)
        {
            a[i + 1][w - 1]++;
            pair<int, int> p = make_pair(i + 1, w), q = make_pair(i + 2, w);
            v.push_back(p);
            v.push_back(q);
        }
    }
    cout << v.size() / 2 << endl;
    for (int i = 0; i < v.size(); i++)
    {
        int a = v[i].first, b = v[i].second;
        if (i % 2 == 0)
            cout << a << " " << b << " ";
        else
            cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	vector<int> a { 201 } ;
	for (auto x : A) {
		if (x != a.back()) a.push_back(x);
	}
	a.push_back(-1);
	vector<int> b;
	for (unsigned i = 1; i+1 < a.size(); ++ i) {
		if (a[i-1] > a[i] && a[i] < a[i+1]) {
			b.push_back(a[i]);
		}
		if (a[i-1] < a[i] && a[i] > a[i+1]) {
			b.push_back(a[i]);
		}
	}
	ll s = 1000;
	for (unsigned i = 1; i < b.size(); i += 2) {
		ll n = s / b[i-1];
		s += n * (b[i] - b[i-1]);
	}
	cout << s << endl;
}


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

struct wawa{
    char a;
    int yoko,tate;
};
wawa s[2005][2005];

int main()
{
    int mini = 0;
    int h, w;
    cin >> h >> w;
    for(int i = 0; i <= h + 1; i++) {
        for(int j = 0; j <= w + 1; j++) {
            if(i == 0 || i == h + 1 || j == 0 || j == w + 1) s[i][j].a = '#';
            else cin >> s[i][j].a;
        }
    }
    for(int i = 0; i <= h + 1; i++) {
        for(int j = 0; j <= w + 1; j++) {
            if(s[i][j].a == '#') {
                s[i][j].yoko = 0;
                s[i][j].tate = 0;
            }else{
                if(s[i - 1][j].a == '#'){
                    int k = 0;
                    while(s[i + k][j].a == '.'){
                        k++;
                    }
                    s[i][j].yoko = k;
                }else s[i][j].yoko = s[i- 1][j].yoko;
                
                if(s[i][j - 1].a == '#'){
                    int k = 0;
                    while(s[i][j + k].a == '.'){
                        k++;
                    }
                    s[i][j].tate = k;
                }else s[i][j].tate = s[i][j - 1].tate;
            }
            mini = max(mini, s[i][j].yoko + s[i][j].tate - 1);
        }
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 47360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int s = sc.nextInt();
			if (n == 0) {
				break;
			}
			int ans = 0;
			for(int i=1;i<1<<n;i++) {
				if (Integer.bitCount(i) != k) {
					continue;
				}
				int sum = 0;
				for(int j=0;j<n;j++) {
					if ((i&1<<j)>0) {
						sum += j + 1;
					}
				}
				if (sum == s) {
					ans++;
				}
			}
			System.out.println(ans);
		}
	}

}

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

#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int n;cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n){
        int tmp;cin >> tmp;
        v[i] -= tmp;
    }
    sort(v.begin(),v.end(),std::greater<int>());
    int ans = 0;
    rep(i,n){
        if(v[i]>0){
            ans += v[i];
        }else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    MOD = 10**9 + 7

    N = int(input())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [0] * (1<<N)
    dp[0] = 1
    for S in range(1, 1<<N):
        iM = bin(S).count('1') - 1
        for iW in range(N):
            if S & (1<<iW) and Ass[iM][iW]:
                S0 = S ^ (1<<iW)
                dp[S] += dp[S0]
        dp[S] %= MOD

    print(dp[-1])


solve()


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n;
    cin >> n;
    if(n%2==0) cout << n/2 << endl;
    else cout << n/2+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int k, a, b; cin >> k >> a >> b;
	for( int i = 1; i <= 2000; ++i ){
		if( a <= k*i and k*i <= b ){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

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

using namespace std;

#define FOR(i, a) for(int i = 0; i < (int) a; i++)
#define all(v) v.begin(), v.end()
#define f first
#define s second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;



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

	int h, n; cin >> h >> n;
	ll sum = 0;
	FOR(i, n){
		int x; cin >> x;
		sum += x;
	}

	if(sum >= h) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

int main() {
  ll N, M;
  bool nonumber = 0;
  cin >> N >> M;
  vector<ll> s(M), c(M), number(N, 0);
  for(ll i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
    number.at(s.at(i) - 1) = c.at(i);
    for(ll j = 0; j < i; j++){
      if((s.at(i) == s.at(j)) && (c.at(i) != c.at(j))) nonumber = 1;
    }
    if((s.at(i) == 1) && (c.at(i) == 0) && (N != 1)) nonumber = 1;
  }
  if(nonumber == 1) cout << -1 << endl;
  else {
    for(ll i = 0; i < N; i++) {
      if((i == 0) && (number.at(i) == 0) && (N != 1)) cout << 1;
      else cout << number.at(i);
    }
  }
}


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

using namespace std;

#define ll long long int
#define ld long double
#define pii pair<int,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define bit(a,b) ((a>>b)&1)
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const ll mx = 2e5+1, Mod = 1e9+7;

int n, p[mx];
int loc[mx];
int dp[mx];

int main()
{
    IOS;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> p[i], loc[p[i]] = i;
    dp[1] = 1;
    int ans = 1;
    for(int i=2;i<=n;i++)
    {
        dp[i] = 1;
        if(p[i] > 1 && loc[p[i]-1] < loc[p[i]])
            dp[i] += dp[loc[p[i]-1]];
        ans = max(ans, dp[i]);
    }
    cout << n - ans << '\n';
    return 0;
}












Measured memory_bytes: 2688
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0114/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aojxxxx/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;sc.hasNext();) {
			long v[] = new long[3];
			for (int i = 0; i < 3; i++) {
				int a = sc.nextInt();
				int m = sc.nextInt();
				if (a == 0)
					return;
				v[i] = move(a, m);
			}
			long ans = lcm(v[0], lcm(v[1], v[2]));
			System.out.println(ans);
		}
	}
	
	long move(long a, long m) {
		long x = 1;
		int cnt = 0;
		do {
			cnt++;
			x = (x * a) % m;
		} while (x != 1);
		return cnt;
	}
	
	long gcd(long a, long b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}
	long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

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

using namespace std;

const int N=101;
const long long inf=1000000007;

int n;
vector<int>g[4][4][4];
int f[N][4][4][4];

bool check(vector<int> v)
{
	for(int i=0;i<2;++i)
	{
		if(v[i]==0&&v[i+1]==2&&v[i+2]==1)return false;
	}
	for(int j=0;j<3;++j)
	{
		swap(v[j],v[j+1]);
		for(int i=0;i<2;++i)
		{
			if(v[i]==0&&v[i+1]==2&&v[i+2]==1)return false;
		}
		swap(v[j],v[j+1]);
	}
	return true;
}

void init()
{
	for(int x=0;x<4;++x)
	{
		for(int y=0;y<4;++y)
		{
			for(int z=0;z<4;++z)
			{
				for(int c=0;c<4;++c)
				{
					vector<int>v;
					v.push_back(x);
					v.push_back(y);
					v.push_back(z);
					v.push_back(c);
					if(check(v))g[x][y][z].push_back(c);
				}
			}
		}
	}
}

int main()
{
	cin>>n;
	init();
	for(int i=0;i<4;++i)for(int j=0;j<4;++j)for(int k=0;k<4;++k)f[3][i][j][k]=1;
	f[3][0][2][1]=f[3][2][0][1]=f[3][0][1][2]=0;
	for(int num=3;num<n;++num)
	{
		for(int i=0;i<4;++i)
		{
			for(int j=0;j<4;++j)
			{
				for(int k=0;k<4;++k)
				{
					for(int s=0;s<g[i][j][k].size();++s)
					{
						int c=g[i][j][k][s];
						f[num+1][j][k][c]=(f[num][i][j][k]+f[num+1][j][k][c])%inf;
					}
				}
			}
		}
	}
	int ret=0;
	for(int i=0;i<4;++i)
	{
		for(int j=0;j<4;++j)
		{
			for(int k=0;k<4;++k)
			{
				ret=(ret+f[n][i][j][k])%inf;
			}
		}
	}
	cout<<ret;
}


Measured memory_bytes: 3592
S=input()
l=len(S)
cnt=(l+1)//2
n=l-cnt
b=S[l//2]
if l%2==0:
    for i in range(n):
        if S[l//2-i-1]!=b or S[l//2+i]!=b:
            break
        cnt+=1
else:
    for i in range(n):
        if S[l//2-i-1]!=b or S[l//2+i+1]!=b:
            break
        cnt+=1
print(cnt)

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

int main(){
    int A,B;
    cin>>A>>B;
    
    int a=ceil(A/0.08);
    int b=ceil(B/0.1);

    int x=a>b?a:b;

    if(floor((A+1)/0.08)<=ceil(B/0.1) ||
        floor((B+1)/0.1)<=ceil(A/0.08))
        x=-1;
    cout<<x;
}


Measured memory_bytes: 256
H,W=map(int,input().split());S=[input()for _ in[0]*H];print('\n'.join(''.join([str(sum(s[max(0,w-1):min(W,w+2)].count('#')for s in S[max(0,h-1):min(H,h+2)])),'#'][S[h][w]=='#']for w in range(W))for h in range(H)))

Measured memory_bytes: 3064
#include <iostream>
#include<ctype.h>
#include<stdio.h>
using namespace std;

int main() {

	char ch[2000];
	scanf("%[^\n]", ch);
	for (int i = 0; ch[i] != '\0'; i++) {
		char c = ch[i];
		if ('a' <= c && c <= 'z') {
			printf("%c", toupper(c));
		}
		else if ('A' <= c && c <= 'Z') {
			printf("%c", tolower(c));
		}
		else {
			printf("%c",c);
		}
	}printf("\n");
		return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    string S,T;
    cin >> S;
    T=S;
    reverse(T.begin(),T.end());
    int Ans=0;
    REP(i,(S.size()/2)){
        if(S[i]!=T[i]){
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}



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

int sp[2][2010][2010];
int k;

int query(int x1, int y1, int x2, int y2, int c)
{
    if (x2 < 2 * k && y2 < 2 * k) {
        return sp[c][x2 + 1][y2 + 1] - sp[c][x2 + 1][y1] - sp[c][x1][y2 + 1] + sp[c][x1][y1];
    }
    if (x2 >= 2 * k) {
        return query(x1, y1, 2 * k - 1, y2, c) +
        query(0, y1, x2 % (2 * k), y2, c);
    }
    if (y2 >= 2 * k) {
        return query(x1, y1, x2, 2 * k - 1, c) +
        query(x1, 0, x2, y2 % (2 * k), c);
    }
}

int main()
{
    int xlast(0), ylast(0), tlast(0);
    int n, a, b;
    char c;
    cin >> n >> k;

    while (n--) {
        cin >> a >> b >> c;
        sp[c == 'W'][a % (2 * k) + 1][b % (2 * k) + 1]++;
    }

    for (int i(1); i <= 2 * k; i++)
        for (int j(1); j <= 2 * k; j++)
            for (int q(0); q <= 1; q++)
                sp[q][i][j] += sp[q][i - 1][j] + sp[q][i][j - 1] - sp[q][i - 1][j - 1];

    int best(0);

    for (int i(0); i < 2 * k; i++) {
        for (int j(0); j < 2 * k; j++) {
            /// white square starst at (i, j)
            int ans = query(i, j, i + k - 1, j + k - 1, 1);
            ans +=  query((i + k) % (2 * k), (j + k) % (2 * k), (i + k) % (2 * k) + k - 1, (j + k) % (2 * k) + k - 1, 1);
            ans += query(i, (j + k) % (2 * k), i + k - 1, (j + k) % (2 * k) + k - 1, 0);
            ans += query((i + k) % (2 * k), j, (i + k) % (2 * k) + k - 1, j + k - 1, 0);
            best = max(best, ans);
        }
    }

    cout << best;
    return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
 
std::vector<long long> A;
long long N, M, result = 0;
 
// check if there are less than M pairs less than {target}
bool check(long long target) {
  long long cnt = 0;
  for (const auto & e : A) {
    long long pos = std::lower_bound(A.begin(), A.end(), target - e) - A.begin();
    cnt += (N - pos);
  }
  return cnt < M;
}
 
int main() {
  std::cin >> N >> M;
  A.resize(N);
  for (auto i=0; i<N; ++i) std::cin >> A[i];
  
  std::sort(A.begin(), A.end());
  
  long long ok = std::numeric_limits<long long>::max();
  long long ng = 0;
  while (std::abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  
  std::vector<long long> accsum(N+1, 0);
  
  for (auto i=0; i<N; ++i)  accsum[i+1] = A[i] + accsum[i];
  
  for (const auto & e : A) {
    long long pos = std::upper_bound(A.begin(), A.end(), ng - e) - A.begin();
    long long cnt = N - pos;
    result += cnt * e + (accsum[N] - accsum[pos]);
    M -= cnt;
  }
  result += M * ng;
  std::cout << result << "\n";
}

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [usize1; n]
    }
    let mut ans = 0;
    let mut cum = 0;
    let mut cumv = vec![0];
    let mut map: HashMap<usize, usize> = HashMap::new();
    map.insert(0, 1);
    for i in 0..min(k - 1, n) {
        cum = (cum + v[i]) % k;
        cumv.push(cum);
        let x = map.entry(cum).or_insert(0);
        ans += *x;
        *x += 1;
    }
    for i in k - 1..n {
        cumv.push((cum + v[i]) % k);
        *map.get_mut(&cumv[i + 1 - k]).unwrap() -= 1;
        cum = (cum + v[i]) % k;
        let x = map.entry(cum).or_insert(0);
        ans += *x;
        *x += 1;
    }
    println!("{}", ans);
}


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

int main(){
    int n;
    cin >> n;
    vector<int> r(n);
    for(int i = 0; i < n; i++){
        cin >> r.at(i);
    }
    vector<int> c(9);
    for(int i = 0; i < n; i++){
        if(r.at(i) <= 3199){
            c.at(r.at(i)/400) = c.at(r.at(i)/400)+1;
        } else {
            c.at(8) = c.at(8)+1;
        }
    }
    int count = 0;
    for(int i = 0; i < 8; i++){
        if(c.at(i) >= 1){
            count++;
        }
    }
    int min = 0;
    if(count == 0 && c.at(8) >= 1){
        min = 1;
    } else {
        min = count;
    }
    cout << min << " " << count+c.at(8);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int n, t;
std::vector<std::pair<int, int>> vec;

int main() {
    std::cin >> n;
    int half = n/2;
    int ans;
    std::vector<std::pair<int, int>> zero_origin(100000+1, std::pair<int, int>(0, 0));
    std::vector<std::pair<int, int>> one_origin(100000+1, std::pair<int, int>(0, 0));
    std::vector<std::pair<int, int>> vec(100000+1, std::pair<int, int>(0, 0));
    for (int i = 1; i <= n; i++) {
        std::cin >> t;
        if (i % 2 == 0) {
            zero_origin[t].first++;
            zero_origin[t].second = t;
        }
        else if (i % 2 != 0) {
            one_origin[t].first++;
            one_origin[t].second = t;
        }
        vec[t].first++;
        vec[t].second = t;
    }
    int vec_max = std::max_element(vec.begin(), vec.end())->first;
    if (vec_max == n) {
        std::cout << static_cast<int>(vec_max / 2) << std::endl;
        return 0;
    }
    std::sort(zero_origin.begin(), zero_origin.end());
    std::sort(one_origin.begin(), one_origin.end());
    auto zero_vec = zero_origin[zero_origin.size() - 1];
    auto one_vec = one_origin[one_origin.size() - 1];
    if (zero_vec.second != one_vec.second) {
        ans = (half - zero_vec.first) + (half - one_vec.first);
        std::cout << ans << std::endl;
        return 0;
    }
    else {
        int zero_index = zero_origin.size() - 1;
        int one_index = one_origin.size() - 1;
        while (one_origin[one_index].second == zero_origin[zero_index].second) {
            int u = (half - one_origin[one_index].first) + (half - zero_origin[zero_index-1].first);
            int w = (half - one_origin[one_index-1].first) + (half - zero_origin[zero_index].first);
            if (u < w) {
                zero_index--;
            }
            else {
                one_index--;
            }
        }
        std::cout << (half - one_origin[one_index].first) + (half - zero_origin[zero_index].first) << std::endl;
    }
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    char s[11000];
    cin >> s;
    int l = strlen(s);
    for(int i = l - 2; i > 0; i-=2){
        if(strncmp(s, s + i/2, i/2) == 0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);

	int ans = min(N * A, B);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
const int N=1e5+10;

int main(){
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> dp(n,(int)1e9);
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
    dp[i]=min({dp[i],dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])});
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#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;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
int fact(int n){
  int m;
  if (n == 0)
      return 1;
  m = fact(n - 1);    
  return n * m;       
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint h(n+100);
  REP(i,1,n+1){
      cin>>h[i];
  }
  vector<vector<int> >dp(n+100,vector<int>(3));
  dp[1][1]=0;
  dp[1][2]=0;
  dp[2][1]=abs(h[1]-h[2]);
  dp[2][2]=9999999;
  REP(i,3,n+1){
      REP(j,1,3){
	  dp[i][j]=min((dp[i-j][1]+abs(h[i]-h[i-j])),dp[i-j][2]+abs(h[i]-h[i-j]));
	  
      }
      
  }
  cout<<min(dp[n][1],dp[n][2])<<'\n';
  
  return(0);
}


Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	string S;
	cin >> S;
	int pos = 0;
	int prev = -1;
	bool OK = 1;
	while (pos < S.size()) {
		if (pos + 5 <= S.size() && S.substr(pos, 5) == "dream") {
			pos += 5;
			prev = 0;
		}
		else if (pos + 5 <= S.size() && S.substr(pos, 5) == "erase") {
			pos += 5;
			prev = 2;
		}
		else if (pos + 2 <= S.size() && S.substr(pos, 2) == "er") {
			if (prev != 0) {
				OK = 0;
				break;
			}
			pos += 2;
			prev = 1;
		}
		else if (S[pos] == 'r') {
			if (prev != 2) {
				OK = 0;
				break;
			}
			pos++;
			prev = 3;
		}
		else {
			OK = 0;
			break;
		}
	}
	if (OK) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
#define FAST_IO std::ios::sync_with_stdio(false);std::cin.tie(0);  

struct st
{
  int num, id;
  st(int a, int b) : num(a), id(b) { }
  st() {  }
};


int main(int argc, char** argv) { FAST_IO
  int n; cin >> n;
  vector<st> v(n);
  for (int i = 1; i <= n; ++i) {
    int num; cin >> num; v[i-1] = st(num, i);
  }
  sort(v.begin(), v.end(), [&](st a, st b) {
    return a.num < b.num;
  });
  for (auto& x : v) cout << x.id << " ";


  return 0; 
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main() {
  string s;cin>>s;
  int n=s.size();
  vector<long long>a(n+1);
  REP(i,n)if(s[i]=='<')a[i+1]=a[i]+1;
  REP(i,n)if(s[n-i-1]=='>')a[n-i-1]=max(a[n-i-1],a[n-i]+1);
  cout<<accumulate(a.begin(),a.end(),0LL)<<endl;
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

const int mod=1e9+7;

int main(){
	int n;
	cin>>n;
	int a=n/1000*10+n/100%10;
	int b=n%100;

	

	if(a>=1&&a<=12&&b>=1&&b<=12){
		cout<<"AMBIGUOUS"<<endl;
	}else if(a>=1&&a<=12&&(b>=13||b==0)){
		cout<<"MMYY"<<endl;
	}else if(b>=1&&b<=12&&(a>=13||a==0)){
		cout<<"YYMM"<<endl;
	}else{
		cout<<"NA"<<endl;
	}

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int func(int n) {
    if (n < 10) return n;
    return func(n / 10) + n % 10;
}
int main() {
    int n; cin >> n;
    
    if (n % func(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = list(map(int,input().split()))

chofuku_dict = {}
chofuku = []

for a in A:
    if a not in chofuku_dict:
        chofuku_dict[a] = 1
    else:
        chofuku.append(a)
        
chofuku = set(chofuku)

A = list(set(A))
A.sort()

bl = np.array([0] + [1]*A[-1])

ans = 0
for a in A:
    if bl[a] == 0:
        continue
    if a not in chofuku:
        ans += 1
    bl[2*a::a] = 0
print(ans)

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

using namespace std;

const int M = 2e5 + 10;
int n;
long long arr[M];

int main() {
#ifndef ONLINE_JUDGE
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    string a, b;
    cin >> a >> b;
    int len = a.length(), ans = 0;
    for (int i = 0; i < len; i++) {
        if (a[i] != b[i]) {
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[100009];
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3652
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    var h, a = sc.nextInt


    var count = 0
    while(h > 0) {
      count += 1
      h -= a
    }
    println(count)
  }
}


Measured memory_bytes: 27284
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

N, M = input_li()
A_LI = []
B_LI = []
for _ in range(N):
    A_LI.append(input())
for _ in range(M):
    B_LI.append(input())
for i in range(N - M + 1):
    for j in range(N - M + 1):
        is_ok = True
        for col in range(M):
            for row in range(M):
                if B_LI[col][row] != A_LI[i + col][j + row]:
                    is_ok = False
                    break
            if not is_ok:
                break
        if is_ok:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 63720
#include<bits/stdc++.h>
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const long long INF=0x7FFFFFFFFFFFFFFFLL;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
char s[15];
 
int main()
{ 
    int i,j,len,x;
    ll temp,sum=0;
    scanf("%s",s);
    len=strlen(s);
    x=1<<(len-1);
    for(i=0;i<x;i++)
    {
        temp=s[0]-'0';
        for(j=0;j<len;j++)
        {
            if(j==len-1 || i&(1<<j))
            {
                sum=sum+temp;
                temp=0;
                if(j==len-1)
                    break;
            }
            temp=temp*10+(s[j+1]-'0');
        }
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static final int MAX = 999999;
	static int[] p = new int[MAX + 1];

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Arrays.fill(p, 0);
		while (scanner.hasNext()) {
			int n = scanner.nextInt();
			int cnt = 0;
			for(int i = 2; i <= n; i++) {
				if(isPrime(i)) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}

	private static boolean isPrime(int i) {
		if(p[i] == 0) {
			double root = Math.sqrt(i);
			for(int j = 2; j <= root; j++) {
				if(i % j == 0) {
					p[i] = 2;
					return false;
				}
			}
			p[i] = 1;
			return true;
		}
		if (p[i] == 1) {
			return true;
		}
		return false;
	}


}



Measured memory_bytes: 30688
#include <stdio.h>

int main() {

	int N, K;

	scanf("%d %d",&N,&K);

	int i;

	int ans = 0;

	for (i = 0; i < N; i++) {
		int h;
		scanf(" %d",&h);
		if (h >= K) { ans++; }
	}
	printf("%d\n",ans);

	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define vii vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pdd pair<double,double>
#define pldld pair<long long double, long long double>
#define ff first
#define ss second
#define pb push_back
#define read freopen("alu.txt","r",stdin);
#define write freopen("vorta.txt","w",stdout);
#define fastio ios::sync_with_stdio(false); cin.tie(NULL);
#define PI 2*acos(0.0)
#define DEBUG(x) cerr << #x << " = " << x << endl
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

const int MAX = 2e6 + 5, MOD = 1e9 + 7  , MAXLG = log2(MAX)+1;
const ll inf = 1e18 + 5;

int arr[MAX];
ll dp[2][3005];
ll sum[2][3005];
int dir[3005];

int main(){

    fastio;
    int n;
    string s;
    cin>>n>>s;

    s = '#' + s;
    s.pb('<');

    sum[1][0] = 1;
    int cur = 0;
    for(int baki = 1; baki <= n; baki++){
        if(s[baki] == '<') dp[cur][0] = 0;
        else dp[cur][0] = sum[cur ^ 1][baki - 1];

        for(int small = 1; small <= baki; small++){
            if(s[baki] == '<') dp[cur][small] = sum[cur ^ 1][small - 1];
            else{
                int big = baki - small;
                dp[cur][small] = sum[cur ^ 1][small + big - 1];
                dp[cur][small] -= sum[cur ^ 1][small - 1];
                if(dp[cur][small] < 0) dp[cur][small] += MOD;
            }
        }

        sum[cur][0] = dp[cur][0];
        for(int small = 1; small <= baki; small++){
            sum[cur][small] = (sum[cur][small - 1] + dp[cur][small]);
            if(sum[cur][small] >= MOD) sum[cur][small] -= MOD;
        }
        cur ^= 1;
    }

    ll ans = dp[cur ^ 1][n];
    cout<<ans<<"\n";

}


Measured memory_bytes: 384
N, M = map(int, input().split())
A = []
for _ in range(N):
    Ai = tuple(input())
    A.append(Ai)
A = tuple(A)
B = []
for _ in range(M):
    Bi = tuple(input())
    B.append(Bi)
B = tuple(B)


for i in range(N - M + 1):
    for j in range(N - M + 1):
        contain = True
        for k in range(M):
            if not contain:
                break
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    contain = False
                    break
        if contain:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 9236
#include <iostream>
#include <string.h>
using namespace std;

int main () {
  int ans = 0;
  string s;
  cin >> s;
  ans = s.size() / 2;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'p') {
      ans--;  
    }  
  }  
  cout << ans << endl;
}

Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int k = Integer.parseInt(strArr[2]);
		for (int i = 0; i < k; i++) {
			if (i % 2 == 0) {
				b += a / 2;
				a = a / 2;
			} else {
				a += b / 2;
				b = b / 2;
			}
		}
		System.out.println(a + " " + b);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

using namespace std;
typedef priority_queue<int, vector<int>, greater<int> > pq;
typedef long long ll;
int n,m;
int a[100005];
int par[100005];
int Rank[100005];
pq g[100005];
void init(int n) {
  for(int i = 0; i < n; i++) {
    par[i] = i;
    Rank[i] = 0;
  }
}

int find(int x) {
  return x == par[x] ? x : par[x] = find(par[x]);
}

void Union(int x, int y) {
  int a = find(x);
  int b = find(y);
  if(a == b) return;

   if(Rank[a] > Rank[b]) {
    par[b] = a;
  }
   else {
     par[a] = b;
     if(Rank[a] == Rank[b]) Rank[b]++;
   }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  cin >> n >> m;
  int group = n;
  init(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) {
    int x,y;
    cin >> x >> y;
    if(find(x) != find(y)) {
      Union(x,y);
      group--;
    }
  }
  /*  for(int i = 0; i < n; i++) {
    cout << par[i] << endl;
    }*/
  
  if(group == 1) {
    cout << "0" << endl;
    return 0;
  }

  ll ans = 0;
  for(int i = 0; i < n; i++) g[find(i)].push(a[i]);
  pq rest;

  for(int i = 0; i < n; i++) {
  
    if(find(i) == i) {
      ans += g[i].top(); g[i].pop();
    }
    while(!g[i].empty()) {
      rest.push(g[i].top());
      //  cout << g[i].top() << endl;
      g[i].pop();
      
    }
  }
  int ne = (group - 1) * 2 - group;

  while(ne > 0) {
    if(rest.empty()) {
      cout << "Impossible" << endl;
      return 0;
    }
    ans += rest.top();
    rest.pop();
    ne--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 7680
#include <iostream>
#include <utility>

using namespace std;

int main()
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  int maxX = X;
  int minY = Y;
  
  for (int n=0; n<N; ++n) {
    int x;
    cin >> x;
    maxX = max(x,maxX);
  }

  for (int m=0; m<M; ++m) {
    int y;
    cin >> y;
    minY = min(y,minY);
  }

  cerr << maxX << ' ' << minY << endl;

  cout << (maxX<minY ? "No " : "") << "War" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string h;
	cin >> h;
	unsigned long long ans = h.length();
	for (unsigned long long i = 0; i < h.length() - 1; ++i) {
		if (h[i] != h[i + 1]) {
			ans = min(ans, max(i + 1, h.length() - i - 1));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
S = input()
S = S[::-1]
a = 'dream'[::-1]
b = 'dreamer'[::-1]
c = 'erase'[::-1]
d = 'eraser'[::-1]
words = [a, b, c, d]
t = 0
for i in range(1, len(S) + 1):
    if S[t:i] in words:
        t = i
if t == len(S):
    print('YES')
else:
    print('NO')


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


void solve(long long X, long long Y, long long Z, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    vector<ll> v;
    for(int i = 0;i < X;i++){
        for(int j = 0;j < Y;j++){
            v.push_back(A[i] + B[j]);
        }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(int i = 0;i < min(K, (ll)v.size());i++){
        for(int j = 0;j < Z;j++){
            que.push(v[i] + C[j]);
            if(que.size() > K)que.pop();
        }
    }
    vector<ll> ans;
    for(int i = 0;i < K;i++){
        ll q = que.top();
        ans.push_back(q);
        que.pop();
    }
    reverse(ans.begin(), ans.end());
    for(int i = 0;i < K;i++){
        cout<<ans[i]<<endl;
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(X);
    for(int i = 0 ; i < X ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(Y);
    for(int i = 0 ; i < Y ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(Z);
    for(int i = 0 ; i < Z ; i++){
        scanf("%lld",&C[i]);
    }
    solve(X, Y, Z, K, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 10608