akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;
	int H, M;
	cin >> H >> M;

	double pi = acos(-1);

	double ji = double(H * 60 + M) / 360 * pi;
	double hun = double(M) / 30 * pi;

	ce(ji);
	ce(hun);

	double x = A * cos(ji) - B * cos(hun);
	double y = A * sin(ji) - B * sin(hun);

	double kotae = sqrt(x * x + y * y);

	cout << setprecision(12) << kotae << endl;


	Would you please return 0;
}

Measured memory_bytes: 4120
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

string str[8];

void chain(int x, int y){
	
	if(x < 0 || x >= 8 || y < 0 || y >= 8){
		return;
	}
	if(str[y][x] == '0'){
		return;
	}else{
		str[y][x] = '0';
		chain(x - 1, y);
		chain(x - 2, y);
		chain(x - 3, y);
		chain(x + 1, y);
		chain(x + 2, y);
		chain(x + 3, y);
		chain(x, y - 1);
		chain(x, y - 2);
		chain(x, y - 3);
		chain(x, y + 1);
		chain(x, y + 2);
		chain(x, y + 3);
	}
	
}

int main(){
	
	
	int n, x, y;
	
	cin >> n;
	
	for(int loop = 1; loop <= n; loop++){
		for(int i = 0; i < 8; i++){
			cin >> str[i];
		}
		cin >> x >> y;
		chain(x - 1, y - 1);
		
		printf("Data %d:\n", loop);
		for(int i = 0; i < 8; i++){
			cout << str[i] << endl;;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1228
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

template <class T> void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1)
    return cout << "0" << endl, 0;
  int x = n - k + 1;
  cout << x - 1 << endl; 
  return 0;
}

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

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 str_to_i(string S) {
    int acc = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        int d = S[i] - '0';
        acc = acc * 10 + d;
    }
    return acc;
}

int main(void) {
    string S;
    cin >> S;

    int year = str_to_i(S.substr(0, 4));
    int month = str_to_i(S.substr(5, 2));
    int day = str_to_i(S.substr(8, 2));

    if (month <= 4) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}


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

 
int main()
{	int x, y;
	cin>>x>>y;
	int sum = 4*x;
	if(sum == y){

	cout<<"Yes"; return 0;
	} 
	if(y > sum or x*2 > y){

		cout<<"No"; return 0;
	} 
	for(int i=1; i<=x; i++){
		sum -= 2;
		if(sum == y){
			cout<<"Yes";
			break;
		}
		if( sum < y){
			cout<<"No";
			break;
		}
	}

 	return 0;
}

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

// パターンが少ないので全部書いたら出力結果のformatで()...
// 相当キモいことに...

int main()
{
  string ABCD;
  cin >> ABCD;
  int A = stoi(ABCD) / 1000;
  int B = stoi(ABCD) / 100 - 10*A;
  int C = stoi(ABCD) / 10 - 100*A - 10*B;
  int D = stoi(ABCD) - 1000*A - 100*B - 10*C;
  //cout << A << ' ' << B << ' ' << C << ' ' << D << endl;

  //  int A_dash = 7 - A;
  // A_dash = op1 B op2 C op3 Dとなればいい。

  int result[8];
  result[0] = A + B + C + D;
  result[1] = A + B + C - D;
  result[2] = A + B - C + D;
  result[3] = A + B - C - D;
  result[4] = A - B + C + D;
  result[5] = A - B + C - D;
  result[6] = A - B - C + D;
  result[7] = A - B - C - D;

  int i = 0;
  for (i = 0; i < 8; i++) {
    //cout << result[i] << endl;
    //cout << i << endl;
    if (7 == result[i]) break;
  }
  //  char plus = '+', minus = '-';

  if (i == 0) cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
  else if (i == 1) cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
  else if (i == 2) cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
  else if (i == 3) cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
  else if (i == 4) cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
  else if (i == 5) cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
  else if (i == 6) cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
  else if (i == 7) cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;

  return 0;
}


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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  string a, b, c; cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << "\n";
  return 0;
}

Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
    static StringBuilder builder = new StringBuilder();
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        final int n = Integer.parseInt(reader.readLine());
        final int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = Integer.parseInt(reader.readLine());
        }
        shellSort(a, n);
        for (int i = 0; i < n; ++i) {
            builder.append(a[i]).append("\n");
        }
        System.out.print(builder);
    }
 
    private static void shellSort(int[] a, int n) {
        ArrayList<Integer>nums = new ArrayList<Integer>();
        int m = 0;
        for (int i = 1; i <= n; i = i * 3 + 1) {
            //g[m] = i;
        	nums.add(m,i);
            m++;
        }
 
        builder.append(m).append("\n");
 
        m--;
        int cnt = 0;
        for (int i = m; i >= 0; i--) {
            if (i != m)
            builder.append(" ");
            builder.append(nums.get(i));
            cnt += insertionSort(a, n, nums.get(i));
        }
        builder.append("\n").append(cnt).append("\n");
    }
 
    private static int insertionSort(int[] a, int n, int g) {
        int cnt = 0;
        for (int i = g; i < n; ++i) {
            final int key = a[i];
            int j = i - g;
            while (j >= 0 && a[j] > key) {
                a[j + g] = a[j];
                j = j - g;
                cnt++;
            }
            a[j + g] = key;
        }
        return cnt;
    }
}

Measured memory_bytes: 130896
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)

total = A.sum() // 2
first = total - A[1::2].sum()

B = [first]
for a in A[:-1]:
  B.append(a-B[-1])
  
print(' '.join(str(2*x) for x in B))

Measured memory_bytes: 24944
N = int(input())
S = input()
dp = [[0]*N for _ in range(N)]
ans = 0
for i in range(N-1,0,-1):
    for j in range(i-1,-1,-1):
        if S[i] == S[j]:
            if i < N-1 and j < i-1:
                dp[i][j] = min(dp[i+1][j+1]+1, i-j)
            else:
                dp[i][j] = 1
        ans = max(ans, dp[i][j])
print(ans)


Measured memory_bytes: 230152
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);
    lli n,k;
    cin>>n>>k;
    lli i,j,a[n],dp[k+1];
    memset(dp,0LL,sizeof(dp));
    
    for(i=0;i<n;i++) cin>>a[i];
    
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i-a[j]>=0 && dp[i-a[j]]==0)
                dp[i]=1;
        }
    }
    if(dp[k]==1) cout<<"First";
    else         cout<<"Second";
    return 0;
}

Measured memory_bytes: 1024
#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 < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(x,n);
    vec(y,n);
    vec(h,n);
    REP(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }
    int spl = 0;
    while(h[spl] == 0){
        spl++;
    }
    REP(i,101){
        REP(j,101){
            int hs = abs(i-x[spl])+abs(j-y[spl])+h[spl];
            bool ans = true;
            REP(k,n){
                if(h[k] == 0){
                    int ju = hs-(abs(i-x[k])+abs(j-y[k]));
                    if(ju > 0){
                        ans = false;
                        break;
                    }
                }
                else{
                    int ju = (hs-h[k])-(abs(i-x[k])+abs(j-y[k]));
                    if(ju != 0){
                        ans = false;
                        break;
                    }
                }
            }
            if(ans){
                cout << i << " " << j << " " << hs << endl;
                return 0;
            }
        }
    }


    
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
int get_ans(int a)
{
	int ans=0;
	while(a)
	{
		++ans;
		int b=a;
		int cnt=0;
		while(b)
		{
			if(b%2)++cnt;
			b=b/2;
		}
		a=a%cnt;
	}
	return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int cnt=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	if(s[i]=='1')++cnt;
	ll pow[n][2];
	pow[0][0]=pow[0][1]=1;
	for(int i=1;i<n;i++)
	{
		if(cnt!=1)
		pow[i][0]=(pow[i-1][0]*2)%(cnt-1);
		
		pow[i][1]=(pow[i-1][1]*2)%(cnt+1);
	}
	ll ans[2]={0};
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			if(cnt!=1)
			ans[0]=(ans[0]*2+1)%(cnt-1);
			
			ans[1]=(ans[1]*2+1)%(cnt+1);
		}
		else
		{
          if(cnt!=1)
			ans[0]=(ans[0]*2)%(cnt-1);
          
			ans[1]=(ans[1]*2)%(cnt+1);
		}
	}
	for(int i=0;i<n;i++)
	{
		if(s[i]=='1')
		{
			if(cnt==1)
			{
				cout<<0<<"\n";
			}
			else
			{
				int a=ans[0];
				a=(a-pow[n-1-i][0]+(cnt-1))%(cnt-1);
				cout<<1+get_ans(a)<<"\n";
			}	
		}
		else
		{
			    int a=ans[1];
				a=(a+pow[n-1-i][1])%(cnt+1);
				cout<<1+get_ans(a)<<"\n";
		}
	}	
	return 0;
}

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

int main(){
  int n;
  long long t, lcm;
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> t;
    if(i == 0) lcm = t;
    else lcm = lcm / __gcd(lcm, t) * t;
  }
  
  cout << lcm << endl;
  
  return 0;
}

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

int main(void){

  int n;
  int i, j;

  scanf("%d", &n);

  int b[n], f[n], r[n], v[n];

  int A[4][16], B[4][16], C[4][16], D[4][16];

  for(i = 0; i < 3; i++){
    for(j = 0; j < 10; j++){
      A[i][j] = 0;
      B[i][j] = 0;
      C[i][j] = 0;
      D[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d %d %d %d", &b[i], &f[i], &r[i], &v[i]);
    if(b[i] == 1){
      A[f[i] - 1][r[i] - 1] += v[i];
    }else if(b[i] == 2){
      B[f[i] - 1][r[i] - 1] += v[i];
    }else if(b[i] == 3){
      C[f[i] - 1][r[i] - 1] += v[i];
    }else if(b[i] == 4){
      D[f[i] - 1][r[i] - 1] += v[i];
    }
  }

  for(i = 0; i < 3; i++){
    for(j = 0; j < 10; j++){
      printf(" %d", A[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(i = 0; i < 3; i++){
    for(j = 0; j < 10; j++){
      printf(" %d", B[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(i = 0; i < 3; i++){
    for(j = 0; j < 10; j++){
      printf(" %d", C[i][j]);
    }
    printf("\n");
  }
  printf("####################\n");
  for(i = 0; i < 3; i++){
    for(j = 0; j < 10; j++){
      printf(" %d", D[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2060
N = gets.to_i
B = gets.split(" ").map(&:to_i)
A = []
A << B[0]
i = 1
while i < N - 1 do
    if B[i - 1] < B[i]
        A << B[i - 1]
    else
        A << B[i]
    end
    i += 1
end
A << B[-1]
puts A.inject(:+)


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll h, w; cin >> h >> w;
   ll ans = 1e10;
   ll Smax, Smin;
   for (int i=1; i<h; i++){
      Smax = w * i;
      Smin = w * i;
      ans = min(ans, max(Smax, (w-w/2)*(h-i))-min(Smin, (w/2)*(h-i)));
      ans = min(ans, max(Smax, w * (h-i-(h-i)/2))-min(Smin, w * ((h-i)/2)));
   }
   swap(h,w);
   for (int i=1; i<h; i++){
      Smax = w * i;
      Smin = w * i;
      ans = min(ans, max(Smax, (w-w/2)*(h-i))-min(Smin, (w/2)*(h-i)));
      ans = min(ans, max(Smax, w * (h-i-(h-i)/2))-min(Smin, w * ((h-i)/2)));
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
#define M 1000003 
#define L 14
 
char H[M][L];
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2; 
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else  return 0;
}
 
int getKey(char str[]){ 
  int sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ 
  return key%M; 
}
 
int h2(int key){ 
  return 1+key%(M-1); 
}
 
int find(char str[]){
  int i=0,key,sum;
  key=getKey(str);
 
  for(i=0;;i++){
    sum=(h1(key)+i*h2(key))%M;
    if(strcmp(H[sum],str)==0)return 1;
    else if(strlen(H[sum])==0) return 0;
  }
  return 0;
}
 
int insert(char str[]){
  int key,i=0,k; 
    key=getKey(str);
    for(i=0;;i++){
      k=(h1(key)+i*h2(key))%M;
      if(strcmp(H[k],str)==0)return 1;
      else if(strlen(H[k])==0){
    strcpy(H[k],str);
    return 0;
      }
    }
    return 0;
}
int main(){
  int i, n; 
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){ 
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){ 
      insert(str); 
    }
    else {
      if (find(str)){ 
    printf("yes\n");
      }
      else {
    printf("no\n");
     
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 15428
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,k;
  cin>>n>>k;
  long long int arr[k],sum=0,ma=0;

  for(int i=0;i<k;++i)
  {
    cin>>arr[i];
  }
  for(int i=1;i<k;++i)
  {
    if(arr[i]-arr[i-1]>ma)
      ma=arr[i]-arr[i-1];
  }
  ma=max(ma,n+arr[0]-arr[k-1]);
  cout<<n-ma<<endl;
}


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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

int main(){

  ll r, g;
  cin >> r >> g;

  cout << (g * 2 - r) << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main()
    {
        var rgb = Console.ReadLine().Split(' ');
        var r = int.Parse(rgb[0]);
        var g = int.Parse(rgb[1]);
        var b = int.Parse(rgb[2]);
        if ((r * 100 + g * 10 + b) % 4 == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11092
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i;
    boolean[] y;

    y = new boolean[30];
    for(i = 0;i < 28;i++){
      n = sc.nextInt(); y[--n] = true;
    }
    for(n = 0;n < 30;n++)if(!y[n])out.println(n + 1);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17352
import java.util.*;
public class Main {
	public static void main(String[] args){
		Set<String> set = new HashSet<>();
	      Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
	      for(int i = 0; i < N; i++) {
	    	  String s = sc.next();
	    	  set.add(s);
	      }
	      System.out.println(set.size());
	}
}

Measured memory_bytes: 76788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            double yenTotal = 0;

            for (int i = 0; i < n; ++i)
            {
                string[] strs = Console.ReadLine().Split(' ');

                if (strs[1][0] == 'J')
                {
                    yenTotal += double.Parse(strs[0]);
                }
                else
                {
                    yenTotal += double.Parse(strs[0]) * 380000.0;
                }
            }

            Console.WriteLine(yenTotal.ToString());
        }
    }
}


Measured memory_bytes: 13140
import java.awt.Point;
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int max = 0;
        int maxIndex = 0;
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            if (Math.abs(max) < Math.abs(a[i])) {
                max = a[i];
                maxIndex = i;
            }
        }
        List<Point> ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (maxIndex != i) {
                ans.add(new Point(maxIndex + 1, i + 1));
            }
        }
        if (max == 0) {
            System.out.println(0);
            return;
        } else if (max > 0) {
            for (int i = 2; i <= n; i++) {
                ans.add(new Point(i - 1, i));
            }
        } else {
            for (int i = n - 1; i > 0; i--) {
                ans.add(new Point(i + 1, i));
            }
        }
        System.out.println(ans.size());
        for (Point point : ans) {
            System.out.println(point.x + " " + point.y);
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 21972
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        int a = r.i();
        String s = r.s();
        println(a >= 3200 ? s : "red");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;



int main() {
    string s; cin >> s;
    bool can = true;
    int n = s.size();

    rep(i, n) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                can = false;
                break;
            }
        }
        else {
            if (s[i] == 'R') {
                can = false;
                break;
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i=1;;i++){
            int a = sc.nextInt();
            if(a == 0){
                System.exit(0);
            }else{
                System.out.println("Case "+i+": "+a);
            }
       }
    }
}


Measured memory_bytes: 41664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef queue <int> qi;

int main() {
  int n, m; cin >> n >> m;
  vvi vex(n);
  vi hi(n), dp(n);
  int u, v;
  while(m--) {
    cin >> u >> v;
    vex[v - 1].push_back(u - 1);
    ++hi[u - 1];
  }
  
  qi box;
  for(int i = 0; i < n; ++i) {
    //cout << hi[i] << ' ';
    if(hi[i] == 0) { box.push(i); } }
  
  while(!box.empty()) {
    int rx = box.front();
    box.pop();
    
    for(int& r : vex[rx])
      if(--hi[r] == 0) {
        dp[r] = dp[rx] + 1;
         box.push(r);
      }
  }
  
  int mx = 0;
  for(int& i : dp)
    mx = max(mx, i);
  
  cout << mx;
  
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int N = 1e5 + 5;

int a[N], b[N], v[N];
int prea[N], suffa[N], preb[N], suffb[N];
				
int32_t main() {
	fast_cin();  

	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
		if (i % 2) a[v[i]]++;
		else b[v[i]]++;
	}
	for (int i = 1; i < N; i++) {
		prea[i] = a[i], preb[i] = b[i];
		prea[i] = max(prea[i], prea[i - 1]);
		preb[i] = max(preb[i], preb[i - 1]);
	}
	for (int i = N - 2; i >= 1; i--) {
		suffa[i] = a[i], suffb[i] = b[i];
		suffa[i] = max(suffa[i], suffa[i + 1]);
		suffb[i] = max(suffb[i], suffb[i + 1]);
	}
	int ans = 0;
	for (int i = 1; i < N - 1; i++) {
		int temp1 = a[i] + max(preb[i - 1], suffb[i + 1]);
		int temp2 = b[i] + max(prea[i - 1], suffa[i + 1]);
		if (ans <= temp1) {
			ans = temp1;
		}
		if (ans <= temp2) {
			ans = temp2;
		}
	}
	cout << n - ans << endl;

	return 0;
}

Measured memory_bytes: 5760
import java.util.Arrays;
import java.util.Scanner;

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

		if(s.compareTo(t) < 0) {
			System.out.println("Yes");
			return;
		}

		char[] sa = s.toCharArray();
		Arrays.sort(sa);
		s = new String(sa);
		char[] ta = t.toCharArray();
		Arrays.sort(ta);
		t = (new StringBuilder((new String(ta)))).reverse().toString();

		if(s.compareTo(t) < 0) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");

		return;
	}

}

Measured memory_bytes: 22996
data = [input().split() for i in range(2)]
NM = data[0]
N = int(NM[0])
M = int(NM[1])
A = data[1]
sum = 0
for i in A:
  sum += int(i)
result = N - sum
if result >=0:
  print(result)
else:
  print("-1")

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

int main(){
  int N, M;
  cin >> N >> M;
  pair<int,int> P;
  vector<pair<int,int>> vec(M);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    P = make_pair(a,b);
    vec.at(i) = P;
  }
  sort(vec.begin(),vec.end());
  int cnt = 0;
  int pos = vec.at(0).second-1;
  for(int i=0; i<M; i++){
    pos = min(pos,vec.at(i).second-1);
    if(i != M-1){
      if(pos < vec.at(i+1).first){
        cnt++;
        pos = vec.at(i+1).second-1;
      }
    }
    //cout << cnt << endl;
  }
  cout << cnt + 1 << endl; 
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    ans = 'Yes'
    for i in reversed(range(1, N)):
        if H[i-1]-H[i] > 1:
            ans = 'No'
            break
        elif H[i-1]-H[i] == 1:
            H[i-1] -= 1
    
    # print(H)
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

  int choosable_cnt = 0;
  for(int i = 0; i < N; i++){
    if(A[i] >= (A_sum + 4 * M - 1) / (4 * M)){
      choosable_cnt++;
    }
  }

  if(choosable_cnt >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
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;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) { //逆元
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

//宣言とか

/*signed*/int main(void) {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) if (s[i] == '?') s[i] = 'D';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3772
void main() {
	auto S = rs;
	bool flag = true;
	if(S[0] != 'A') flag = false;
	ulong tmp;
	foreach(i; 2..S.length-1) {
		tmp += S[i] == 'C';
	}
	if(flag) {
		ulong tmp2;
		foreach(i; S) {
			if(i.isUpper) tmp2++;
		}
		if(tmp2!=2) flag = false;
	}
	if(tmp != 1) flag = false;
	writeln(flag ? "AC" : "WA");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
 
fn main() {
    
    let n = read::<usize>();
    
    let mut map = HashMap::new();
    
    for _ in 0..n {
        let mut ret = read::<String>().chars().collect::<Vec<char>>();
        ret.sort();
        let str = ret.into_iter().collect::<String>();
        let count = map.entry(str).or_insert(0u64);
        *count += 1;
        //println!("{:?}", str);
    }
    
    let mut ans = 0;
    
    for (_, value) in &map {
        //println!("{}: {}", key, value);
        if *value < 2u64 {continue;}
        ans += value * (value - 1) / 2;
    }
    
    //println!("{:?}", map);
    println!("{}", ans);

}


Measured memory_bytes: 15420
#include <stdio.h>

int main()
{
	char S[100001];
	scanf("%s", &S);
	
	int i, a[100001], count = 0;
	for (i = 0; S[i] != 0; i++) {
		a[i] = S[i] - '0';
		if (i % 2 == 0) a[i] ^= 1;
		count += a[i];
	}
	
	if (count <= i / 2) printf("%d\n", count);
	else printf("%d\n", i - count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break
    x = list(map(int, input().split()))
    
    y = sum(x)/n
    a = 0
    for i in range(n):
        a += (x[i]-y)**2
    
    m = math.sqrt(a/n)
    print(f'{m:.8f}')


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

int n;
int v[25], c[25];
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] - c[i] > 0) ans += v[i] - c[i];
    }
    cout << ans;
}

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

class RSAQ{
public: 
  typedef long long ll;
  const int mod = 1e9+7;
  //マージ可能な主データ型
  struct D{
    ll value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(ll value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };

  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    ll value;
    T():type(0),value(0){}
    T(int type,ll value):type(type),value(value){}
  };

  
  int n, n_;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSAQ(){n=-1;}
  RSAQ(int n_):n_(n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  inline D merge(const D a,const D b)const{return (a.value + b.value)%mod;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    ll type = td[k].type;
    ll v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    len /= 2;
    {
      int l = k*2+1;
      dat[l].value += v * len;
      td[l].type = type;
      td[l].value += v;
    }
    {
      int r = k*2+2;
      dat[r].value += v * len;
      td[r].type = type;
      td[r].value += v;
    }
  }

  D write(int k, D x, int len){
    dat[k].value += x.value * len;
    td[k].type = 1;
    td[k].value += x.value;
    return dat[k];
  }
  
  D dfs(int a, int b, D x, bool flag, int k, int l, int r){
    if(r <= a||b <= l) return flag? dat[k]:returnD;
    if(a <= l && r <= b) return flag? write(k, x, r - l):dat[k];
    delay(k, r - l);
    D vl = dfs(a, b, x, flag, k*2+1, l, (l+r)/2);
    D vr = dfs(a, b, x, flag, k*2+2, (l+r)/2, r);
    return flag? (dat[k] = merge(vl, vr)):merge(vl, vr);
  }

  //[l,r)の値にx加算
  void add(int l,int r,ll x){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    dfs(l, r, D(x), true, 0, 0, n);
  }
  
  //[l,r)の合計値を得る
  ll get(int l,int r){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    D res = dfs(l, r, D(), false, 0, 0, n);
    return res.value;
  }
};

const int N = 2005;
const int M = 2005;
const int mod = 1e9 + 7;

int n, m;
int A[N], B[M];
int dp[N][M];

signed main(){
  
  cin>>n>>m;
  
  for(int i=0;i<n;i++) cin>>A[i];
  
  for(int i=0;i<m;i++) cin>>B[i];
  
  RSAQ rmq( m );
  
  for(int i=0;i<n;i++){
    
    for(int j=0;j<m;j++){
      
      if( A[i] == B[j] ){
	dp[i][j] = rmq.get(0,j) + 1;
	dp[i][j] %= mod;
      }
      
    }
    
    for(int j=0;j<m;j++){
      
      if( A[i] == B[j] ){
	rmq.add(j,j+1,dp[i][j]);
      }
      
    }
    
  }
  
  int ans = ( rmq.get( 0, m ) + 1 ) % mod;
  
  cout<<ans<<endl;
  
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll n, k; cin >> n >> k;
    ll res = 0;
    rep(i, min(n, k+1)){
        res = modint(modint(res) + comb(n, i)*comb(n-1, n-1-i));
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define bit(x) __builtin_popcount(x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
// =================
void impgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1e9;
const int N = 3e5 + 1;

vi g[N];
int A[N];

void solve()
{
    int n, m, ans = 0, cnt = 0, k;
    cin>>n>>k;
    vi h(n);
    f(i,0,n) cin>>h[i];
    vi dp(n,mod);
    dp[0]=0;
    f(i,0,n) {
        for(int j=i+1;j<n && j-i<=k;j++) {
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();

    return 0;
}

void impgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (A[v])
        {
        }
        dfs(v, 0);
    }
}

Measured memory_bytes: 11108
import java.util.Scanner;
 
public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String S = sc.next();
        int minDiff = -1;
        int X = 0;
        int minX= 0;
        //System.out.println("S="+S);
        for(int i = 0 ; i < S.length() - 2; ++i) {
            
            String sub = S.substring(i, i+3);
            
            X = Integer.parseInt(sub);
            int diff = Math.abs(X - 753);
            if(minDiff ==-1 || diff <= minDiff) {
                minX = X;
              minDiff = diff;
            }
            //System.out.println("X="+X+" sub="+sub+" minX="+minX +" diff="+diff);
          
        }
      System.out.println(minDiff);
 
    }
 
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> t(N), d(N);
    priority_queue<pair<ll, ll>> q; 
    REP(i, N)
    {
        cin >> t[i] >> d[i];
        t[i]--;
        q.push(make_pair(d[i], t[i]));
    }
    ll score = 0;
    ll kind = 0;
    vector<bool> isEat(N, false);
    priority_queue<ll, vector<ll>, greater<ll>> depliQ;
    REP(i, K)
    {
        pair<ll, ll> p = q.top();
        q.pop();
        ll t = p.second;
        ll d = p.first;
        if (!isEat[t])
        {
            kind++;
            isEat[t] = true;
        }
        else
        {
            depliQ.push(d);
        }
        score += d;
    }
    score += kind * kind;

    ll ans = score;
    while (!q.empty())
    {
        pair<ll, ll> p = q.top();
        q.pop();
        ll t = p.second;
        ll d = p.first;
        if (!isEat[t])
        {
            kind++;
            isEat[t] = true;
            if (!depliQ.empty())
            {
                ll removeD = depliQ.top();
                depliQ.pop();
                score -= removeD;
                score -= (kind - 1) * (kind - 1);
                score += d;
                score += kind * kind;
                ans = max(ans, score);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(it, c) \
  for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007LL;

ll dp[64][3];

int main() {
  ll N;
  cin >> N;

  dp[63][0] = 1;
  for (ll i = 62; i >= 0; i--) {
    if (((N >> i) & 1) == 0) {
      dp[i][0] += dp[i + 1][0];
      dp[i][0] %= MOD;
      dp[i][0] += dp[i + 1][1];
      dp[i][0] %= MOD;

      dp[i][1] += dp[i + 1][1];
      dp[i][1] %= MOD;

      dp[i][2] += dp[i + 1][1];
      dp[i][2] %= MOD;
      dp[i][2] += dp[i + 1][2] * 3;
      dp[i][2] %= MOD;
    } else {
      dp[i][0] += dp[i + 1][0];
      dp[i][0] %= MOD;

      dp[i][1] += dp[i + 1][0];
      dp[i][1] %= MOD;
      dp[i][1] += dp[i + 1][1];
      dp[i][1] %= MOD;

      dp[i][2] += dp[i + 1][1] * 2;
      dp[i][2] %= MOD;
      dp[i][2] += dp[i + 1][2] * 3;
      dp[i][2] %= MOD;
    }
  }

  ll ret = 0;
  rep(i, 3) {
    ret += dp[0][i];
    ret %= MOD;
  }

  cout << ret << endl;

  return 0;
}


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


int main(){
  //int n; cin >> n;
  string s,t ; cin >> s >> t;
  int n = s.size();
  bool ans = true;
    
  for (int i=0; i<n; i++){
    if(s.at(i)!=t.at(i)){
      ans = false;
      break;
    }
  }
  
  if(ans){
    cout << "Yes" << endl;;
  }
  else{
    cout << "No" << endl;
  }
  
  
  
}

Measured memory_bytes: 3628
M,D=map(int,input().split())

count=0
for i in range(1,M+1):
    for j in range(22,D+1):
        temp=str(j)
        if temp[0] >="2" and temp[1]>="2":
            if int(temp[1]) * int(temp[0])==i:
                count+=1

print(count)



Measured memory_bytes: 2940
//#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <algorithm>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

const int nmax = 100;
const double pi = acos(-1);

struct pct {
    int x, y, ind;

    bool operator < (const pct &shp) const {
        if (x != shp.x)
            return x < shp.x;
        return y < shp.y;
    }
} v[nmax + 1], st[nmax + 1];

vector< pct > inf;

double sol[nmax + 1];

inline int ccw (pct x, pct y, pct z) {
    long long ans = (1LL * x.x * y.y - 1LL * x.y * y.x +
                     1LL * y.x * z.y - 1LL * y.y * z.x +
                     1LL * z.x * x.y - 1LL * z.y * x.x);

    if (ans > 0) return 1;
    if (ans == 0) return 0;
    return -1;
}

int main() {
    int n;

    cin >> n;
    for( int i = 1; i <= n; ++ i ) {
        cin >> v[ i ].x >> v[ i ].y;
        v[ i ].ind = i;
    }
    sort(v + 1, v + n + 1);

    int t = 0;
    st[ ++ t ] = v[ 1 ];
    st[ ++ t ] = v[ 2 ];
    for( int i = 2; i <= n; ++ i ) {
        while ( t >= 2 && ccw(st[t - 1], st[ t ], v[ i ]) != 1) {
            -- t;
        }
        st[ ++ t ] = v[ i ];
    }
    for( int i = 1; i <= t; ++ i ) {
        inf.push_back( st[ i ] );
    }

    t = 0;
    st[ ++ t ] = v[ n ];
    st[ ++ t ] = v[ n - 1 ];
    for( int i = n - 2; i > 0; -- i ) {
        while ( t >= 2 && ccw(st[t - 1], st[ t ], v[ i ]) != 1) {
            -- t;
        }
        st[ ++ t ] = v[ i ];
    }

    for( int i = 2; i < t; ++ i ) {
        inf.push_back( st[ i ] );
    }

    for (int i = 0; i < (int)inf.size(); ++ i) {
        pct nxt = inf[ 0 ];
        pct ant = inf.back();

        if (i - 1 >= 0)
            ant = inf[i - 1];
        if (i + 1 < (int)inf.size())
            nxt = inf[i + 1];

        double u1 = atan2(ant.y - inf[ i ].y, ant.x - inf[ i ].x);
        double u2 = atan2(nxt.y - inf[ i ].y, nxt.x - inf[ i ].x);

        if (u1 > u2)
            swap(u1, u2);

        double dif = min(2 * pi - (u2 - u1), u2 - u1);

        sol[ inf[ i ].ind ] = (pi - dif) / (2 * pi);
    }

    cout << setprecision( 7 ) << fixed;
    for (int i = 1; i <= n; ++ i)
        cout << sol[ i ] << "\n";

    return 0;
}


Measured memory_bytes: 256
k=int(input())
if k % 2 ==0:
    print(-1)
else:
    n=7
    ans = 0
    while(True):
        ans += 1
        if ans >= 10**6:
            print(-1)
            exit()
        n %= k
        if n  == 0:
            print(ans)
            exit()
        n = 10 * n + 7


Measured memory_bytes: 63180
d = ["maerd", "remaerd", "esare", "resare"]
s = gets.chomp
s.reverse!
t = s.dup
while s do
  for i in 0..3
    if s.start_with?(d[i])
      #puts d[i]
      #puts s
      #puts t
      s.slice!(0, d[i].length)
      #puts s
      #puts t
    end
    #puts s
  end
  if s == ""
    #puts s
    puts "YES"
    exit
  end
  if s == t
    #puts s
    #puts t
    puts "NO"
    exit
  end
  #puts s
  #puts t
  t = s.dup
end


Measured memory_bytes: 71804