akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
/******* MY EVERY AC WILL BE A TRIBUTE TO SSR ********/
#define vi vector
#define lli long long int
#define vli vi<lli>
#define pb push_back
#define pll pair<lli,lli>
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(),greater<lli>()
#define clear(x) x.clear()
#define rep(i,n) for(lli i=0;i<(lli)n;i++)
#define rep1(i,n) for(lli i=1;i<=(lli)n;i++)
#define rep2(i,n) for(lli i=1;i<(lli)n;i++)
#define refor(i,n) for(lli i=(lli)n;i>=0;i--)
#define range(i,l,r) for(lli i=(lli)l;i<=(lli)r;i++)
#define big(x,y) (x>y)?x:y
#define small(x,y) (x<y)?x:y
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
using namespace std;
lli gcd(lli a,lli b) {return b==0?a:gcd(b,a%b);}
lli lcm(lli a,lli b) {return (a*b)/gcd(a,b);}
bool isprime(lli x) {for(lli i=2;i<=sqrt(x);i++) { if(x%i == 0) return false;} return true;}
lli modpow(lli x,lli y) {x%=mod;lli res=1;while(y>0){if(y&1) res*=x%mod; y=y>>1; x=x*x%mod;} return res%mod;}
lli ncr(lli n,lli k) {lli res=1; if(k>n-k) k=n-k; rep(i,k){res*=(n-i);res/=(i + 1);} return res;}
lli bintodec(lli n) {lli decimal=0,i=0,rem;while (n!=0){rem = n%10;n/=10;decimal += rem*pow(2,i);++i;}return decimal;}

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

    string s,t;
    cin>>s>>t;
    lli ss=0,n;
    n=s.length();
    rep(i,n)
    { if(s[i]!=t[i])
         ss++;
	}
	
	cout<<ss<<'\n';
	    return 0;
}











Measured memory_bytes: 3888
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll=long long;
const int MAXN=100010;

int nlen;
int num[MAXN];

bool check(){
    auto pa=minmax_element(num+1,num+1+nlen);
    auto a=pa.first,b=pa.second;

    if(abs(*a-*b)>1)return false;

    if(*a==*b){
        if(*a==nlen-1)return true;
        else{
            //一只猫认为剩下的颜色最多为nlen-2，至少有两只猫的颜色一致。就是所有的猫至少同色两只，那么颜色不能过半
            return *a*2<=nlen;
        }
    }else{
        int singledog=0;
        int color=*b;
        for(int i=1;i<=nlen;i++)
            if(num[i]==*a){
                singledog++;
            }
        if(singledog>=color)return false;
        return 2*(color-singledog)<=nlen-singledog;
    }
}
int main(){
    ios::sync_with_stdio(false);

    cin>>nlen;
    for(int i=1;i<=nlen;i++){
        cin>>num[i];
    }

    if(check()){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}

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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    long long ret = 0;
    int nr = 0, ng = 0, nb = 0;
    for (auto c : S)
    {
        if (c == 'R') nr++;
        if (c == 'G') ng++;
        if (c == 'B') nb++;
    }
    ret = 1LL * nr * ng * nb;

    for (int j = 0; j < N; j++)
    {
        for (int i = 0; i < N; i++)
        {
            int k = i * 2 - j;
            if (j < k and k < N)
            {
                if (S[i] != S[j] and S[j] != S[k] and S[i] != S[k])
                {
                    ret--;
                }
            }
        }
    }
    cout << ret << "\n";
}


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

int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector<long long> num(100001);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        num[a]+=b;
    }
    for(int i=0;i<=100000;i++){
        k-=num[i];
        if(k<=0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    int N, M, li, ri, maxL=0, minR=100000;
    cin >> N >> M;
    for (int i=0; i<M; i++) {
        scanf("%d %d", &li, &ri);
        maxL = max(maxL, li);
        minR = min(minR, ri);
    }

    cout << max(0, minR - maxL + 1) << endl;

    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
L = K.bit_length()
D = [0]*(L+1)
A = list(map(int, input().split()))
for a in A:
    for i in range(L+1):
        D[i] += (a>>i)&1
res = 0
flg = True
for i in reversed(range(L+1)):
    if flg == False:
        if D[i]<=N//2:
            res += (N-D[i])*pow(2,i)
        else:
            res += D[i]*pow(2, i)
    else:
        if D[i]<=N//2:
            if (K>>i)&1==1:
                res += (N-D[i])*pow(2, i)
            else:
                res += D[i]*pow(2, i)
        else:
            if (K>>i)&1==1:
                flg = False
            res += D[i]*pow(2, i)
mask = 0
for i in range(L+1,43):
    mask += 1<<i
for a in A:
    res += a&mask
print(res)

Measured memory_bytes: 86980
n=int(input())
p=[int(i) for i in input().split()]
ans=0
for i in range(1,n-1):
        count=0
        if p[i-1]<p[i]:
                count+=1
        if p[i]>p[i+1]:
                count+=1
        if count==1:
                ans+=1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = tuple<int,int>;
using node = tuple<int,int,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int h,w;
  vector<node> ans;
  int grid[510][510];
  cin >> h >> w;
  for(int i = 0;i < h;++i){
    for(int j = 0;j < w;++j){
      cin >> grid[i][j];
    }
  }
  
  vector< P > snake;
  for(int i = 0;i < h;++i){
    if(i % 2 == 0){
      for(int j = 0;j < w;++j){
        snake.push_back((P){i,j});
      }
    }else{
      for(int j = w-1;j >= 0;--j){
        snake.push_back((P){i,j});
      }
    }
  }
  
  for(int i = 1;i < (int)snake.size();++i){
    int fromy,fromx,toy,tox;
    tie(fromy,fromx) = snake[i-1];
    tie(toy,tox) = snake[i];
    if(grid[fromy][fromx] % 2 == 1){
      ans.push_back((node){fromy+1,fromx+1,toy+1,tox+1});
      --grid[fromy][fromx];
      ++grid[toy][tox];
    }
  }
  printf("%d\n", (int)ans.size());
  for(int i = 0;i < (int)ans.size();++i){
    int fromy,fromx,toy,tox;
    tie(fromy,fromx,toy,tox) = ans[i];
    printf("%d %d %d %d\n",fromy,fromx,toy,tox);
  }
  return 0;
}



Measured memory_bytes: 7152
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int i,j=0;
  cin>>s;
  for(i=1;i<=s.size();++i){
    if(i%2==1){
      if(s.at(i-1)=='R')j+=1;
      else if(s.at(i-1)=='U')j+=1;
      else if(s.at(i-1)=='D')j+=1;
    }
    else if(i%2==0){
      if(s.at(i-1)=='L')j+=1;
      else if(s.at(i-1)=='U')j+=1;
      else if(s.at(i-1)=='D')j+=1;
    }
    //cout<<j<<" ";
  }
  if(j==s.size())cout<<"Yes"<<endl;
  else if(j!=s.size())cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
int main()
{
	int a[3];
	a[0]=io::F(),a[1]=io::F(),a[2]=io::F();
	int ans=0x3f3f3f3f;
	for(register int x=0;x<=50;++x)
	{
		int now=0;
		for(register int i=0;i<=2;++i)
			if(a[i]<x)now+=(x-a[i]+1)/2+(x+a[i]&1);
				else now+=a[i]-x;
		cmin(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
def examA():
    N = I(); A = I()
    ans = "No"
    if N%500<=A:
        ans = "Yes"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

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

using namespace std;

int main() {
    //std::setを用いた解法
    int N;
    int d[110];
    cin >> N;
    for (int i=0; i<N; ++i) cin >> d[i];

    set<int> values;
    for(int i=0; i<N; ++i){
        values.insert(d[i]);
    }

    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	string str;
	cin>>str;
	int l=str.length();
	int ans=0;
	for(int i=1; i<l; i++){
		if(str[i-1]!=str[i]){
			ans++;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 512
# スペース区切りの整数の入力
N,M = map(int, input().split())
A_list=[]
food_list=[]

for i in range(N):
  A_list.append([int(e) for e in input().split()])

for i in range(M):
  food_list.append(0)
  
for i in range(N):
  K=A_list[i][0]
  for j in range(1,K+1):
    #print(A_list[i][j],end="")
    food_list[A_list[i][j]-1]+=1

ans=0
    
for i in range(M):
  if food_list[i]==N:
    ans+=1
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 20000

int main(){

  int i, j, n, flag, temp, count=0;
  int num[N];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &num[i]);
  }
  
  flag = 1;
  i = 0;
  while(flag){
    flag = 0;
    for(j=n-1; j>=i+1; j--){
      if(num[j] < num[j-1]){
	temp = num[j];
	num[j] = num[j-1];
	num[j-1] = temp;
	flag = 1;
	count++;
      }
    }
    i++;
  }

  for(j=0; j<n; j++){
    printf("%d", num[j]);
    if(j==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const double PI = 3.14159265358979;
const ll INF =  1e15 + 7;
const ll MOD = 998244353;
const ll nax = 500010;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		int h1, m1, h2, m2, k;
		cin >> h1 >> m1 >> h2 >> m2 >> k;

		int t1 = h1 * 60 + m1;
		int t2 = h2 * 60 + m2;

		int ans = t2 - t1 - k;
		if (ans < 0)
			ans = 0;
		cout << ans;
	}
	return 0;
}




















Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define modulo 924844033
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000




int main(){
	
	int N;
	cin>>N;
	
	vector<int> c(3,0);
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		c[a-1]++;
	}
	
	vector<vector<vector<double>>> dp(301,vector<vector<double>>(301,vector<double>(301,0.0)));
	
	for(int i=0;i<dp.size();i++){
		for(int j=0;j<dp.back().size();j++){
			for(int k=0;k<dp.back().back().size();k++){
				dp[i][j][k] = 0.0;
				if(i==0&&j==0&&k==0)continue;
				if(i+j+k>N)continue;
				if(k!=0){
					dp[i][j][k] += ((double)k/N)*dp[i][j][k-1];
				}
				if(k!=dp.back().back().size()-1&&j!=0){
					dp[i][j][k] += ((double)j/N)*dp[i][j-1][k+1];
				}
				if(j!=dp.back().size()-1&&i!=0){
					dp[i][j][k] += ((double)i/N)*dp[i-1][j+1][k];
				}
				dp[i][j][k] += 1.0;
				dp[i][j][k] /= 1.0 - ((double)N-i-j-k)/N;
			}
		}
	}
	
	cout<<fixed<<setprecision(12)<<dp[c[2]][c[1]][c[0]]<<endl;
	
    return 0;
}


Measured memory_bytes: 216960
#include <stdio.h>
#include <stack>

using namespace std;


//??¨??¬??????a,b????????????????????????????????¢??°
bool judge(int a, int b){
	int checkTable[26];
	for(int i=0;i<26;i++)checkTable[i] = 0;
	for(int i=0;i < 26;i++){
		if(checkTable[(a*i+b)%26] == 0){
			checkTable[(a*i+b)%26] = 1;
		}else{
			return false;
		}
	}
	return true;
}


int main(){
	int n,length,a,b;
	char buf[300],convert[26],s1,s2,s3,s4;
	bool FLG;

	scanf("%d",&n);
	getchar();
	for(int i=0;i<n;i++){
		fgets(buf,300,stdin);
		length = 0;
		FLG = false;
		//??????4?????????????????¢??????a,b?????????????????????
		for(int k=0;buf[k] != '\0';k++){
			if(buf[k] == ' '){
				if(length == 4){

					s1 = buf[k-4] - 97;
					s2 = buf[k-3] - 97;
					s3 = buf[k-2] - 97;
					s4 = buf[k-1] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1 && (7*a+p)%26 == s2 && (8*a+p)%26 == s3 && (18*a+p)%26 == s4){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}

					if(s1 == s4){
						//that??§??¨??¬
						a = -1;
						b = s3;
						for(int p=0;p<26;p++){
							if((19*p+b)%26==s1 && (7*p+b)%26==s2){
								a = p;
								if(judge(a,b)){
									FLG = true;
									break;
								}
							}
						}
						if(FLG){
							break;
						}
					}
				}
				length = 0;
			}else if(buf[k+1] == '\n' || buf[k+1] == '\0'){
				length++;
				if(length == 4){

					s1 = buf[k-3] - 97;
					s2 = buf[k-2] - 97;
					s3 = buf[k-1] - 97;
					s4 = buf[k] - 97;

					//this??§??¨??¬
					if(s1 > s4){
						a = s1 - s4;
					}else{
						a = (s1 + 26) -s4;
					}
					b = -1;
					for(int p=0;p<26;p++){
						if((19*a+p)%26==s1 && (7*a+p)%26 == s2 && (8*a+p)%26 == s3 && (18*a+p)%26 == s4){
							b = p;
							if(judge(a,b)){
								FLG = true;
								break;
							}
						}
					}
					if(FLG){
						break;
					}


					//that??§??¨??¬
					if(s1 == s4){
						a = -1;
						b = s3;
						for(int p=0;p<26;p++){
							if((19*p+b)%26==s1 && (19*p+b)%26 == s1 && (7*p+b)%26==s2){
								a = p;
								if(judge(a,b)){
									FLG = true;
									break;
								}
							}
						}
						if(FLG){
							break;
						}
					}
				}
				length = 0;
			}else{
				length++;
			}
		}

		//????????¨?????????
		for(int k = 0; k < 26;k++)convert[(a*k+b)%26] = k;

		for(int k=0;buf[k] != '\0';k++){
			if(buf[k]>=97 && buf[k] <= 122){
				buf[k] = convert[buf[k]-97]+97;
			}
		}
		printf("%s",buf);
	}

    return 0;
}

Measured memory_bytes: 2564
#include <cstdio>
using namespace std;

int main()
{
	int n;
	long ans = 1;
	
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++){
		ans *= i;
	}
	
	printf("%ld\n", ans);
	
	return (0);
}

Measured memory_bytes: 1020
#include <iostream>


using namespace std;


int main()
{
	int n, m;

	cin >> n >> m;

	int **box = new int*[n];
	for(int i = 0; i < n; i++)
		box[i] = new int[m];

	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> box[i][j];

	int *s_box = new int[m];
	for(int i = 0; i < m; i++)
		cin >> s_box[i];

	// 計算結果出力
	for(int i = 0; i < n; i++){
		int sum = 0;

		for(int j = 0; j < m; j++)
			sum += box[i][j] * s_box[j];

		cout << sum << endl;
	}

	return 0;
}


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

char mat[1010][1010];
long long dp[1010][1010];
long long mod = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> mat[i][j];
    
    for(int i = 0; i < n; i++) {if(mat[i][0] == '.') dp[i][0] = 1; else break;}
    for(int j = 0; j < m; j++) {if(mat[0][j] == '.') dp[0][j] = 1; else break;}
    for(int i = 1; i < n; i++)
    {
        for(int j = 1; j < m; j++)
        {
            if(mat[i][j] == '.')
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= mod;
        }
    }
    
    cout << dp[n-1][m-1];
    
    return 0;
}

Measured memory_bytes: 9216
import scala.io.StdIn

object Main {
  def main(args: Array[String]) {
    val arr: Array[String] = StdIn.readLine().split(" ")
    val stack: MyStack = new MyStack(1000)
    for(v <- arr) {
      calc(stack, v)
    }
    println(stack.pop())
  }

  def calc(stack: MyStack, v: String): Unit = {
    if(v != "+" && v != "-" && v != "*") {
      stack.push(v)
      return
    }

    val y = stack.pop.toInt
    val x = stack.pop.toInt

    if(v == "+") {
      stack.push((x + y).toString)
    } else if(v == "-") {
      stack.push((x - y).toString)
    } else {
      stack.push((x * y).toString)
    }
  }
}

class MyStack(n: Int) {
  val arr: Array[String] = Array.fill(n)("")
  var p = 0

  def pop(): String = {
    p -= 1
    val ret = arr(p)
    arr(p) = ""
    return ret
  }

  def push(v: String): Unit = {
    arr(p) = v
    p += 1
  }
}

Measured memory_bytes: 43808
def main():
    A,B,M=map(int, input().split())
    a=list(map(int, input().split()))
    b=list(map(int, input().split()))
    
    min_a = min(a)
    min_b = min(b)
    ans = min_a + min_b

    for _ in range(M):
        x,y,c=map(int, input().split())
        p = a[x-1] + b[y-1] - c
        if p < ans:
            ans = p
    print(ans)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 18736
/*******************************
* BASMILLAHHIR RAHMANNIR RAHIM *
* MD SHAHINUR RAHMAN           *
* DATE: 12/sep/2020            *
* DEPT. OF CSE                 *
* LEADING UNIVERSITY, SYLHET   *
*******************************/
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<math.h>
#define shahin std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax=1000*1007;
const int mod = 1e9 + 7;

using namespace std;
char wcz[nax];

bool fu(int a, int b){
    return (a>b);
}
 
void fun(){
   ll x;
   cin >> x ;
   if(x<=0)cout << 1 << endl;
   else cout << 0 << endl;
}
int main()
{
    shahin
  /*  ll tc,i=1;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/ 
    fun();
   
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, x, y;
    cin >> len >> x >> y;
    map<int, int> m;
    x--;
    y--;
    for(int i = 0; i < len; i++) {
        for(int j = i + 1; j < len; j++) {
            int dist = min(j - i, abs(i - x) + 1 + abs(j - y));
            m[dist]++;
        }
    }
    for(int i = 1; i < len; i++)
        cout << m[i] << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int maxn=100010;
int n,k,h[maxn],f[maxn];
const int inf=0x7fffffff;
void init(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	f[1]=0;
	for(int i=2;i<=n;i++) f[i]=inf;
	for(int i=2;i<=n;i++)
		for(int j=i-1;j>=max(1,i-k);j--)
			f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
	printf("%d",f[n]);
}
int main(){
	init(); 
	return 0;
}

Measured memory_bytes: 1024
// Koch Curve
// 問題URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
// 中央*右
// 
//

#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

typedef complex<double> xy_t;
const xy_t i( 0.0, 1.0 );

int N;
xy_t A(0.0, 0.0), B(100.0, 0);

void show_vertex(xy_t p){
    printf("%.8f %.8f\n",p.real(), p.imag());
}

void koch(xy_t p1, xy_t p2, int n){
    if(n == 0) show_vertex(p1);
    else{
        xy_t vec = p2 - p1;
        xy_t s = p1 + vec * 1.0/3.0;
        xy_t t = p1 + vec * 2.0/3.0;
        double theta = 60.0*M_PI/180.0;
        xy_t buff = vec * 1.0/3.0 * exp(i * theta);
        xy_t u = s + buff;

        koch(p1, s, n-1);
        koch(s, u, n-1);
        koch(u, t, n-1);
        koch(t, p2, n-1);
    }
}

int main(){
    cin >> N;

    koch(A, B, N);
    show_vertex(B);
}



Measured memory_bytes: 3224
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int N=Integer.parseInt(cin.nextLine());
			if(N==0)break;
			
			int[][] a = new int[N][2];
			for(int i=0;i<N;i++){
				String[] s =cin.nextLine().split(" ");
				int[] b = new int[s.length-1];
				a[i][0]=Integer.parseInt(s[0]);
				int frame=1;
				for(int j=1;j<s.length;j++){
					b[j-1]=Integer.parseInt(s[j]);
				}
				for(int j=0;j<b.length;){
					if(frame==10){
						a[i][1]+=b[j];
						j++;
						continue;
					}
					a[i][1]+=b[j]+b[j+1];
					if(b[j]==10){
						a[i][1]+=b[j+2];
						j++;
					}
					else{
						if(b[j]+b[j+1]==10){
							a[i][1]+=b[j+2];
						}
						j+=2;

					}
					frame++;
				}
//				System.out.println(a[i][1]);
			}
			Arrays.sort(a,new Comparator<int[]>(){
				public int compare(int[] a,int[] b){
					if(a[1]==b[1]){
						return a[0]-b[0];
					}
					return b[1]-a[1];
				}
			});
			
			for(int i=0;i<N;i++){
				System.out.println(a[i][0]+ " " + a[i][1]);
			}
		}
	}
	
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 10000000000000000

int main(){
	
	long long A,B;
	cin>>A>>B;
	
	cout<<max({A+B,A-B,A*B})<<endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin >> s >> t;
  vector<pair<char,char>> count(s.size());
  for(int i = 0;i < s.size();i++)count[i] = make_pair(s[i],t[i]);
  sort(count.begin(),count.end());
  //for(int i = 0;i < s.size();i++)cout << count[i].first << " " << count[i].second << endl;
  bool res = true;
  for(int i = 0;i < count.size() - 1;i++){
    if(count[i].first == count[i + 1].first){
      if(count[i].second != count[i + 1].second)res = false;
    }
  }
  for(int i = 0;i < s.size();i++)count[i] = make_pair(t[i],s[i]);
  sort(count.begin(),count.end());
  //for(int i = 0;i < s.size();i++)cout << count[i].first << " " << count[i].second << endl;
  for(int i = 0;i < count.size() - 1;i++){
    if(count[i].first == count[i + 1].first){
      if(count[i].second != count[i + 1].second)res = false;
    }
  }
  if(res)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4092
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void solve(){
	long a = read.to!long;
	long b = read.to!long;
	long c = read.to!long;
	long d = read.to!long;
	
	long m = (c / gcd(c, d)) * d;
	log("m:", m);
	
	long bx = b - b / c - b / d + b / m;
	long ax = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / m;
	log("ax:", ax, "bx:", bx);
	
	long ans = bx - ax;
	
	ans.writeln;
}

long gcd(long a, long b){
	if(a % b == 0) return b;
	if(a < b) return gcd(b, a);
	else return gcd(b, a % b);
}
long lcm(long a, long b){
	return (a / gcd(a, b) * b);
}



Measured memory_bytes: 256
<?php

$input = trim(fgets(STDIN));

$parts = explode(" ", $input);

$W = $parts[1];
$H = $parts[0];



echo str_pad("", $W+2,'#', STR_PAD_RIGHT);
echo "\n";

for ($i = 0;$i < $H; $i++)
{
    $input = trim(fgets(STDIN));
    echo str_pad($input, $W+2,'#', STR_PAD_BOTH);
echo "\n";

    
}

echo str_pad("", $W+2,'#', STR_PAD_RIGHT);
echo "\n";

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

using namespace std;

struct Card
{
    char c;
    int num;
    int t;
};

const int MAX = 100000;
Card cards[MAX];
    
int partition (Card v[], int p, int r)  
{  
    Card pivot = v[r];
    int i = (p - 1);
  
    for (int j = p; j < r; j++)  
        if (v[j].num <= pivot.num)
            swap(v[j], v[++i]);
   
    swap(v[++i], v[r]);
    return i;
}

void quicksort(Card v[], int p, int r)
{
    if(p < r)
    {
        int x = partition(v, p, r);
        
        quicksort(v, p, x-1);
        quicksort(v, x+1, r);
    }
}

int main() 
{
    int n, i;
    cin >> n;
    
    for(i = 0; i < n; i++)
    {
        cin >> cards[i].c >> cards[i].num;
        cards[i].t = i;
        
    }
    
    quicksort(cards, 0, n-1);
    bool cond = true;
    
    for(i = 0; i < n-1; i++)
    {
        if(cards[i].num == cards[i+1].num && cards[i].t > cards[i+1].t)
        {
            cond = false;
            break;
        }
    }
    
    if(cond)
        cout << "Stable\n";
    else
        cout << "Not stable\n";
    
    for(i = 0; i < n; i++)
        cout << cards[i].c << " " << cards[i].num << "\n";
    
    return 0;
}


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int d1, d2, d3, d4;
  
  cin >> a;
  d1 = a / 1000;
  a -= d1 * 1000;
  d2 = a / 100;
  a -= d2 * 100;
  d3 = a / 10;
  a -= d3 * 10;
  d4 = a;

  if ((d1 == d2 && d2 == d3) || (d2 == d3 && d3 == d4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
  string S; cin >> S;
  int alpha[26]={};
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
  }else if(S.size()!=26){
    for(int i=0; i<S.size(); i++){
      alpha[S[i]-'a']=1;
    }
    int count=0;
    while(1){
      if(alpha[count]==0){
        cout << S << (char)(count+'a') << endl;
        break;
      }
      count++;
    }
  }else{
    int count=25;
    while(1){
      if(S[count-1]<S[count])
        break;
      count--;
    }
    string Sfront=S.substr(0,count-1);
    string Sback=S.substr(count);
    sort(Sback.begin(),Sback.end());
    for(int i=0; i<Sback.size(); i++){
      if(Sback[i]>S[count-1]){
        Sback=Sback[i];
        break;
      }
    }
    cout << Sfront << Sback << endl;
  }
}

Measured memory_bytes: 256
import math

a,b,h,m=map(int,input().split())
asita= 2*math.pi*(h/12 + m/(12*60))
bsita= 2*math.pi*m/60
sita= min(abs(asita-bsita), 2*math.pi-abs(asita-bsita))

ans=(a**2 + b**2 - 2*a*b*math.cos(sita))**0.5
print(ans)

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

// ax + by = gcd(a, b) となる {x, y, gcd(a, b)} を返す
// O(log(min(a, b)))
ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a; x = 1, y = 0;
    if(b != 0) g = extgcd(b, a%b, y, x), y -= (a/b) * x;
    return g;
}

// a^-1 mod n を返す　存在しなければ-1
// O(log(n))
ll inv(ll a, ll n) {
    ll s, t;
    extgcd(a, n, s, t);
    return (n+s) % n;
}

// O(a.size*logM)
// 連立線形合同式 a[i] * x ≡ b[i] (mod m[i]) を解く
// オーバーフローには注意
pair<ll, ll> crt(const vector<ll>& a, const vector<ll>& b, const vector<ll>& m) {
    // (答えx, mod)
    pair<ll, ll> ret(0, 1);
    REP(i, a.size()) {
        ll s = a[i] * ret.second;
        ll t = b[i] - a[i] * ret.first;
        ll d = __gcd(m[i], s);
        if(t % d != 0) return make_pair(-1, -1);
        ll u = t / d * inv(s / d, m[i] / d) % (m[i] / d);
        ret.first += ret.second * u;
        ret.second *= m[i] / d;
        ret.first = (ret.first % ret.second + ret.second) % ret.second;
    }
    return ret;
}

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> a0(n, 1), b(a), mo(a);
    REP(i, n) b[i] /= 2;
    auto p = crt(a0, b, mo);
    if(p.first < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll l1 = 1, l2 = 1;
    REP(i, n) {
        l1 = l1 / __gcd(l1, a[i]/2) * (a[i]/2);
        l2 = l2 / __gcd(l2, a[i]) * a[i];
        if(l1 > m) break;
    }

    if(l1 > m) {
        cout << 0 << endl;
        return 0;
    }

    dump(l1, l2);
    cout << (m-l1)/l2+1 << endl;

    return 0;
}

Measured memory_bytes: 3456
n, k = map(int, input().split())
p_list = list(map(int, input().split()))

expected_list = [(x+1)/2 for x in p_list]

partsum = sum(expected_list[0:k])
maximum = partsum
for i in range(1, n-(k-1)):
    partsum = partsum + expected_list[i+k-1] - expected_list[i-1]
    maximum = max(maximum, partsum)
print(maximum)

Measured memory_bytes: 77448
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int N;
	cin >> N;
	while(N != 0){
		int Y, M, D;
		cin >> Y >> M >> D;
		int sum = 0;
		for(int i = Y;i < 1000;i++){
			if(i%3 == 0){
				for(int j = M;j <=10;j++){
					for(int k = D;k <= 20;k++){
						sum++;
					}
					D = 1;
				}
				M = 1;
			}
			else{
				for(int j = M;j <= 10;j++){
					if(j%2 == 1){
						for(int k = D;k <= 20;k++){
							sum++;
						}
						D = 1;
					}
					else if(j%2 == 0){
						for(int k = D;k <= 19;k++){
							sum++;
						}
						D = 1;
					}
				}
				M = 1;
			}	
		}
		cout << sum << endl;
		N--;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

signed main(){
	int ans = 0, n;
	scanf("%lld", &n);
	rrep(i,n){
		if(i%2 == 0)continue;
		int cnt = 0;
		rrep(j,i){
			if(i%j == 0)cnt++;
		}
		if(cnt == 8)ans++;
	}
	printf("%lld\n", ans);
	return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

bool ok(char c) {
  char a[] = {'A', 'C', 'G', 'T'};
  rep(i,0,3) {
    if (a[i] == c) return true;
  }
  return false;
}

int main() {
  string str;
  cin >> str;
  int max = 0, cnt = 0;;
  for (char c : str) {
    if (!ok(c)) {
      cnt = 0;
      continue;
    }
    cnt++;
    if (max < cnt) max = cnt;
  }

  cout << max << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  bool taka = true;

  while (true) {
    c -= b;
    if (c <= 0) {
      break;
    }
    a -= d;
    if (a <= 0) {
      taka = false;
      break;
    }
  }

  cout << (taka ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	int N, T, A, ans;
	double min = 1e9;
	cin >> N >> T >> A;
	for (int i = 0, H; i < N; i++) {
		cin >> H;
		double tmp = abs(T - H * 0.006 - A);
		if (tmp < min) {
			min = tmp;
			ans = i + 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	days := [12]int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	weekday := [7]string{"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"}

	for {
		var m, d int
		fmt.Scan(&m, &d)
		if m == 0 {
			break
		}

		for i := 0; i < m-1; i++ {
			d += days[i]
		}

		fmt.Println(weekday[d%7])
	}
}



Measured memory_bytes: 1136
import numpy as np

a,b=map(int,input().split())
ans=0

def check(x):
    s=str(x)
    for i in range(len(s)):
        if(s[i]!=s[len(s)-1-i]):return False
    return True

for i in range(a,b+1):
    if(check(i)):ans+=1
print(ans)

Measured memory_bytes: 12388
sp = gets.chomp
t = gets.chomp
rsp = sp.reverse
rt = t.reverse
r = rsp.gsub(/\?/, '.')
0.upto(sp.size - t.size) do |i|
  if Regexp.new(r[i..i+t.size-1]) =~ rt
    r[i..i+t.size-1] = rt
    puts r.gsub(/\./, 'a').reverse
    exit
  end
end
puts 'UNRESTORABLE'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

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

int main(){
	ll n, x, m;
	cin >> n >> x >> m;
	
	//{ll ans = x, sum = 0;
	//for(int i = 0; i < n-1; i++){
		//cout << ans << endl;
		//sum += ans;
		//ans = (ans * ans) % m;
	//}
	
	//cout << ans << endl;
	//sum += ans;
	//cout << ")) " << ' ' << sum << endl;}
	
	vector <ll> sum = {x};
	unordered_map <ll, int> s;
	s[x] = 0;
	
	ll ans = x;
	for(int i = 0; i < n-1; i++){
		ans = (ans * ans) % m;
		if(ans == 0)
			return cout << sum.back() << endl, 0;
		
		if(s.count(ans)){
			//cout << i << endl;
			//cout << ans << endl;
			ll summ = sum.back() - (s[ans]-1 >= 0 ? sum[s[ans] - 1] : 0);
			ll d = (n - 1 - s[ans]) / (len(sum) - s[ans]);
			
			ll res = d * summ;
			res += sum[s[ans] - 1];
			
			res += sum[s[ans] + (n - 1 - s[ans] - d * (len(sum) - s[ans]))];
			res -= sum[s[ans] - 1];
			cout << res << endl;
			return 0;
		}
		
		s[ans] = i+1;
		
		sum.pb(sum.back() + ans);
	}

	cout << sum.back() << endl;
	return 0;
}


Measured memory_bytes: 5644
#include<iostream>
#include<cmath>
#include<vector>

int main() {
  int input;
  bool flag = false;
  std::cin >> input;

  std::vector<int> number(3); 

  for(int i=0; i<3; i++) {
    number.at(i) = input/pow(10, 2-i);
    input -= number.at(i)*pow(10, 2-i);
  }

  for(int num:number) {
    if(num == 7) {
      flag = true;
      std::cout << "Yes" << std::endl;
      break;
    }
  }

  if(flag == false) std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 3848
def l(): return list(map(int, input().split()))
def m(): return map(int, input().split())

def main():
  c = [0]*3
  for i in range(3):
    c[i] = l()
  for i in range(2):
    x = c[2][i+1] - c[2][i]
    for j in range(2):
      if c[j][i+1] - c[j][i] != x:
        print('No')
        exit()
  print('Yes')

  
if __name__ == '__main__':
  main()

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
string S;

int main()
{
	cin >> S;
	N = S.size();

	map<char,int> mp;
	ll ans = 1;
	FOR(i,0,N){
		ans += i;
		ans -= mp [S [i]];
		mp [S [i]]++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
n = int(input())
p = [int(i) for i in raw_input().split()]
a = [0 for i in range(n)]
b = [0 for i in range(n)]
p.reverse()
for i in range(n):
	k = p.pop()
	a[k-1] = i + 1
	b[k-1] = i + 1
for i in range(1,n):
	d = min(a[i] - a[i-1],b[i-1] - b[i])
	if d <= 0:
		a[i] -= d - 1
		b[i] += d - 1
ma = min(a)
mb = min(b)
a = [str(i+1-ma) for i in a] 
b = [str(i+1-mb) for i in b]
print(" ".join(a))
print(" ".join(b))

Measured memory_bytes: 7108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;


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

	int a = N/2;
	int b = N % 2;
	
	if (b == 0) {
		cout << 0.5 << endl;
	}else{
		
		cout << (static_cast<double> (a) + 1)/ static_cast<double> (N) << endl;
		
	}

	
	return 0;
	
}


/*

for(int i = 0; i < N; i++){
	
}

for(int i = 0; i < N; i++){
	for(int j = 0; j < N; j++){
		
	}
}


*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string s;
    cin >> s;

    rep(i, (int)s.size() - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    rep(i, (int)s.size() - 2) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N = int(input())
dp = [0] * (N + 1)
dp[0] = 1
for i in range(N):
  for j in range(6):
    if i + j + 100 <= N:
      dp[i + j + 100] += dp[i]
if dp[-1]: print(1)
else: print(0)

Measured memory_bytes: 67292
N = int(input())
dp = [[[[0 for i in range(0, 4)] for j in range(0, 4)] for k in range(0, 4)] for l in range(0, 101)]

dp[0][3][3][3] = 1
for n in range(0, 100):
    for i in range(0, 4):
        for j in range(0, 4):
            for k in range(0, 4):
                for l in range(0, 4):
                    if dp[n][i][j][k] == 0:
                        continue

                    if (j == 0 and k == 2 and l == 1
                        or j == 0 and k == 1 and l == 2
                        or j == 2 and k == 0 and l == 1
                        or i == 0 and k == 2 and l == 1
                        or i == 0 and j == 2 and l == 1):
                        continue
                    dp[n+1][j][k][l] += dp[n][i][j][k]

ans = 0
for i in range(0, 4):
    for j in range(0, 4):
        for k in range(0, 4):
            ans += dp[N][i][j][k]
            ans %= pow(10, 9) + 7
print(ans)

Measured memory_bytes: 3444
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		char s[]=(" "+nextLine()).toCharArray();
		int freq[]=new int[128];
		for(int i=1;i<=n;i++)
			freq[s[i]]++;
		long ans=1l*freq['R']*freq['G']*freq['B'];
		for(int i=1;i<=n;i++)
		{
			for(int j=1;i-j>=1 && i+j<=n;j++)
				if(s[i]!=s[i-j] && s[i]!=s[i+j] && s[i-j]!=s[i+j])
					ans--;
		}
		out.println(ans);
	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();

		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 36724
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;
int main()
{
	double c = 1;
	double i, k;
	double N, K;
	double a;//勝つための回数
	double b;//現在の点数
	double x=0;//確率
	cin >> N >> K;
	for (i = 1; i < N+1; i++) {
		a = 0;
		b = i;
		while (b < K) {
			b = b * 2;
			a += 1.0;
		}
		x += (c / N)*(pow(0.5,a));
	}
	cout << std::setprecision(10)<<x;
}


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	ll N; cin >> N;
	ll A;
	map<ll, int> m;

	bool ans = true;

	rep(i, N) {
		cin >> A;
		m[A]++;
		if (m[A] > 1) {
			ans = false;
		}
	}

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 16144
#include <iostream>

using namespace std;

int main(){

    int N, x;
    cin >> N >> x;

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

    long long ans = 0;
    for (int i = 0; i < N - 1; i++){
        if (a[i] + a[i + 1] > x){
            ans += a[i] + a[i + 1] - x;
            a[i + 1] = max(0, x - a[i]);
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    abc = [list(map(int,input().split())) for _ in range(N)]
    abc.insert(0,[0,0,0])
    dp = [[0]*3 for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j],dp[i-1][k]+abc[i][j])
    print(max(dp[N]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 74328
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    if(n >= k * 2 - 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

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

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

    long long x = 0;
    for(int i = 0; i < n; i++){
        if(i % 2) x -= A[i];
        else x += A[i];
    }

    long long bef = x;
    for(int i = 0; i < n; i++){
        cout << bef << ' ';
        bef = (A[i] - bef / 2) * 2;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2176
use std::cmp;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let x: i64 = sc.read();
    let mut cur = 1;
    let mut ans = 1e10 as i64;
    for _ in 0..10 {
        let t = (x / cur) % 1000;
        if t >= 100 {
            ans = cmp::min(ans, (753 - t).abs());
        }
        cur *= 10;
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(void){
  int i;
  char s[100001];
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    if(s[i]==s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
  }
  for(i=0;i<strlen(s);i++){
    if(s[i]==s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }
  printf("-1 -1\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5,MAX_M=1e5;
ll N,M;
typedef pair<ll,ll> P;
P work[MAX_N];
ll bef[MAX_M+1];
ll fndbef(ll n){
	if(n==-1 || n==bef[n])return n;
	return bef[n]=fndbef(bef[n]);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	REP(i,N){
		ll a,b;
		cin>>a>>b;
		work[i]=P(b,a);
	}
	REP(i,M+1)bef[i]=i;
	sort(work,work+N);
	reverse(work,work+N);
	ll ans=0;
	REP(i,N){
		if(M-work[i].second<0)continue;
		ll b=fndbef(M-work[i].second);
		if(b!=-1){
			ll b2=b-1;
			b2=fndbef(b2);
			bef[b]=b2;
			ans+=work[i].first;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
int A[250];
void parent(int pk){
  if((pk/2)>0){
    printf("parent key = %d, ",A[pk/2]);
  }
}
void left(int lk){
  if(A[lk*2]!=NIL){
    printf("left key = %d, ",A[lk*2]);
  }
}
void right(int rk){
  if(A[rk*2+1]!=NIL){
    printf("right key = %d, ",A[rk*2+1]);
  }
}
int main(){
  int h, i, j;

  scanf("%d", &h);

  for ( i = 1; i <= h; i++ ){
    scanf("%d", &A[i]);
  }
  for ( j = 1; j <= h; j++ ){
    printf("node %d: key = %d, ",j,A[j]);
    parent(j);
    left(j);
    right(j);
    printf("\n"); 
  }
  return 0;
}



Measured memory_bytes: 2048
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] D = new int[N];
        for(int i = 0; i < N; i++)
            D[i] = sc.nextInt();
        int M = sc.nextInt();
        int[] T = new int[M];
        for(int i = 0; i < M; i++)
            T[i] = sc.nextInt();
        sc.close();

        Arrays.sort(D);
        Arrays.sort(T);

        int idx_D = 0;
        int idx_T = 0;
        while(idx_D < N){
            if(idx_T == M)
                break;
            if(D[idx_D] == T[idx_T]){
                idx_T++;
            }
            idx_D++;
        }
        if(idx_T == M)
            System.out.println("YES");
        else
            System.out.println("NO");
   }
}

Measured memory_bytes: 93400