akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int Maxn = 100010;

bool dp[Maxn];

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

    dp[0] = true;
    REP(i,0,n){
        if (dp[i] == false) continue;

        if (i + 5 <= n && s.substr(i, 5) == "dream") dp[i + 5] = true;
        if (i + 5 <= n && s.substr(i, 5) == "erase") dp[i + 5] = true;
        if (i + 7 <= n && s.substr(i, 7) == "dreamer") dp[i + 7] = true;
        if (i + 6 <= n && s.substr(i, 6) == "eraser") dp[i + 6] = true;
    }
    
    cout << (dp[n]?"YES":"NO") << endl;

    return 0;
}

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

int main()
{

string s,t;
cin>>s>>t;
int ans=INT_MAX;
for(int i=0;i<=s.length()-t.length();i++)
{
   int count=0;
   for(int j=i;j<i+t.length();j++)
    {
      if(s[j]!=t[j-i])
        count++;
    }

    ans=min(ans,count);
}
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
int main(void)
{
	ll N;
	int v[50];
	double ans;
	cin>>N;
	rep(i,N) cin>>v[i];
	sort(v,v+N);
	ans=v[0];
	rep(i,N-1){
		ans=(ans+v[i+1])/2.0;
	}
	cout<<ans<<endl;
    return 0;
}



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

int main(){
    int a, b, kazu = 0;
    scanf("%d %d", &a, &b);

    int n;
    if(b>=100){
        n = 1000;
    }
    else if (b >= 10){
        n = 100;
    }else{
        n = 10;
    }

    kazu = b + a * n;
    

    //printf("%d", kazu);

    /*double N;
    N = sqrt(kazu);
    printf("%lf", sqrt(kazu));
    */

    int kazu_sqrt = sqrt(kazu);
    // printf("%d", kazu_sqrt);
    if(kazu_sqrt*kazu_sqrt==kazu){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        n -= a;
        if (n < 0) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 3624
import math
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    else:
        if m==-1 or f==-1:
            print('F')
        elif m+f>=80:
            print('A')
        elif m+f>=65:
            print('B')
        elif m+f>=50:
            print('C')
        elif m+f>=30:
            if r>=50:
                print('C')
            else:
                print('D')
        else:
            print('F')


Measured memory_bytes: 5652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	long long x;
	cin >> x;

	long long a = x / 11;
	long long b = a * 11;
	long long c = x - b;
	long long d = x % 11;

	if (c != 0 && c < 7) {
		cout << 2 * a + 1 << endl;
	}
	else if (c == 0) {
		cout << a * 2 << endl;
	}
	else {
		cout << 2 * a + 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	  ll n;
      cin>>n;
      ll ar[n];
      for(int i=0;i<n;i++)
      {
        cin>>ar[i];
      }
      sort(ar,ar+n,greater<int>());
      ll su = ar[0];
      ll point = 1;
      if(n>2)
      {
      	 for(int i=2;i<n;i++)
      	 {
      	 	if(i%2==0 && i>2)
      	 	{
      	 		point+=1;
      	 	}
      	 	su+=(ar[point]);
      	 }
      }
      cout<<su<<"\n";
}

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

using namespace std;

const int INF = 1e9+5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n;
    cin>>n;
    vector<int>h(n),dp(n,INF);
    for(int i=0; i<n; i++)cin>>h[i];
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(auto step:{1,2}){
            if(i+step<n){
                dp[i+step]=min(dp[i+step],dp[i]+abs(h[i]-h[i+step]));
            }
        }
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 3952
import Data.List
import Control.Monad

f ::[Int]->Int->[Int]
f [] _=[]
f (x:xs) d=(x-d):f xs d

f2 ::[Int]->[Int]
f2 []=[]
f2 (x:[])=[x]
f2 (x:y:xs)=(y-x):f2 (y:xs)

f3 :: [Int]->Int->Int
f3 [] ans= ans
f3 (x:xs) y=f3 xs (gcd x y)

main = do
       a<-getLine
       b<-getLine
       let (n:x:[])=map read . words $ a::[Int]
           xs=sort $ map read . words $ b::[Int]
           ys=(f2 $ f xs x)
       putStrLn $ show $ f3 ys (head ys)

Measured memory_bytes: 39804
/*
ID: jerrywcy
TASK: AtCoder Beginner Contest 107 Problem A
LINK: https://abc107.contest.atcoder.jp/tasks/abc107_a
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int n,i;

int main()
{
	cin>>n>>i;
	cout<<n+1-i<<endl;

	return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())

    ans = f(N)
    print(ans)


def f(N):
    for f in range(25+1):
        for s in range(14+1):
            if (f * 4 + s * 7) == N:
                return "Yes"

    return "No"


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/* 142a */
#include<stdio.h>
int main(void){
  int n;
  double a;
  scanf("%d",&n);
  if(n%2!=0){
    a=(n+1)/(2*((double)n));
    printf("%3.10f\n",a);
      }
  if(n%2==0){
    printf("0.5000000000\n");
      }
  return 0;
  }


Measured memory_bytes: 128
#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};

int main() {
  ll n;
  cin >> n;
  Vi to(n),num(n);
  rep(i,n){
    int x,y;
    cin >> x >> y;
    x--;y--;
    to[x]=y;
    num[x]=i;
  }
  ll mn=n;
  UnionFind uf(n);
  rep(i,n){
    ll x=to[i];
    chmin(mn,x);
    if(mn!=n-i-1&&i!=n-1){
      uf.unite(i,i+1);
    }
  }
  Vi ans(n);
  rep(i,n){
    int x=uf.size(i);
    int y=num[i];
    ans[y]=x;
  }
  rep(i,n) cout << ans[i] << endl;
    
}


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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int score = 0;
    for (int i=0;i<N-1;i++){
        if (S[i] == S[i+1]) score++;
    }
    int ans = min(score+2*K, N-1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=2e3+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll ans[MAXN];
int main()
{
    int n,x,y;cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            ans[min(j-i,abs(x-i)+abs(y-j)+1)]++;
        }
    }
    for(int i=1;i<n;i++)
    {
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long double x1,y1,x2,y2,x3,y3,x4,y4;
	int n;
	cin>>n;
	int N[100];
for(int i=0;i<n;i++)
{
	cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
	if((y1-y2)/(x1-x2)==(y3-y4)/(x3-x4))
	{
	N[i]=1;
	}
	else
	{
	N[i]=0;
	}
}
for(int j=0;j<n;j++)
{
	if(N[j]==1)
	{
		cout<<"YES"<<endl;
	}
	else if(N[j]==0)
	{
		cout<<"NO"<<endl;
	}
}
return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <cmath>

using namespace std;

int N,lg,lg_initial,nr0;
int nr[11],sol[11],a[4];


inline bool valid(int K)
{
    if(nr[a[1]] == lg_initial || nr[a[2]] == lg_initial || nr[a[3]] == lg_initial)
        return false;
    if(K > lg)
    {
        int X = 0;
        for(int i = 1; i < K; ++i)
            X = X * 10 + sol[i];
        if(X > N)
            return false;
    }
    return true;
}

void bt(int K)
{
    if(valid(K))
        ++nr0;
    if(K <= lg)
        for(int i = 1; i <= 3; ++i)
            if(nr[a[i]])
            {
                nr[a[i]]--;
                sol[K] = a[i];
                bt(K + 1);
                nr[a[i]]++;
            }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> N;
    lg = int(log10(N) + 1);
    lg_initial = lg - 2;
    a[1] = 3,a[2] = 5,a[3] = 7;
    nr[a[1]] = nr[a[2]] = nr[a[3]] = lg_initial;

    bt(1);
    cout << nr0;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

typedef struct{ 
    int array[100]; 
}abc; 



int main() {

  int N;
  cin>>N;
  int b[N];
  FOR(i,0,N-1){
    cin>>b[i];
  }
  ll ans[N];

  FOR(i,0,N-1){
    ll flag=-1;
    ll cnt=0;
    FOR(j,0,N-1){
      if(b[j]!=-1)cnt++;
      if(b[j]==(cnt)){
        flag=j;
        //cout<<"!"<<endl;
      }
      //cout<<b[j]<<"!"<<cnt<<endl;
    }
    if(flag!=-1){
      ans[i]=b[flag];
      b[flag]=-1;
      //cout<<"ans"<<ans[i]<<endl;
      //cout<<"flag"<<flag<<endl;
      //cout<<b[flag]<<endl;
    }else{
      //cout<<b[0]<<endl;
      //cout<<b[1]<<endl;
      //cout<<b[2]<<endl;
      cout<<"-1"<<endl;
      return 0;
    }
  }
  
  FOR(i,0,N-1){
      cout<<ans[N-1-i]<<endl;

    
  }

  return 0;
}
 


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());
        int C = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());

        int sum = 0;
        for (int a = 0; a <= A; a++)
            for (int b = 0; b <= B; b++)
                for (int c = 0; c <= C; c++)
                    if (500 * a + 100 * b + 50 * c == X)
                        sum++;
        Console.WriteLine(sum);
    }
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 

using namespace std;
typedef long long lint;
typedef long double ldb;
typedef unsigned long long uli;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define I(i, a) for(auto i : a)
#define pb push_back
#define rs resize
#define mk make_pair
#define asg assign
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define era erase
#define fi0(x) memset(x, 0, sizeof(x))
#define finf(x) memset(x, 127, sizeof(x))
#define acpy(y, x) memcpy(y, x, sizeof(y))
#define y1 adjf
#define tm dhgdg

const int MAXN = 2e5 + 5;

lint pref[MAXN];
int a[MAXN];
int n, k;
set<lint> aa;
int t[MAXN];
int ci = 1;
map<lint, int> lol;

void upd(int pos){
	while(pos <= ci){
		t[pos]++;
		pos += pos&-pos;
	}
}

int get(int r){
	int ans = 0;
	while(r > 0){
		ans += t[r];
		r -= r&-r;
	}
	ret ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	scanf("%d%d", &n, &k);
	F(i, 0, n)scanf("%d", &a[i]);
	F(i, 0, n){
		pref[i] = a[i] - k;
		if(i > 0)pref[i] += pref[i - 1];
		aa.ins(pref[i]);
	}
	aa.ins(0);
	I(c, aa)lol[c] = ci++;
	fi0(t);
	upd(lol[0]);
	lint ans = 0;
	F(i, 0, n){
		ans += get(lol[pref[i]]);
		upd(lol[pref[i]]);
	}
	printf("%lld", ans);
	ret 0;
}



Measured memory_bytes: 25216
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int i;
    for(i=N; i<1000; i++){
        if(i/100==i%100/10 && i/100==i%10){
            cout << i;
            return 0;
        }
    }

    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void Sort(int*, int*, int);

int main(){
  int i;
  int n;

  scanf("%d",&n);

  int A[n],B[n];

  for(i=0;i<n;i++){
    scanf(" %d",&A[i]);
  }

  Sort(A,B,n);

  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);

  return 0;
}

void Sort(int *A,int *B,int k){
  int i,j,max;
  
  max=A[0];
  for(i=1;i<k;i++){
    if(max<A[i])max=A[i];
  }

  int C[max+1];
  for(i=0;i<=max;i++){
    C[i]=0;
  }

  for(j=0;j<k;j++){
    C[A[j]]++;
  }

  for(i=1;i<=max;i++){
    C[i] = C[i] + C[i-1];
  }

  for(j=k-1;j>=0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    
  }

}



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

void solve() {
  int n;
  int64_t k;
  cin >> n >> k;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  auto pos_left = lower_bound(a.begin(), a.end(), 0);
  auto rpos_left = make_reverse_iterator(pos_left);
  auto pos_right = upper_bound(pos_left, a.end(), 0);
  auto rpos_right = make_reverse_iterator(pos_right);

  auto pos_cnt = a.end() - pos_left;
  auto neg_cnt = n - pos_cnt;
  auto non_zero_pos_cnt = a.end() - pos_right;
  auto zero_cnt = pos_cnt - non_zero_pos_cnt;

  constexpr int64_t limit = 1'000'000'000LL;
  int64_t left = -limit * limit;
  int64_t right = limit * limit + 1;
  while (left <= right) {
    int64_t lcnt = 0;
    int64_t ucnt = 0;
    auto mid = left + (right - left) / 2;

    if (mid == 0) {
      lcnt = neg_cnt * non_zero_pos_cnt;
      ucnt = lcnt;
      for (int i = 0; i < zero_cnt; ++i) {
        ucnt += n - 1 - i;
      }
    } else if (mid < 0) {
      for (auto it = a.begin(); it != pos_left; ++it) {
        auto lit =
            lower_bound(a.rbegin(), rpos_right, mid / *it, greater<int64_t>{});
        auto uit =
            lower_bound(lit, rpos_right, (mid + 1) / *it, greater<int64_t>{});
        lcnt += lit - a.rbegin();
        ucnt += uit - a.rbegin();
      }
    } else {
      for (auto it = rpos_left; it != a.rend(); ++it) {
        auto lit =
            upper_bound(rpos_left, it, (mid - 1) / *it, greater<int64_t>{});
        auto uit = upper_bound(lit, it, mid / *it, greater<int64_t>{});
        lcnt += non_zero_pos_cnt + lit - rpos_left;
        ucnt += non_zero_pos_cnt + uit - rpos_left;
      }
      for (int i = 0; i < zero_cnt; ++i) {
        lcnt += n - 1 - i;
        ucnt += n - 1 - i;
      }
      for (auto it = pos_right; it != a.end(); ++it) {
        auto lit = upper_bound(it + 1, a.end(), (mid - 1) / *it);
        auto uit = upper_bound(lit, a.end(), mid / *it);
        lcnt += lit - it - 1;
        ucnt += uit - it - 1;
      }
    }
    if (k <= lcnt) {
      right = mid;
    } else if (ucnt < k) {
      left = mid + 1;
    } else {
      cout << mid << endl;
      return;
    }
  }
  assert(false);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1024
K = int(input())
i = 1

if K % 5 == 0 or K % 2 == 0:
    i = -1
N = 0
while True:
    if i == -1:
        break
    N = (N * 10 + 7)  %K 
    if N % K != 0:
        i += 1
    else:
        break
print(i)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;

    int ans = 0;
    int c = 0;
    for(int i = 0; i < sz(s); i++){
        if(s[i] == 'R'){
            c++;
        }else{
            ans = max(ans , c);
            c = 0;
        }
    }
    ans = max(ans , c);
    cout<<ans;
}

Measured memory_bytes: 3648
#include<stdio.h>
int N,SS[400010],NN=1e9;
int hyouka(int a,int b){return a<b?a:b;}
void ssset(int n,int *d){
	int i;
	for(N=1;N<n;N*=2);
	for(i=0;i<n;i++)SS[i+N]=d[i];
	for(   ;i<N;i++)SS[i+N]=NN;
	for(i=N-1;i;i--)SS[i]=hyouka(SS[i*2],SS[i*2+1]);
}
//[l,r)?????????x??????????????????i??????????????????[a,b)
//ssud(l,r,x,1,0,N);
int ssud(int l,int r,int x,int i,int a,int b){
	int t;
	if(b<=l||r<=a)return SS[i];
	if(l<=a&&b<=r)return SS[i]+=x;
	t=hyouka(ssud(l,r,x,i*2,a,(a+b)/2),ssud(l,r,x,i*2+1,(a+b)/2,b));
	SS[i*2  ]-=t;
	SS[i*2+1]-=t;
	return SS[i    ]+=t;
}
//[l,r)????????????????????????i??????????????????[a,b)
//ssout(l,r,1,0,N);
int ssout(int l,int r,int i,int a,int b){
	if(r<=a||b<=l)return 0;
	if(l<=a&&b<=r)return SS[i];
	return ssout(l,r,i*2,a,(a+b)/2)+ssout(l,r,i*2+1,(a+b)/2,b)+SS[i];
}
int main(){
	int n,m,d[100010],i,a,b,c,q;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)d[i]=0;
	ssset(n,d);
	while(m--){
		//for(i=1;i<N*2;i++)printf("%d %d\n",i,SS[i]);printf("\n");fflush(stdout);
		scanf("%d",&q);
		if(q){
			scanf("%d",&a);
			printf("%d\n",ssout(a-1,a,1,0,N));
		}
		else{
			scanf("%d %d %d",&a,&b,&c);
			ssud(a-1,b,c,1,0,N);
		}
	}
	return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n, m;
	cin >> n >> m;
	int ans = 1;
	range(i, 1, sqrt(m) + 1) {
		if (m%i == 0) {
			int j = m / i;
			if (i >= n&&ans < j)ans = j;
			if (j >= n&&ans < i)ans = i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)

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

    vector<pair<int,int>> arms;
    rep(i,0,n){
        int x,l;
        cin>>x>>l;
        arms.push_back(make_pair(x+l,x-l));
    }
    sort(arms.begin(),arms.end());

    int64_t max_x=-1e10;
    int removed_arms=0;
    for(auto arm:arms){
        if(arm.second>=max_x) max_x=arm.first;
        else removed_arms++;
    }

    cout<<n-removed_arms<<endl;
}

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

int main() {
 
	int a, b;
	
	cin >> a >> b;
	
	int ans = 0;
	if ((a > 0 && a < 10) && (b > 0 && b < 10)) {
		ans = a * b;
	} else {
		ans = -1;
	}
	cout << ans << endl;
      return 0;
}

Measured memory_bytes: 256
using System;
//using System.Linq;
//using System.Collections;
//using System.Collections.Generic;


namespace ABC171
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string a = "";
            string c = Console.ReadLine();
            if(c == c.ToLower())
            {
                a = "a";
            }
            else
            {
                a = "A";
            }

            Console.WriteLine(a);

        }
    }
}

Measured memory_bytes: 26212
import java.util.*;

public class Main{
    /**
     * メインメソッド
     */
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        final String S = sc.next();
        final int answer = weatherReport(S);
        System.out.println(answer);
    }

    /**
     * ロジック
     */
    public static int weatherReport(String S) {
        if (S.matches("R{3}")){
            return 3;
        } else if (S.matches(".*R{2}.*")) {
            return 2;
        } else if (S.matches(".*R.*")) {
            return 1;
        } else {
            return 0;
        }
    }
}

Measured memory_bytes: 35420
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  vector<int> a(n);
  int s = 0;
  for (auto &i : a) {
    cin >> i;
    s += i;
  }
  sort(all(a));
  if (a[n - 1] * 2 < s) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


class Combination{
    public:
        Combination(long long N, long long MOD) : fact(N), inv(N), finv(N), N(N), MOD(MOD){
            init();
        }

        void init(){
            fact[0] = fact[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for(long long i = 2; i < N; ++i){
                fact[i] = fact[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
            }
        }

        long long com(long long n, long long r){
            if(n < r || n < 0 || r < 0) return 0;
            return fact[n] * (finv[r] * finv[n - r] % MOD) % MOD;
        }

    private:
        vector<long long> fact;
        vector<long long> inv;
        vector<long long> finv;
        const long long N;
        const long long MOD;
};


const int MOD = (int)(1e9 + 7);
int N, M;
vector<int> prime;


signed main(){
    cin >> N >> M;
    int m = M;
    int sq = (int)ceil(sqrt(M));
    FOR(i, 2, sq + 1){
        int j = 0;
        while(m % i == 0){
            m /= i;
            j++;
        }
        if(j > 0) prime.push_back(j);
    }
    if(m > 1) prime.push_back(1);
    Combination c(200000, MOD);
    ll ans = 1;
    for(int i : prime){
        ans = ans * c.com(N - 1 + i, i) % MOD;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll m;
string S,T;
ll d;
ll M = 1000000007;
vector<ll> fac(5000001); //n!(mod M)
vector<ll> ifac(5000001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

//ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//    ll ans = 1;
//    while(n != 0){
//        if(n&1) ans = ans*x % M;
//        x = x*x % M;
//        n = n >> 1;
//    }
//    return ans;
//}
//
//ll comb(ll a, ll b){ //aCbをmod計算
//    if(a == 0 && b == 0)return 1;
//    if(a < b || a < 0)return 0;
//    ll tmp = ifac[a-b]* ifac[b] % M;
//    return tmp * fac[a] % M;
//}
int main() {
    cin >> S>>T;
    N = S.size();
    for(int i=0;i<N;i++){
        if(S[i]!=T[i]){
            K++;
        }
    }
    cout << K << endl;
    
    }


Measured memory_bytes: 82020
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		long sum[] = new long[N + 1];
		int A[] = new int[N + 1];
		A[1] = Integer.parseInt(sc.next());
		sum[0] = 0;
		sum[1] = A[1];
		map.put((int)(sum[1] % M), 1);
		for(int i = 2; i <= N; i++) {
			A[i] = Integer.parseInt(sc.next());
			sum[i] = sum[i - 1] + A[i];
			int mod = (int)(sum[i] % M);
			if(map.containsKey(mod)){
				map.put(mod, map.get(mod) + 1);
			} else {
				map.put(mod, 1);
			}
		}
		
		long ans = 0;
		Iterator<Map.Entry<Integer, Integer>> it = map.entrySet().iterator();
		while(it.hasNext()) {
			Map.Entry<Integer, Integer> mapEntry = it.next();
			long temp = 0;
			if(mapEntry.getKey() == 0) {
				for(long i = mapEntry.getValue(); i > 0; i--) {
					temp += i;
				}
			} else {
				for(long i = mapEntry.getValue() - 1; i > 0; i--) {
					temp += i;
				}
			}	
			if(temp != 0 || mapEntry.getKey() == 0) {
				ans += temp;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 48948
lis1=list(map(int,list(input('').split(' '))))
n=lis1[0]
m=lis1[1]
lis=list(map(int,list(input('').split(' '))))
sum=0 
count=0
for i in range(n) :
  sum+=lis[i]
  
for i in range(n):
  if(lis[i]>=sum/(4*m)):
    count+=1
if count>=m :
  print("Yes")
else :
  print("No")
  
  
         

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

int main(){
    bool table[4][14] = {0};
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        int num,f;
        cin >> c >> num;
        if(c == 'S') f = 0;
        if(c == 'H') f = 1;
        if(c == 'C') f = 2;
        if(c == 'D') f = 3;
        table[f][num] = 1;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 1; j < 14; j++){
            if(!table[i][j]){
                if(i == 0) cout << "S " << j << endl;
                if(i == 1) cout << "H " << j << endl;
                if(i == 2) cout << "C " << j << endl;
                if(i == 3) cout << "D " << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma comment(linker, "/STACK:2000000000")

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

class Mo {
public:
  Mo(int n, int q) : bucket_size((int)sqrt(n)), query_idx(q), in(n) {
    for (int i = 0; i < q; ++i) query_idx[i] = i;
  }

  // [l, r)
  void push(int l, int r) {
    left.emplace_back(l);
    right.emplace_back(r);
  }

  void run() {
    std::sort(begin(query_idx), end(query_idx), [&](int i, int j) {
      if (left[i] / bucket_size != left[j] / bucket_size)
        return left[i] < left[j]; // 違うバケットにいたら
      else if (left[i] / bucket_size % 2 == 0)
        return right[i] < right[j]; // 同じバケットにいたら
      return right[i] > right[j];
    });
    int nl = 0, nr = 0;
    for (int idx : query_idx) {
      while (nl > left[idx]) move(--nl);
      while (nr < right[idx]) move(nr++);
      while (nl < left[idx]) move(nl++);
      while (nr > right[idx]) move(--nr);
      solve(idx);
    }
  }

private:
  int bucket_size;
  std::vector<int> left, right, query_idx;
  std::vector<bool> in;
  void move(int idx) {
    in[idx].flip();
    if (in[idx])
      insert(idx);
    else
      erase(idx);
  }

  // 問題ごとに変える
  void insert(int idx);
  void erase(int idx);
  void solve(int idx);
};

// ---- mo 用 ----
vector<int> cnt(500001), a, ans;
int num_kind = 0;

void Mo::insert(int idx) {
  if (cnt[a[idx]] == 0) ++num_kind;
  ++cnt[a[idx]];
}

void Mo::erase(int idx) {
  if (cnt[a[idx]] == 1) --num_kind;
  --cnt[a[idx]];
}

void Mo::solve(int idx) { ans[idx] = num_kind; }
// ----

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q, l, r;
  cin >> n >> q;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  Mo mo(n, q);
  for (int i = 0; i < q; i++) {
    cin >> l >> r;
    mo.push(l - 1, r);
  }
  ans.resize(q);

  mo.run();
  for (int i = 0; i < q; i++) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 15672
url = "https://atcoder.jp//contests/abc107/tasks/arc101_a"

def main():
    n, k = list(map(int, input().split()))
    xs = list(map(int, input().split()))
    ans = 100000000000000
    se = [0, k-1]
    while se[1] < n:
        if xs[se[0]] < 0 <= xs[se[1]]:
            tmp = min(abs(xs[se[0]]), xs[se[1]]) * 2 + max(abs(xs[se[0]]), xs[se[1]])
            ans = min(ans, tmp)
        elif xs[se[0]] < 0:
            ans = min(ans, abs(xs[se[0]]))
        elif xs[se[1]] >= 0:
            ans = min(ans, xs[se[1]])
        se = [v + 1 for v in se]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20424
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static void Main(string[] args) {
        var input = Console.ReadLine();
        string[] S = new string[input.Length];
        for(int i = 0;i < input.Length ;i++){
            S[i] = input[i].ToString();
        }
        LowerBound(S);
    }
    
    public static void LowerBound(string[] S) {
        var N = S.Length;
        for(int i = 0;i < Math.Pow(2,N-1);i++){
            var res = int.Parse(S[0]);
            var ans = S[0];
            for(int j = 1;j <　N ;j++){
                int bit = (int) Math.Pow(2,j-1);
                if((i&bit) != 0){
                    res += int.Parse(S[j]);
                ans = String.Concat(ans,String.Concat("+",S[j]));
                }else{
                    res -= int.Parse(S[j]);
                    ans = String.Concat(ans,String.Concat("-",S[j]));
                }
            }
            if(res == 7){
                Console.WriteLine(ans+"=7");
                break;
            }
        }
         }
             
     }


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> arr(n);
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    int current = arr[0];
    long int ans = 0;
    for(int i=1;i<n;++i){
        if(arr[i]>current){
            current = arr[i];
        }else{
            ans += (current-arr[i]);
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int n;
  cin >> n;
  string str;
  vector<string> s(n);
  for(int i = 0; i < n; i++) {
    cin >> str;
    sort(str.begin(),str.end());
    s.at(i) = str;
  }
  sort(s.begin(),s.end());
  int64_t ans = 0, wk_ans = 0;
  string tmp;
  for(int i = 0; i < n; i++){
    if(tmp == s.at(i)) wk_ans++;
    else{
      if(wk_ans != 0) {
        wk_ans++;
        ans += (wk_ans)*(wk_ans-1)/2;
        wk_ans = 0;
      }
    }
    tmp = s.at(i);
  }
  if(wk_ans != 0) {
    wk_ans++;
    ans += (wk_ans)*(wk_ans-1)/2;
  }
  cout << ans;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N,K;
	cin>>N>>K;
	vector<int> a(N);
	rep(i,0,N) cin>>a[i];
	
	int res=0;
	rep(l,0,N+1) rep(r,0,N+1) rep(p,0,N+1) {
		if (l+r>N || p>=l+r || l+r+p>K) continue;
		
		int sum=0;
		priority_queue<int> q;
		rep(i,0,N) if (i<l || N-r<=i) {
			sum+=a[i];
			q.emplace(-a[i]);
		}
		
		//~ cerr<<l+r<<" "<<sz(q)<<endl;
		
		rep(i,0,p) {
			sum+=q.top();
			q.pop();
		}
		
		res=max(res,sum);
	}
	cout<<res<<"\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static long mod = 998244353;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = sc.nextInt();
        long[] next = new long[s+1];
        next[0] = 1;



        for(int i=0; i<n; i++) {
            int a = sc.nextInt();
            long[] prev = next;
            next = new long[s+1];

            for(int j=0; j<=s; j++) {
                next[j] += prev[j] *2;
                next[j] %= mod;
                int num = j + a;
                if(num > s) continue;
                next[num] += prev[j];
                next[num] %= mod;
            }
        }

        System.out.println(next[s]);
    }



}


Measured memory_bytes: 54612
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int N;
  string s, t;
  cin >> N >> s >> t;
  
  if (N == 1) {
    if (s == t) {
      cout << 1 << endl;
    } else {
      cout << 2 << endl;
    }
  } else {
    int kaburi = N;
    for (int i = 0; i < N; i++) {
      if (s.substr(i, kaburi) == t.substr(0, kaburi)) {
        break;
      } else {
        kaburi--;
      }
    }
    cout << 2*N - kaburi << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    int res = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            res += lower_bound(l.begin(), l.end(), l[i] + l[j]) - (l.begin() + j + 1);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import sys
#import bisect
sys.setrecursionlimit(10**6)
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

def bisect(ls,x):
    l,r=0,len(ls)
    while r-l>1:
        mid=(l+r)//2
        if ls[mid]>=x: # condition
            r=mid
        else:
            l=mid
    #print('bisect',ls,x,'=',r)
    return l

n=I()
a=deque()
q=[[] for _ in range(n)]
m=0 # num of queue now
for i in range(n):
    a+=[I()]
#print('a=',a)

q=deque()
q.append(a.popleft())
#print(q,'q[',0,']=')

while a:
    c=a.popleft()
    if c<=q[0]:
        q.appendleft(c)
        #print(q,'q[',0,']=',c)
    else:
        i=bisect(q,c)
        q[i]=c
        #print(q,'q[',i,']=',c)


ans=len(q)
print(ans)


Measured memory_bytes: 53664
#include <stdio.h>

int ser(int*,int,int);

int main()
{
  int A[10000+1],sum = 0,i,n,q,key;

  scanf("%d",&n);
  for(i=0;i<n;i++)
      scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      if(ser(A,n,key))
	sum++;
    }
  printf("%d\n",sum);

  return 0;
}

int ser(int A[],int n,int key)
{
  int i=0;
  A[n]= key;
  while(A[i] !=key)
    i++;
  return i != n;
}
  


  



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

int main () {
    
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        cout << "a < b" << endl;
    }
    else if (a > b) {
        cout << "a > b" << endl;
    }
    else {
        cout << "a == b" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
n = int(input())
h = [int(i) for i in input().split()]
ans =  True
maxv = h[0]
for i in range(n-1):
        if h[i] > h[i+1]:
            if maxv-h[i+1] >= 2:
                ans = False
        elif maxv < h[i+1]:
            maxv = h[i+1]
if ans == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63984
#include<stdio.h>

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

int main(){

  long long int n;
  scanf("%lld",&n);

  long long int ans = 1;
  long long int tmp;
  int flag = 0;

  for(int i = 0; i < n; ++i){
    scanf("%lld",&tmp);
    if( tmp == 0 ){
      printf("0");
      return 0;
    }
    if( ans > 1000000000000000000 / tmp ){
      flag = 1;
    }

    ans *= tmp;

  }

  if(flag == 1) printf("-1");
  else printf("%lld",ans);

  return 0;
}


Measured memory_bytes: 1728
n = gets.to_s.to_i
a = gets.to_s.split.map{ |v| v.to_i }

# nが3の倍数でないとき
# 全てのaが0
# nが3の倍数の時
# n/3づつ、a,b,cがあって、a^b^c==0
# 2n/3 a, n/3 b a^a^b==0 -> b == 0
# 全てのaが0

def solve(n,a)
  return "Yes" if a.all?(&:zero?)
  return "No" if n % 3 != 0

  b = a.tally
  return "No" if b.keys.size > 3
  return "Yes" if b.values.all?{ _1 == n / 3 } && b.keys.inject(:^) == 0
  return "No" if b.size == 1
  return "Yes" if b.keys.sort.first.zero? && b[0] == n / 3
  return "No"
end

puts solve(n,a)

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


int n,d,x,i,ar[1003],total,hari;
int main(){
    ios_base::sync_with_stdio(false);

    cin>>n;
    cin>>d>>x;

    total=0;
    for(i=0;i<n;i++){
        cin>>ar[i];
        hari=1;
        while(hari<=d){total++; hari+=ar[i];}
    }
    cout<<total+x<<"\n";
}


Measured memory_bytes: 256
//package com.beginner.b053;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception
    {
        Scanner sc = new Scanner(System.in);
        long target = sc.nextLong();

        long ans = 1;


        long base = (target-1)/11;
        long rest = (target-1)%11;

        if(rest<=5) ans = base*2+1;
        else ans = base*2+2;



        System.out.println(ans);

        sc.close();
    }

}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	int r = 0;
	string cur;
	cur += s[0];
	r = 1;
	string t = "";
	int k = 1;
	while(r < n){
		t += s[r];
		if(t != cur){
			cur = t;
			k++;
			t = "";
		}
		r++;
	}
	cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

const int INF = 1<<29;

int toInt(string s){
  stringstream ss;
  ss << s;
  int a;
  ss >> a;
  return a;
}

int main(){
  int p,s;
  bool flag = false;
  while(cin >> p && p){
    if(flag) cout << endl;
    flag = true;
    cin >> s;
    s++,p++;
    vector<vector<int> >v;
    v.resize(p,vector<int>(s));
    //    cin.ignore();

    string str;
    vector<pair<int,int> >pos;
    int total = 0;
    int r_hatena[p];
    int c_hatena[s];
    int r[p];
    int c[s];

    fill(r_hatena,r_hatena+p,0);
    fill(c_hatena,c_hatena+s,0);
    fill(r,r+p,0);
    fill(c,c+s,0);

    for(int i=0; i<p; i++){
      for(int j=0; j<s; j++){
	cin >> str;
	if(str == "?"){
	  total++;
	  v[i][j] = INF;
	  pos.push_back(pair<int,int>(j,i));
	}
	else v[i][j] = toInt(str);
      }
    }


    for(int i=0; i<p; i++){
      int sum = 0;
      for(int j=0; j<s; j++){
	if(v[i][j] == INF) c_hatena[j]++;
	else if(j != s-1) sum += v[i][j];
      }
      r[i] = sum;
    }


    for(int i=0; i<s; i++){
      int sum = 0;
      for(int j=0; j<p; j++){
	if(v[j][i] == INF) r_hatena[j]++;
	else if(j != p-1) sum += v[j][i];
      }
      c[i] = sum;
    }


    priority_queue<pair<bool,int>,vector<pair<bool,int> >,
      greater<pair<bool,int> > >que;

    for(int i=0; i<s; i++){
      if(c_hatena[i] == 1){
	que.push(pair<bool,int>(true,i));
      }

    }

    for(int i=0; i<p; i++){
      if(r_hatena[i] == 1){
	que.push(pair<bool,int>(false,i));
      }
    }

    //p tate s yoko
    //0 is row 1 is column
    while(!que.empty()){
      pair<bool,int> tmp = que.top();
      que.pop();

      if(tmp.first == 0){
	if(r_hatena[tmp.second] <= 0)continue;

	for(int i=0; i<s; i++){
	  if(v[tmp.second][i] == INF){
	    v[tmp.second][i] = v[tmp.second][s-1]-r[tmp.second];
	    //	    cout << v[tmp.second][s-1] << endl;
	    //	    cout << r[tmp.second] << endl;
	    r_hatena[tmp.second]--;
	    c_hatena[i]--;
	    //	    cout << tmp.second << " " << i << endl;
	    total--;
	    c[i] += v[tmp.second][i];
	    if(c_hatena[i] == 1)
	      que.push(pair<bool,int>(1,i));
	  }
	}





      } else {
	if(c_hatena[tmp.second] <= 0)continue;
	for(int i=0; i<p; i++){
	  if(v[i][tmp.second] == INF){
	    //	    cout << i << " " << tmp.second << endl;
	    v[i][tmp.second] = v[p-1][tmp.second]-c[tmp.second];
	    c_hatena[tmp.second]--;
	    r_hatena[i]--;
	    //	    cout << i << " " << tmp.second << endl;
	    //	    cout << c_hatena[tmp.second] << endl;
	    //	    cout << r_hatena[i] << endl;
	    r[i] += v[i][tmp.second];
	    total--;
	    if(r_hatena[i] == 1)
	      que.push(pair<bool,int>(0,i));
	    //	    cout << v[i][tmp.second] << endl;
	  }
	}

      }






    }

    

    if(total <= 0){
      for(int i=0; i<pos.size(); i++){
	int x = pos[i].first;
	int y = pos[i].second;
	cout << v[y][x] << endl;
      }
    } else cout << "NO" << endl;
    //    cout << endl;
  }
  return 0;
}

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

typedef long long ll;

vector <ll> arr;

bool visited[105], edge[105][105], done[105][105];
int n, m;

void dfs(int node){

    visited[node] = true;

    for(int i=1; i<=n; i++){
        if(node == i || edge[node][i] == false || visited[i] == true) continue;
        dfs(i);
    }
}

bool solve(int a, int b){
    edge[a][b] = edge[b][a] = false;

    for(int i=1; i<=n; i++)
        visited[i] = false;
    dfs(1);

    edge[a][b] = edge[b][a] = true;    
    for(int i=1; i<=n; i++)
        if(visited[i] == false) return true;
    return false;
}

int main(){

    scanf("%d %d\n", &n, &m);

    for(int i=0; i<105; i++){
        for(int j=0; j<105; j++){
            edge[i][j] = edge[j][i] = false;
            done[i][j] = done[j][i] = false;
        }
    }
    
    int x, y;
    for(int i=1; i<=m; i++){
        scanf("%d %d\n", &x, &y);
        edge[x][y] = edge[y][x] = true;
    }

    int ans = 0;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(j == i || edge[i][j] == false || done[i][j]) continue;
            ans += solve(i, j);
            done[i][j] = done[j][i] = true;
        }
    }

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

Measured memory_bytes: 256
#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM : https://atcoder.jp/contests/dp/submissions/4011183

S,T = input(), input()
S,T = list(map(lambda x: ord(x)-97, S)), list(map(lambda x: ord(x)-97, T))

# print(S,T)

dp = [ [0] * (len(T)+1)] + [[0]+[None]*len(T) for _ in range(len(S))]

for i,s in enumerate(S):
    for j,t in enumerate(T):
        dp[i+1][j+1] = max(
                dp[i][j+1], 
                dp[i+1][j],
                dp[i][j] + (s==t)
                )
res = []

x,y = len(S), len(T)

while x > 0 and y > 0:
    if dp[x][y] == dp[x-1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y-1]:
        y -= 1
    else:
        x -= 1
        y -= 1
        res.append(chr(S[x]+97))
print(''.join(reversed(res)))



Measured memory_bytes: 121180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 202020;
int n;
int a[N];
int main() {
	scanf("%d", &n);
	rep(i, 1, n + 1) scanf("%d", a + i);
	ll sum = 0;
	rep(i, 1, n + 2) sum += abs(a[i] - a[i - 1]);
	rep(i, 1, n + 1) {
		ll t = sum;
		t -= abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i]);
		t += abs(a[i + 1] - a[i - 1]);
		printf("%lld\n", t);
	}
	return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
int gcd(int x,int y){
    while(true){
    if(y>x) swap(x,y);
    if(x%y==0) return y;
    else x =x%y;
    }
}

signed main(){
    int K;
    cin >>K;
    int ans=0;
    REP(i,K){
        REP(j,K){
            REP(l,K){
                ans+=gcd(i+1,gcd(j+1,l+1));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636