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

bottom_left = [0, 0]
top_right = [W, H]

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and bottom_left[0] < x:
        bottom_left[0] = x
    elif a == 2 and top_right[0] > x:
        top_right[0] = x
    elif a == 3 and bottom_left[1] <  y:
        bottom_left[1] = y
    elif a == 4 and top_right[1] > y:
        top_right[1] = y

if top_right[0] > bottom_left[0] and top_right[1] > bottom_left[1]:
    area = (top_right[0] - bottom_left[0]) * (top_right[1] - bottom_left[1])
else:
    area = 0

print(area)


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		switch(n%10) {
			case 2:
			case 4:
			case 5:
			case 7:
			case 9:
				System.out.println("hon"); break;
			case 0:
			case 1:
			case 6:
			case 8:
				System.out.println("pon"); break;
			case 3:
				System.out.println("bon"); break;
		}
	}
}



Measured memory_bytes: 35688
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $v=[];
  for($i=0;$i<strlen($s);$i++){
    if(isset($v[$s[$i]])) {
      echo "no".PHP_EOL;
      exit;
    }
    $v[$s[$i]]=true;
  }
  echo "yes".PHP_EOL;

Measured memory_bytes: 16096
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] b = na(n-1);
		int result = 0;
		result += b[0];
		result += b[n - 2];
		for(int i = 1; i < n - 1; i++) {
			result += Math.min(b[i - 1], b[i]);
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 24788
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(); int b = sc.nextInt(); int x = sc.nextInt();
    if (a <= x && x <= a + b) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if(A>9 or B>9){
    cout<<-1<<endl;
    return 0;
  }
  cout<<A*B<<endl;
  return 0;
}


Measured memory_bytes: 256
from math import pi, sin, cos, tan, sqrt, radians
a, b, h, m = map(int, input().split())

angle_a = -2 * pi * (h / 12) + (-2*pi*(1/12) * (m/60)) + radians(90)
angle_b = -2 * pi * (m / 60) + radians(90)

ax, ay = a * cos(angle_a), a * sin(angle_a)
bx, by = b * cos(angle_b), b * sin(angle_b)
print(sqrt(pow(ax-bx, 2)+pow(ay-by, 2)))


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

int main(){
  string s;
  cin>>s;
  int l=0;
  int ans=0;
  int r=s.size()-1;
  while(r-l>0){
	if(s[l]==s[r]) {
		l++;
		r--;
	}
	else if(s[l]=='x') {
		l++;
		ans++;
	}
	else if(s[r]=='x') {
		r--;
		ans++;
	}
	else {
		cout<<-1<<endl;
		return 0;
	}
  }	
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 512
#include<stdio.h>
#define	MM	2000000000
int data[2][5001][2];

int main(void)
{
	int n,t[10001];
	int i,j,k,ii,ii2;
	
	scanf("%d",&n);
	for(i=1;i<n;i++)	{
		scanf("%d",&t[i]);
	}
	for(j=0;j<=n/2;j++)	{
		data[1][j][0]=MM;
		data[1][j][1]=MM;
	}
	data[1][0][0]=0;
	data[1][1][1]=0;
	for(i=1;i<n;i++)	{
		ii=i%2;
		ii2=(ii+1)%2;
		for(j=0;j<=n/2 ;j++)	{
			data[ii2][j][0]=MM;
			data[ii2][j][1]=MM;
		}
		for(j=0;j<=n/2;j++)	{
			if(data[ii2][j][0]>data[ii][j][0])
				data[ii2][j][0]=data[ii][j][0];
			if(j<n/2 && data[ii2][j+1][1]>data[ii][j][1])
				data[ii2][j+1][1]=data[ii][j][1];
			if(data[ii2][j][0]>data[ii][j][1]+t[i])	
				data[ii2][j][0]=data[ii][j][1]+t[i];
			if(j<n/2 && data[ii2][j+1][1]>data[ii][j][0]+t[i])
				data[ii2][j+1][1]=data[ii2][j][0]+t[i];
		}
/*		for(j=0;j<=n/2;j++)	{
			printf("%9d ",data[ii2][j][0]);
		}
		printf("\n");
		for(j=0;j<=n/2;j++)	{
			printf("%9d ",data[ii2][j][1]);
		}
		printf("\n");	
*/	}
	printf("%d\n",data[0][n/2][1]);
	return 0;
}


Measured memory_bytes: 712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	long N;
	cin >> N;
	long long  A[N], b;
	long long sb = 0;

	for(long i = 0; i<N; i++){
		cin >> A[i];
	}

	for(long i = 0; i<N; i++){
		cin >> b;
		A[i] -= b;
	}

	sort(A, A+N);

	long long d = 0;
	long ans = 0;
	long j = N -1;
	for(long i = 0; i < N; i++){
		if(A[i] >= 0) break;
		while(-A[i] > d){
			if(A[j] <= 0) break;
			d+= A[j--];
			ans++;
		}
		d += A[i];
		ans++;
	}

	if(d >= 0){
		cout << ans << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
#define MAXN   1000005
int spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
int main()
{
	fast;ll t1;t1=1;
	while(t1--)
	{
		sieve();
		int n,i,a,j,b,ans;
		cin>>n;
		ans=0;
		for(i=1;i<=n;i++){
			a=n-i;
			if(a<1){continue;}
			b=sqrt(a);
			if(a==1){ans++;continue;}
			//cout<<a<<" ";
			vector<int>v=getFactorization(a);
			sort(v.begin(),v.end());
			int p=1;int s=1;
			if(v.size()==0){continue;}
			for(j=1;j<v.size();j++)
			{
				if(v[j]==v[j-1]){p++;}
				else{
					s*=(p+1);
					p=1;
				}
			}
			s*=(p+1);
			ans+=s;
			
		}
		cout<<ans<<"\n";
	}
}


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

int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

char t[]={'<','^','>','v'};

char f[101][101];
bool v[100][100];
int X,Y;

bool dfs()
{
	if(v[X][Y]) return false;
	v[X][Y]=1;
	if(f[X][Y]=='.') return true;
	
	for(int i=0; i<4; i++)
	{
		if(t[i]==f[X][Y]) 
		{
			X+=dx[i];
			Y+=dy[i];
		}
	}
	return dfs();
}

int main()
{
	int H,W;
	while(cin >> H >> W, (H||W))
	{
		memset(v,0,sizeof(v));
		for(int i=0; i<H; i++)
		for(int j=0; j<W; j++)
			cin >> f[j][i];
			
		X=0; Y=0;
		
		bool f=dfs();
		if(f) cout << X << " " << Y << endl;
		else cout << "LOOP" << endl;
		
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=150;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	cout<<24+(24-N)<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;
  for(int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];
  int i;
  for(i = 1; i <= n; i++){
    int time = t[i] - t[i - 1];
    int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if(dis <= time && (time - dis) % 2 == 0);
    else break;
  }
  if(i == n + 1) cout << "Yes\n";
  else cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


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


int main() {
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.size();i++) {
    sum=(sum+s[i]-'0')%9;
  }
  if(sum==0) {
    cout<<"Yes";
  }else {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll T = 1LL, A = 1LL;
  REP(i, N)
  {
    ll t, a;
    cin >> t >> a;
    if (T == t && A == a) continue;
    else if (T < t && A < a)
    {
      T = t; A = a;
    }
    else if(T >= t && A < a)
    {
      if (T * a % t == 0) A = T * a / t;
      else
      {
        T += t - (T % t);
        A = T * a / t;
      }
    }
    else if(T < t && A >= a)
    {
      if (A * t % a == 0) T = A * t / a;
      else
      {
        A += a - (A % a);
        T = A * t / a;
      }
    }
    else if (T >= t && A >= a)
    {
      if (T % t != 0) T += t - (T % t);
      if (A % a != 0) A += a - (A % a);
      ll tmpT, tmpA;
      tmpA = a * (T / t);
      tmpT = t * (A / a);
      if (tmpA < A) T = tmpT;
      else if (tmpT < T) A = tmpA;
    }
  }
  cout << T + A << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*
*/

int main() {
   int A1,A2,A3;
   cin >> A1 >> A2 >> A3;
   if(A1+A2+A3>=22) cout << "bust" << endl;
   else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl

int main(){
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin>>K;
    cout<<A[K-1]<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair


int main() {
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        int u=0,k=i;
        while(k>0)
        {
            k/=10;
            u++;
        }
        if(u%2)
            sum++;
    }
    cout<<sum;
    return 0;
}
//5 1 5 -10 -10 -10 5 7


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
  struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
  int main(){
  lint N,M;
  cin>>N>>M;
  P p[N];
  rep(i,N){
      lint a,b;cin>>a>>b;
      p[i]=make_pair(a,b);
  }
  sort(p,p+N);
  priority_queue<P> x;
  lint ans=0;
  lint j=0;
  repp(i,1,M+1){
      lint s,v;
        if(j<N)tie(s,v)=p[j];
      while(s==i&&j<N){
         tie(s,v)=p[j];
         if(i<s)break;
          x.emplace(v,s);
          j++;
      }
      if(x.size()!=0){
          P c=x.top();
          lint a,b;
          tie(a,b)=c;
          x.pop();
          ans+=a;
      } 
  }
  cout<<ans;
  }
  
  
     
  

Measured memory_bytes: 3956
#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;
}

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

    if (K % 2 != 0) {
        ll a = N / K;
        cout << a * a * a << endl;
    } else {
        ll a = N / K;
        ll b = (N - K / 2) / K;
        if (N - K / 2 >= 0) {
            b++;
        }
        cout << a * a * a + b * b * b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n;
int ans;
int a[10010];

void solve(){
	ans = n;
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= 3; j++){
			int s = i, e = i, cnt = 1, tmp = n, color = j;
			if(a[i] == j) continue;
			while(true){
				while(true){
					if(s-1 >= 0 && a[s-1] == color){
						cnt++;
						s--;
					} else break;
				}
				while(true){
					if(e+1 < n && a[e+1] == color){
						cnt++;
						e++;
					} else break;
				}
				if(cnt >= 4){
					tmp -= cnt;
					if(tmp <= 3) break;
					if(s-1 >= 0) color = a[s-1];
					else if(e+1 < n) color = a[e+1];
					cnt = 0;
				} else break;
			}
			if(ans > tmp) ans = tmp;
		}
	}
	printf("%d\n", ans);
}

int main(){
	while(scanf("%d", &n), n) solve();
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> g(H, vector<char>(W, '.'));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            g[i][j] = c;
        }
    }

    int ans = 0;
    for (int hb = 0; hb < (1 << H); ++hb) {
        bitset<6> hbs(hb);
        for (int wb = 0; wb < (1 << W); ++wb) {
            bitset<6> wbs(wb);
            string hs = hbs.to_string();
            string ws = wbs.to_string();
            reverse(hs.begin(), hs.end());
            reverse(ws.begin(), ws.end());

            vector<vector<char>> tg = g;
            for (int k = 0; k < H; k++) {
                if (hs[k] == '1') {
                    tg[k] = vector<char>(W, 'R');
                }
            }
            for (int l = 0; l < W; l++) {
                if (ws[l] == '1') {
                    for (int m = 0; m < H; m++) {
                        tg[m][l] = 'R';
                    }
                }
            }

            int bn = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (tg[i][j] == '#') bn++;
                }
            }

            if (bn == K) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
S = input()

while S:
    if S[-5:] == "dream" or S[-5:] == "erase":
        S = S[:-5]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-7:] == "dreamer":
        S = S[:-7]
    else:
        break


if S:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3188
from math import sqrt

def distance(A, B):
    s = sum((a-b)**2 for a, b in zip(A, B))
    s = sqrt(s)
    return s

def solve(N, D, X):
    c = 0
    for i in range(N):
        for j in range(i+1, N):
            d = distance(X[i], X[j])
            if float(int(d)) == d:
                c+=1
    return c

def main():
    N, D =[int(x) for x in input().split()]
    X = []
    for i in range(N):
        X.append([int(x) for x in input().split()])

    print(solve(N, D, X))

main()



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

int main() {
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if ((10 * b + c - 1) / 4 != (10 * b + c) / 4) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define M 2000001
#define N 10000

int main(){
  unsigned short *A,*B;

  int C[N+1];
  int i,j,n;
  
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=N;i++)C[i]=0;

   /* C[i] に i の出現数を記録する */
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
      }
  /* C[i] に i 以下の数の出現数を記録する*/
  for(i=1;i<=N;i++) C[i]+=C[i-1];
  
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);

  return 0;
}




Measured memory_bytes: 9632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		if (a > b) System.out.println("a > b");
		if (a < b) System.out.println("a < b");
		if (a == b) System.out.println("a == b");
	}
}

Measured memory_bytes: 26148
import java.util.Scanner;
public class Main{
public static void main (String[] args) 
 {
  Scanner sc = new Scanner(System.in);
     int a[] = new int[3];
     for(int i = 0; i < 3; i++){
         a[i]= sc.nextInt();
     }
     for (int i = 0; i < 3; i++) 
 
        {
 
            for (int j = i + 1; j < 3; j++) 
 
            {
 
                if (a[i] < a[j]) 
 
                {
 
                    int temp = a[i];
 
                    a[i] = a[j];
 
                    a[j] = temp;
 
                }
 
            }
 
        }
     int num = a[0]*10 + a[1] + a[2];
     System.out.println(num);
 }
}

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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
#define endl '\n'

int main() {
    int n, d;
    cin >> n >> d;
    int p = d * 2 + 1;
    p = ceil(float(n) / float(p));
    
    cout << p << endl;
    
    return 0;
}

Measured memory_bytes: 256
an = list(map(int, open(0).read().split()[1:]))


def f(flg):
    accum = 0
    ret = 0
    for i, ai in enumerate(an):
        accum += ai
        if flg:
            flg = False
            if accum <= 0:
                ret += -accum + 1
                accum = 1
        else:
            flg = True
            if 0 <= accum:
                ret += accum + 1
                accum = -1
    return ret


def main():
    print(min(f(False), f(True)))
    return


main()


Measured memory_bytes: 14084
from collections import deque
n = int(input())
l = [[] for _ in range(n)]
ans = [0]*(n-1)
q = deque()
color = [0]*n # 保持している色(初期:なし)
count = 0
for i in range(n-1):
    x,y = map(lambda x: int(x)-1, input().split())
    if i == 0:
        q.append(x) # 探索開始ノードを追加
    l[x].append((y,i))
    l[y].append((x,i))
while count<n-1:
    node = q.popleft()
    c = 1
    for d, ind in l[node]:
        if ans[ind] == 0:
            if c == color[node]:
                c += 1
            ans[ind] = c
            q.append(d) # キューを保存
            color[d] = c # 色の保存
            c += 1
            count += 1
print(max(ans))
for i in ans:
    print(i)

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string ss;cin>>ss;
  if(ss=="Sunny")cout<<"Cloudy"<<endl;
  else if(ss=="Cloudy")cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int gcd(int a, int b)
{
  for(;;) {
    int r = a % b;
    if(r == 0) return b;
    a = b;
    b = r;
  }
}
int main(int argc, char *argv[])
{
  auto isDivisor = [](int m, int n, int p, int q) {
    int mpnq = m * p + n * q;
    int mqnp = m * q - n * p;
    int m2n2 = m * m + n * n;
    return (mpnq % m2n2 == 0) && (mqnp % m2n2 == 0);
  };
  int t;
  cin >> t;
  while(t-- > 0) {
    int m, n;
    cin >> m >> n;
    int cnt = 0;
    for(int i = -200; i <= 200; i++) {
      for(int j = -200; j <= 200; j++) {
        if(i == 0 && j == 0) continue;
        if(isDivisor(i,j,m,n)) cnt++;
      }
    }
    cout << ((cnt == 8) ? "P" : "C") << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
int main()
{
    int n;
    set<int>S;
    vector<int>B;
    while(~scanf("%d",&n))
    {
        S.clear();
        B.clear();
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(S.count(x)){
        S.erase(x);
        B.push_back(x);}
        else
        S.insert(x);
    }
    sort(B.begin(),B.end());
    if((int)B.size()<2){
        printf("0\n");
    }
    else
    {
        int x=(int)B.size();
        printf("%lld\n",1LL*B[x-1]*B[x-2]);
    }
    }
    return 0;
}


Measured memory_bytes: 4992
import java. util.Scanner;
public class  Main{
	Scanner sc=new Scanner(System.in);
	int[] month={31,29,31,30,31,30,31,31,30,31,30,31};
	int day;
	
	void a(){
		while(true){
			int m=sc.nextInt();
			day=sc.nextInt();
			String y="";
			if(m==0)break;
			for(int i=0; i<m-1; i++)day+=month[i];
			m=(day)%7;
			switch(m){
				case 0:
					y= "Wednesday";
					break;
				case 1:
					y= "Thursday";
					break;
				case 2:
					y= "Friday";
					break;
				case 3:
					y= "Saturday";
					break;
				case 4:
					y="Sunday";
					break;
				case 5:
					y="Monday";
					break;
				case 6:
					y="Tuesday";
					break;
			}
			System.out.println(y);
		}
	}
	
	public static void main(String[]agrs){
		new Main().a();
	}
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int n; 
vector<pair<int, int>> v;
int main(void) 
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n; 
	for (int i=1; i<=n; i++) 
	{
		int x;
		cin >> x; 
		v.emplace_back(mp(x, i)); 
	}
	sort(v.begin(), v.end()); 
	for (int i=0; i<v.size(); i++)
		cout << v[i].ss << ' ';
	cout << '\n';

	


	return false; 
}


Measured memory_bytes: 1780
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll A, V, B, W, T;

int main() {

	cin >> A >> V >> B >> W >> T;

	if (V <= W) {
		cout << "NO" << endl;
		return 0;
	}

	if (abs(V - W) * T >= abs(A - B)) {
		cout << "YES" << endl;
		return 0;
	}

	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_B
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		Double ans = (double) 0;

		for(int i = 0; i < N; i++) {
			ans += 1 / sc.nextDouble();
		}

		System.out.println(1 / ans);

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}

}


Measured memory_bytes: 37600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100002][4];

ll vacation(ll a[],ll b[], ll c[], int prev, ll n){
	if(n==0)
		return 0;
	
	if(dp[n][prev]!=-1)
		return dp[n][prev];

	if(prev==0)
		return dp[n][0] = max(a[n] + vacation(a,b,c,1,n-1), max(b[n] + vacation(a,b,c,2,n-1), c[n] + vacation(a,b,c,3,n-1)));
	if(prev==1)
		return dp[n][1] = max(b[n] + vacation(a,b,c,2,n-1), c[n] + vacation(a,b,c,3,n-1));
	if(prev==2)
		return dp[n][2] = max(a[n] + vacation(a,b,c,1,n-1), c[n] + vacation(a,b,c,3,n-1));
	if(prev==3)
		return dp[n][3] = max(b[n] + vacation(a,b,c,2,n-1), a[n] + vacation(a,b,c,1,n-1));
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n+1],b[n+1],c[n+1];
    for(int i=1;i<=n;i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    int prev=0;
    cout<<vacation(a,b,c,prev,n);
}


Measured memory_bytes: 20000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll a;
    string s;
    cin >> a >> s ;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
#define LLINF 1145148101919
#define PI 3.14159265359
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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

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

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

////////////////////////////////////////

string S, T;
int ctoi_alpha(char c)
{
    if (c >= 'a' && c <= 'z')
    {
        return c - 'a';
    }
    return 0;
}

////////////////////////////////////////

int main()
{
    int N; cin >> N;
    ll ans = pow(N,3);
    cout << ans << endl;
}


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

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

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

int foo(int S, int i0, int i1, int i2, int i3, int i4, int i5, int i6, string& c) {
	int T = 0;
	T = (T << 1) + ((S >> i6) & 1);
	T = (T << 1) + ((S >> i5) & 1);
	T = (T << 1) + ((S >> i4) & 1);
	T = (T << 1) + ((S >> i3) & 1);
	T = (T << 1) + ((S >> i2) & 1);
	T = (T << 1) + ((S >> i1) & 1);
	T = (T << 1) + ((S >> i0) & 1);
	return c[T] - '0';
}

int main() {
	for (;;) {
		string c; cin >> c;
		if (c == "#") break;
		bool flag = true;
		for (int S = 0; S < (1 << 19); S++) {
			int T = 0, x = foo(S, 4, 6, 7, 9, 11, 12, 14, c);
			T = (T << 1) + foo(S, 9, 11, 12, 14, 16, 17, 18, c);
			T = (T << 1) + foo(S, 7, 9, 10, 12, 14, 15, 17, c);
			T = (T << 1) + foo(S, 6, 8, 9, 11, 13, 14, 16, c);
			T = (T << 1) + foo(S, 4, 6, 7, 9, 11, 12, 14, c);
			T = (T << 1) + foo(S, 2, 4, 5, 7, 9, 10, 12, c);
			T = (T << 1) + foo(S, 1, 3, 4, 6, 8, 9, 11, c);
			T = (T << 1) + foo(S, 0, 1, 2, 4, 6, 7, 9, c);
			int y = c[T] - '0';
			if (x != y) flag = false;
		}
		cout << (flag ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1184
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        // 入力
        long[] nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];

        long[] p = new long[m];
        long[] y = new long[m];
        for (int i = 0; i < m; i++)
        {
            long[] tmp = Console.ReadLine().Split().Select(long.Parse).ToArray();
            p[i] = tmp[0];
            y[i] = tmp[1];
        }

        long[] sp = new long[p.Length];
        long[] sy = new long[y.Length];
        Array.Copy(p, sp, p.Length);
        Array.Copy(y, sy, y.Length);

        Array.Sort(sy, sp);
        long count = 1;
        string ans = "";
        var dic = new Dictionary<Tuple<long, long>, string>() { };
        // 0で配列を初期化
        long[] s = Enumerable.Repeat<long>(1, (int)n + 1).ToArray();
        for (int i = 0; i < m; i++)
        {
            ans = sp[i].ToString("d6") + s[sp[i]-1].ToString("d6");
            dic.Add(new Tuple<long, long>(sp[i], sy[i]), ans);
            s[sp[i]-1]++;
        }



        for (int i = 0; i < m; i++)
        {
            Console.WriteLine(dic[new Tuple<long, long>(p[i], y[i])]);
        }


    }
}


Measured memory_bytes: 37548
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
ll fibo[100];
ll func(int a)
{
        if (fibo[a] != 0)
        {
                return fibo[a];
        }

        if (a == 0)
        {
                return fibo[0] = 2;
        }
        else if (a == 1)
        {
                return fibo[1] = 1;
        }
        else
        {
                return fibo[a] = func(a - 1) + func(a - 2);
        }
}

int main()
{
        //input->compute->output//

        int N;
        cin >> N;

        cout << func(N) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, k;
    cin >> n >> k;

    vl h(n+k);
    rep(i, n) {
        cin >> h[i];
    }
    exrep(i, n, n+k-1) {
        h[i] = INF;
    }

    vl dp(n+k, INF);  // dp[i] : 足場i(iは0-index)に移動するコストの最小値
    dp[0] = 0;
    rep(i, n) {
        exrep(j, 1, k) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    
    out(dp[n-1]);
    re0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  bool d = false;
  if (a == b){
	if (b != c){
		d = true;
	}
  }else{
	if (b == c || a == c){
		d = true;
	}
  }
  ( d) ? cout << "Yes\n" : cout << "No\n";
return 0;
}


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

#define ll long long int
int main()
{
    int i,j;
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;

    int arr[26];
    arr['r'-'a']=p;
    arr['s'-'a']=r;
    arr['p'-'a']=s;

    string ax;
    cin>>ax;
    ll ans=0;
    for(i=0;i<k;i++)
        {

        int prev=-1;
        int coun=0;
        ll aux_sum=0;
        for(j=i;j<ax.size();j+=k)
        {
            if(j==i)
                {prev=ax[j]-'a';
                coun++;
                }

            else
                if(prev==(ax[j]-'a'))
                    coun++;

                else

                {

                    aux_sum+=((coun/2)*arr[prev]);
                    if(coun%2)
                        aux_sum+=arr[prev];
                    coun=1;
                    prev=ax[j]-'a';


                }






        }

        aux_sum+=((coun/2)*arr[prev]);
        if(coun%2)
                        aux_sum+=arr[prev];

        ans+=aux_sum;
        }


        cout<<ans<<endl;




return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

string s;
long long cnt, ans;

int main()
{
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x, y;
	cin >> x >> y;
	bitset<32> a(x), b(y);
	cout << (a & b) << endl;
	cout << (a | b) << endl;
	cout << (a ^ b) << endl;
	return 0; 
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
char ch[maxn];
int main(){
    scanf(" %s",ch);
    int l=strlen(ch),ans=0;
    for(int i=1;i<=l-1;i++)
        ans+=(ch[i]!=ch[i-1]);
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(c>a+b)
	{
		cout<<b*2+a+1<<endl;
	}
	else
	{
		cout<<b+c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B= map(int, input().split())
for _ in range(N - 1):
    a, b= map(int, input().split())
    d = max(A // a, B // b)
    while (a * d < A) or (b * d < B):
        d += 1
    A = a * d
    B = b * d
print(A + B)


Measured memory_bytes: 3064
n, q = map(int, input().split())
s = input()
cum = [0] * (n + 1)
for i in range(2, n + 1):
    cum[i] = cum[i - 1]
    if s[i - 2:i] == "AC":
        cum[i] += 1

ans = [0] * q

for i in range(q):
    l, r = map(int, input().split())
    ans[i] = cum[r] - cum[l]
print(*ans, sep='\n')

Measured memory_bytes: 11860
#include <bits/stdc++.h>
using namespace std;
int n,d;
int a[101][101];
int main(){
    long long l,r;
    long long i,j;
    cin>>l>>r;

    if(r-l>=2019){
        cout<<0;
        return 0;
    }
    long long ans=2019;

    for(i=l ; i<=r ; i++){
        for(j=i+1 ; j<=r ; j++){
            ans=min(ans,i*j%2019);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(list(input().split()))
b = a
for i in range(n):
    b[i][1] = -int(b[i][1])
b = sorted(b)
for i in range(n):
    b[i][1] = -b[i][1]
    print(a.index(b[i])+1)

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

public final class Main {

	public static void main(String[] args) {
		final FastScanner fs = new FastScanner();
		final int time = fs.nextInt();
		int sameTime = 0;

		for (int i = 0; i < time; i++) {
			int a = fs.nextInt();
			int b = fs.nextInt();
			//System.out.println("a=" + a + "b=" + b);
			if (a == b) {
				sameTime++;
				if (sameTime >= 3) {
					System.out.println("Yes");
					System.exit(0);
				}

			} else {
				sameTime = 0;
			}
		}
		System.out.println("No");
	}

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  string S(a, '0' + b);
  string T(b, '0' + a);
  cout << min(S, T) << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    sum = 0
    currentMin = P[0]
    for n in P:
        if n <= currentMin:
            sum += 1
        # else:
            # print(f"m:{n}")
        currentMin = min(currentMin, n)
    print(sum)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25984
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
  int a, b, c, cnt;

  cin >> a >> b >> c;

  if(a == b && b == c) {
    cnt = 1;
  } else if(a == b || b == c || a == c) {
    cnt = 2;
  } else {
    cnt = 3;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
# print('input >>')
N = int(input())
mx = [[0] * 9 for i in range(9)]

for i in range(1, N+1):
    stri = str(i)
    if not stri[-1] == '0':    
        mx[int(stri[0])-1][int(stri[-1])-1] += 1


ans = 0
for j in range(1, N+1):
    strj = str(j)
    # print(strj[-1],"で始まり",strj[0],"で終わる",mx[int(strj[-1])-1][int(strj[0])-1])
    if not strj[-1] == '0':
        ans += mx[int(strj[-1])-1][int(strj[0])-1]

# print('-----output-----')
print(ans)

Measured memory_bytes: 3188