akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int left, right;
    cin >> left >> right;
    
    sum += (right - left) + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
from collections import Counter
a, b = map(int, input().split())
s = list(input())
c = Counter(s)
if len(s) == a+b+1:
    if c['-'] == 1 and s[a] == '-':
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	    a -= Modulus;
	}
	return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	    a += Modulus;
	}
	a -= rhs.a;
	return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	    if (exp % 2) {
		*this *= rhs;
	    }
	    rhs *= rhs;
	    exp /= 2;
	}
	return *this;
    }
};

#include <utility>

template <class T, class U> constexpr T power(T x, U exp) {
    T ret = static_cast<T>(1);
    while (exp) {
	if (exp % static_cast<U>(2) == static_cast<U>(1))
	    ret *= x;
	exp /= static_cast<U>(2);
	x *= x;
    }
    return ::std::move(ret);
}

int main() {
    using mint = modint<1000000007>;
    int N, M;
    mint K=0, ans=1, tmp=0, tmp2=0;
    cin >> N >> M;


    if(abs(N-M) == 0){
	for(int i=1; i<=N; i++){
	    ans *= i;
	    ans *= i;
	}
	ans *= 2;

    }
    else if(abs(N-M) == 1){
	for(int i=1; i<=min(N, M); i++){
	    ans *= i;
	    ans *= i;
	}
	ans *= max(N, M);
    }
    else{
	ans = 0;
    }
    cout << ans.a << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
    int a, b, c, max, ax, bx, cx, x, m;
    scanf("%d %d %d", &a, &b, &c);

    max = a;
    if (max < b) max = b;
    if (max < c) max = c;

    ax = (max - a) / 2;
    bx = (max - b) / 2;
    cx = (max - c) / 2;

    a = 2 * ax + a;
    b = 2 * bx + b;
    c = 2 * cx + c;

    x = ax + bx + cx;

    max = a;
    if (max < b) max = b;
    if (max < c) max = c;

    m = (max - a);
    m += (max - b);
    m += (max - c);

    if (m == 2) x += 1;
    if (m == 1) x += 2;


    printf("%d\n", x);
}

Measured memory_bytes: 128
l = []
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break

    l.append([H, W])

for i in range(len(l)):
    for j in range(l[i][0]):
        if j%2 == 0:
            if l[i][1]%2 == 0:
                print(int(l[i][1]/2) * '#.')
            else:
                print(int(l[i][1]/2) * '#.', '#', sep = '')
        else:
            if l[i][1]%2 == 0:
                print(int(l[i][1]/2) * '.#')
            else :
                print(int(l[i][1]/2) * '.#', '.', sep = '')
    
    print('')


Measured memory_bytes: 5640
#include <stdio.h>

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

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

    for (int i = k; i < n; i++) {
        if (score[i - k] < score[i]) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2400
def main():
  k, N = (int(x) for x in input().split())
  min_LIST = []
  LIST = []
  LIST = list(map(int,input().split()))
  x = 0

  for i in range(len(LIST) - 1):
    min_LIST.append(LIST[i + 1] - LIST[i])
    if(x <= min_LIST[i]):
      x = min_LIST[i]

  if(N != 2):
    min_LIST.append(LIST[0] + (k - LIST[-1]))
    if(x <= (LIST[0] + (k - LIST[-1]))):
      x = (LIST[0] + (k - LIST[-1]))

  sum_list = sum(min_LIST) - x

  print(sum_list)
if __name__ == "__main__":
  main()


Measured memory_bytes: 26444
#include<stdio.h>

int main(){
  int a,b,c,i,n=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0) n++;
  }
  printf("%d\n",n);
  return 0;
}


Measured memory_bytes: 2064
n = int(input())
s = str(input())
ss = str(input())
num = [1]

for i in range(n-1):
  if s[i] == s[i+1]:
    num[-1] += 1
  else:
    num.append(1)

ans = 1
status = 0
for i in range(len(num)):
  if num[i] == 2:
    if status == 1:
      ans *= 2
      status = 2
    elif status == 2:
      ans *= 3
    else:
      ans *= 6
      status = 2
  else:
    if status == 1:
      ans *= 2
    elif status == 2:
      status = 1
    else:
      ans *= 3
      status = 1
  ans %= 10 ** 9 + 7
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,g[2][3];
	scan(N);
	rep(i,2) rep(j,3) scan(g[i][j]);
	vpll AB,BA;
	rep(j,3){
		if(g[0][j]<g[1][j]) AB.push_back({g[0][j],g[1][j]});
		if(g[0][j]>g[1][j]) BA.push_back({g[1][j],g[0][j]});
	}
	ll maxD=N;
	if(AB.size()==3){
		for(ll a=0;a*AB[0].first<=N;a++){
			for(ll b=0;a*AB[0].first+b*AB[1].first<=N;b++){
				ll c=(N-a*AB[0].first-b*AB[1].first)/AB[2].first;
				ll nokorid=N-a*AB[0].first-b*AB[1].first-c*AB[2].first;
				ll D=nokorid+a*AB[0].second+b*AB[1].second+c*AB[2].second;
				maxD=max(maxD,D);
				//printf("a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\n",a,b,c,nokorid,D,maxD);
			}
		}
	}
	else if(AB.size()==2){
		for(ll a=0;a*AB[0].first<=N;a++){
			ll b=(N-a*AB[0].first)/AB[1].first;
			ll nokorid=N-a*AB[0].first-b*AB[1].first;
			ll D=nokorid+a*AB[0].second+b*AB[1].second;
			maxD=max(maxD,D);
			//printf("a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\n",a,b,nokorid,D,maxD);

		}
	}
	else if(AB.size()==1){
		maxD=(N-N/AB[0].first*AB[0].first+N/AB[0].first*AB[0].second);
	}
	//printf("maxD:%lld\n",maxD);
	N=maxD;
	if(BA.size()==3){
		for(ll a=0;a*BA[0].first<=N;a++){
			for(ll b=0;a*BA[0].first+b*BA[1].first<=N;b++){
				ll c=(N-a*BA[0].first-b*BA[1].first)/BA[2].first;
				ll nokorid=N-a*BA[0].first-b*BA[1].first-c*BA[2].first;
				ll D=nokorid+a*BA[0].second+b*BA[1].second+c*BA[2].second;
				maxD=max(maxD,D);
				//printf("a:%lld b:%lld c:%lld nokorid:%lld D:%lld maxD:%lld\n",a,b,c,nokorid,D,maxD);

			}
		}
	}
	else if(BA.size()==2){
		for(ll a=0;a*BA[0].first<=N;a++){
			ll b=(N-a*BA[0].first)/BA[1].first;
			ll nokorid=N-a*BA[0].first-b*BA[1].first;
			ll D=nokorid+a*BA[0].second+b*BA[1].second;
			maxD=max(maxD,D);
		//	printf("a:%lld b:%lld nokorid:%lld D:%lld maxD:%lld\n",a,b,nokorid,D,maxD);

		}
	}
	else if(BA.size()==1){
		maxD=(N-N/BA[0].first*BA[0].first+N/BA[0].first*BA[0].second);
	}
	prin(maxD);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100010
int n,l,t,cnt,a[N],w[N];
int main(){
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;++i) scanf("%d%d",&a[i],&w[i]);
	for(int i=1;i<=n;++i){
		int now=a[i];
		if(w[i]==2) w[i]=-1;
		a[i]+=t*w[i];
		cnt+=a[i]/l;
		if(a[i]%l<0) cnt--;
		a[i]=(a[i]%l+l)%l;
	}
	sort(a+1,a+n+1);
	cnt=(cnt%n+n)%n;
	for(int i=1;i<=n;++i) printf("%d\n",a[(i+cnt-1)%n+1]);
	return 0;
}

Measured memory_bytes: 1920
N = int(input())
if N < 1000:
    print(1000-N)
else:
    
    L = str(N)
    L1 = str(L[-3] + L[-2] + L[-1])
    N1 = int(L1)
    if N1 == 0:
        print(0)
    else:
        print(1000 - N1)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    ll arr[n][3];
    rep(i,0,n)
    rep(j,0,3)cin>>arr[i][j];
    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    rep(i,0,3)
    dp[0][i]=arr[0][i];
    rep(i,1,n)
    {
        rep(j,0,3)
        {
            rep(k,0,3)
            {
                if(j!=k)
                {
                    dp[i][j]=max(dp[i-1][k]+arr[i][j],dp[i][j]);
                }
            }
        }
    }
    ll m=0;
    rep(i,0,3)
    m=max(dp[n-1][i],m);
    cout<<m<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 8280
n,m=map(int,input().split())

S=[]

for i in range(n):
    tmp=input()
    S.append(tmp)

s=[]

for i in range(m+2):
    s.append("#")

print(''.join(s))

for i in range(n):
    tmp=["#", S[i], "#"]
    print(''.join(tmp))

print(''.join(s))


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

using namespace std;

void maxi(int &a, int b) {
	a = max(a,b);
}

int main() {
	long long n; cin >> n;
	if (n % 2 == 0) {
		long long v = 10;
		long long total = 0;
		for (int i=0; i<25; i++) {
			total += n/v; 						
			v*=5;
		}
		cout << total << "\n";
	} else  {
		cout << 0 << "\n";
	}	
}




Measured memory_bytes: 256
/**/
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted.
 *      ____________
 *     /            \
 *    /  /\      /\  \
 *   /  /  \    /  \  \
 *   \                /
 *    \     \___/    /
 *     \____________/
 */
const long long mod = 1000000007;
vector<int> cnt;
vector<bool> can;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N,M,u,v;
	cin>>N>>M;
	can.resize(N),cnt.resize(N,1);
	can[0] = true;
	for(int i = 0;i < M;i++){
		cin>>u>>v;
		u--,v--;
		cnt[u]--,cnt[v]++;
		if(can[u])
			can[v] = 1;
		if(cnt[u] == 0)
			can[u] = 0;
	}
	int res = 0;
	for(int i = 0;i < N;i++)
		res += can[i];//cout<<can[i]<<" \n"[i+1 == N];
	cout<<res<<'\n';
	return 0;
}
/**/


Measured memory_bytes: 640
//@author rohit_0801
// help source : https://www.geeksforgeeks.org/given-an-array-arr-find-the-maximum-j-i-such-that-arrj-arri/

 
#include <bits/stdc++.h>
#define ll int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define debug 0
 
using namespace std;
const ll MOD = 1000000007;
const ll MODD = MOD-1;
 
ll ar[900780], left_max[448390], right_min[123456],br[1234567];
ll dp[505][505], mat[505][505];

vector<ll> vec,pec;

void go(int n, int k)
{
    for (int i=0; i<=n; i++)
        for (int j=0;j<=k;j++)
            dp[i][j] = 0;
 
    dp[0][0] = 0;
 

    for (int i=1;i<=n;i++)
		for (int j=1;j<=k;j++)
 			for (int m=i-1;m>=0;m--)
                dp[i][j] = max(dp[i][j], mat[i-1][m]);
 
 
}

ll solve(ll n)
{
	ll c=0;
    for(int i=1;i<=n;i++){
    	if(n%i==0){
    		c++;
		}
	}
	
	if(c==8){
		return 1;
	}
	else{
		return 0;
	}
}
 
 
int main() {
	//srand(time(0));
	ll a,b,n,m,flag=0,r,t,u,v,w,x,y,z,k,res=0,d,maxm=-999999999,i,j,ct,h,ans=0,s,l,e,f,p,minm=999999999,c,type,q,len,siz;
 	
 	set<ll>::iterator it,jt;
 	
 	string str="",ptr="";
 	char ch;
 	
 	cin>>n;
 	
 	c=0;
 	for(i=1;i<=n;i++){
 		if(i%2){
 			r=solve(i);
	 		if(r){
	 			c++;
			 }
		 }
	 }
 
     cout<<c;
	
	return 0;
}  

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
typedef long long ll;
using namespace std;
string s, t;
int DP[3003][3003]; //DP[i][j]はsのi文字目までと、tのj文字目までの部分文字列の長さ

// ① DP[i+1][j+1]を求めるために、DP[i][j],DP[i][j+1],DP[i+1][j]をどう使うか。
// その漸化式を求めてからDP[s.size()][t.size()]を求める
// ② それを求めてから、その最長文字列がなんであるのかを求める。
// DP[i][j]とDP[i-1][j-1],DP[i][j-1],DP[i-1][j]が変化する時がポイント 

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

  cin >> s >> t;
  rep(i, s.size()) {
    rep(j, t.size()) {
      if (s[i] == t[j]){ // 等しければDP[i][j]までの最長文字列にその文字を加えればいい
        DP[i+1][j+1] = max(DP[i+1][j+1], DP[i][j]+1);
      } else {
        // 等しくなければ、DP[i+1][j]までの最長文字列かDP[i][j+1]までの最長文字列
        DP[i+1][j+1] = max(DP[i+1][j], DP[i][j+1]);
      }
    }
  }

  string ans = "";
  int i = s.size();
  int j = t.size();
  while(i>0 && j>0) {
    if (DP[i][j] == DP[i-1][j]){
      i--;
      continue;
    }

    if (DP[i][j] == DP[i][j-1]){
      j--;
      continue;
    }

    ans = s[i-1] + ans;
    i--, j--;
  }

  cout << ans << endl;
}

Measured memory_bytes: 35456
// D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int H, W, sh, sw, eh, ew; cin>>H>>W>>sh>>sw>>eh>>ew; sh--, sw--, eh--; ew--;
	string S[H]; rp(i, 0, H) cin>>S[i];

	int INF = 1e9;
	vector<vi> dst(H, vi(W, INF));
	dst[sh][sw] = 0;
	deque<pair<int, int>> dq; // <h, w>
	dq.emplace_front(sh, sw);

	while(dq.size()){
		int h, w; tie(h, w) = dq.front(); dq.pop_front();
		rp(dh, -2, 3) rp(dw, -2, 3){
			int nx_h = h + dh, nx_w = w + dw;
			if(nx_h < 0 || H <= nx_h || nx_w < 0 || W <= nx_w || S[nx_h][nx_w] == '#') continue;
			if(dh*dh + dw*dw == 1){
				if(dst[nx_h][nx_w] <= dst[h][w]) continue;
				dst[nx_h][nx_w] = dst[h][w];
				dq.emplace_front(nx_h, nx_w);
			}
			else if(dh*dh + dw*dw > 1){
				if(dst[nx_h][nx_w] <= dst[h][w] + 1) continue;
				dst[nx_h][nx_w] = dst[h][w] + 1;
				dq.emplace_back(nx_h, nx_w);
			}
		}
	}

	cout<< (dst[eh][ew]==INF? -1:dst[eh][ew]) <<endl;
}


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

int main() {
  int n;
  cin >> n;
  int r;
  int minv;
  cin >> minv; // 初期値を最初の入力とする 
  int maxv = -2000000000; //入力に対して十分小さな値
  
  for (int i=1; i<n; i++) { // 二つ目の入力から計算をはじめる
    cin >> r;
      maxv = max(maxv, r-minv); // 利益を最大化
      minv = min(minv, r);
  }
  cout << maxv << endl;
  
  return 0;
}


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a.at(a.size() - 1) == b.at(0) && b.at(b.size()-1) == c.at(0))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int res[1024][1024];

int main(){
   res[1][1]=1;
   rep(d,1,10){
      int mask=1<<d;
      rep(i,0,mask)rep(j,0,mask){
         res[i+mask][j]=res[i][j+mask]=res[i][j];
         res[i+mask][j+mask]=res[i][j]^1;
      }
   }
   int n,m; scanf("%d%d",&n,&m);
   rep(i,1,1<<n){
      rep(j,1,1<<m){
         int x=res[i][j]^res[i-1][j]^res[i][j-1]^res[i-1][j-1];
         printf("%d",x);
      } puts("");
   }
   return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int N = 2e3+10;
int h,w;
string s[N];
int ans;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &h, &w);
  rep(i, 0, h){
    cin >> s[i];
  }
  vector<vector<int>> row(h), col(w);

  rep(i, 0, h){
    rep(j, 0, w){
      if(s[i][j] == '#'){
        row[i].PB(j);
        col[j].PB(i);
      }
    }
  }

  rep(i, 0, h){
    rep(j, 0, w){
      if(s[i][j] == '.'){
        int lo = 0, hi = sz(row[i])-1;

        int l = -1, r = w;
        // search for left
        // greatest value < j
        while(lo <= hi){
          int mid = (hi+lo)/2;
          if(row[i][mid] < j){
            lo = mid+1;
            l = row[i][mid];
          } else {
            hi = mid-1;
          }
        }

        //search for right
        lo = 0; hi = sz(row[i])-1;

        while(lo <= hi){
          int mid = (hi+lo)/2;
          if(row[i][mid] > j){
            hi = mid-1;
            r = row[i][mid];
          } else {
            lo = mid + 1;
          }
        }


        lo = 0; hi = sz(col[j])-1;

        int d = -1, u = h;
        // search down
        while(lo <= hi){
          int mid=(hi+lo)/2;

          // greatest value < i
          if(col[j][mid] < i){
            d = col[j][mid];
            lo = mid+1;
          } else {
            hi = mid-1;
          }
        }

        lo = 0; hi = sz(col[j])-1;

        while(lo <= hi){
          int mid=(hi+lo)/2;

          // lowest value > i
          if(col[j][mid] > i){
            u = col[j][mid];
            hi = mid-1;
          } else {
            lo = mid+1;
          }
        }

        ans = max(ans, (r-l-1) + (u-d-1)-1);
        // printf("i:%d, j:%d, val:%d\n", i, j, (r-l-1) + (u-d-1)-1);
      }
    }
  }

  printf("%d\n", ans);

}


Measured memory_bytes: 38656
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1000000007;
const long double big=1e7+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int solve(vector<vector<int>>& hen){
	//隣接行列
	int n=hen.size();
	vector<int>tu(n);
	tu[0]=1;
	queue<int>que;
	que.push(0);
	while(!que.empty()){
		int town=que.front();
		que.pop();
		for(int i=0;i<n;i++){
			if(hen[town][i]==1&&tu[i]==0){que.push(i);tu[i]=1;}
		}
	}
	for(int i=0;i<n;i++){if(tu[i]==0){return 1;}}
	return 0;
}
int main(void){
	ios::sync_with_stdio(false);
	int i,j,k,n,m,ans=0;cin>>n>>m;
	vector<vector<int>>hen(n);
	for(i=0;i<n;i++){hen[i].res(n);}
	for(i=0;i<m;i++){int a,b;cin>>a>>b;a--;b--;hen[a][b]=1;hen[b][a]=1;}
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			if(hen[i][j]==0){continue;}
			hen[i][j]=0;hen[j][i]=0;
			ans+=solve(hen);
			hen[i][j]=1;hen[j][i]=1;
		}
	}
	cout<<ans<<endl;
	//やるだけ
	return 0;
}


Measured memory_bytes: 888
/*
17D8101031C 杉山　祥吾 ID:keisei334 C
*/

#include <stdio.h>
#include <math.h>

int isPrime(int x){
  int j;
  if(x==2) return 0;
  if(x<2 || x%2==0) return 1;
  
  j=3;
  while(j<=sqrt(x)){
    if(x%j==0) return 1;
    j+=2;
  }
  return 0;
}

int main(void){
  int n,i,j,c,count=0;
  scanf("%d", &n);
  int a[n];

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

  for(i=0;i<n;i++){
    c=isPrime(a[i]);
    if(c==0) count++;
  }

  printf("%d\n",count);
  
  return 0;
}

/*実行結果
6
2
3
4
5
6
7
4
*/


Measured memory_bytes: 2040
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

ll fast_pow(ll x, ll n) {
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

bool is_prime(ll n){
  for(ll x = 2; x * x <= n;x++){
    if(n % x == 0) return false;
  }
  return true;
}

enum Type{
  EVEN,
  ODD,
};

Type type;

ll dfs(ll pos,ll sum,ll len,ll center){
  if(pos == len/2){
    sum += (type == EVEN ? 0 : center * fast_pow(10,len/2));
    if(is_prime(sum)){
      return sum;
    }
    return 0;
  }
  ll res = 0;
  
  for(ll i=0;i<=9;i++){
    if(pos == 0 && i == 0) continue;
    ll lhs = i * fast_pow(10,pos);
    ll rhs = i * fast_pow(10,len-pos-1);
    res = max(dfs(pos + 1,sum + lhs + rhs,len,center),res);
  }
  return res;
}

int main(){
  ll n,center;
  while(~scanf("%lld %lld",&n,&center)){
    //odd
    if(center < 0){
      type = EVEN;

      if(n == 1){
        cout << "11" << endl;
      }
      else{
        cout << string(2*n,'9') << endl;
      }
    }
    //even
    else{
      type = ODD;
      ll len = 2 * n + (type == ODD ? 1 : 0);      
      ll ans = 0;
      ll none_ans = 0;
      
      for(int i=0;i<len;i++){
        none_ans += 9 * fast_pow(10,i);
      }
      printf("%lld\n",(ans = dfs(0,0,len,center)) == 0 ? none_ans : ans);
    }
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define rep(a,b) for(ll a=0; a<(b); ++a)

using namespace std;

using ll=long long;

const ll MOD=998244353;

ll comb[1123][1123];

ll modpow(ll a,ll n){
	a%=MOD;
	ll re=1;
	for(;n;n/=2){
		if(n%2) (re*=a)%=MOD;
		(a*=a)%=MOD;
	}
	return re;
}

int main(){
	comb[0][0]=1;
	rep(i,1023)rep(j,1023){
		(comb[i+1][j]+=comb[i][j])%=MOD;
		(comb[i+1][j+1]+=comb[i][j])%=MOD;
	}
	ll m,n,t;
	cin>>m>>n>>t;
	vector<ll> re(t+1);
	rep(i,t+1){
		re[i]=modpow(i,n);
		rep(j,i) (re[i]+=MOD-comb[i][j]*re[j]%MOD)%=MOD;
	}
	ll ans=modpow(m,n);
	ll M=m%MOD;
	rep(i,t)if(i){
		if(i>M) break;
		ll finv=1;
		rep(j,i) (finv*=j+1)%=MOD;
		finv=modpow(finv,MOD-2);
		ll cmb=finv;
		rep(j,i) (cmb*=M-j)%=MOD;
		(ans+=MOD-cmb*re[i]%MOD)%=MOD;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 12084
import math
N = int(input())
C, S, F = [], [], []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)
for j in range(N-1):
    t = 0
    for i in range(j, N-1):
        if S[i] >= t:
            t = S[i] + C[i]
        else:
            n = math.ceil((t-S[i])/F[i])
            t = S[i] + n*F[i] + C[i]
    print(t)
print(0)

Measured memory_bytes: 3188
from itertools import product
h,w, k = [int(i) for i in input().split()]
A = [input() for i in range(h)]

ans = 0
for i in product(range(2), repeat=h):
    row_ind = [ii for ii in range(h) if i[ii] == 1]
    for j in product(range(2), repeat=w):
        col_ind = [jj for jj in range(w) if j[jj] == 1]
        tmp = 0
        for sub_i in row_ind:
            for sub_j in col_ind:
                if A[sub_i][sub_j] == '#':
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)

Measured memory_bytes: 68820
#include <cstdio>
#include <algorithm>
int main()
{
	int a[55];
	int b[55];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		b[i] = a[i];
	}
	std::sort(b, b + n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i])
			cnt++;
	}
	if (cnt > 2)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if s[b-2:d+1].count("...")!=0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3572
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vector<int> p(n + 1), v;
		v.reserve(1000000);
		for(int i = 1; i <= n; ++i){
			scanf("%d", &p[i]);
			for(int j = 0; j <= i; ++j){
				int s = p[i] + p[j];
				if(s <= m){	v.push_back(s); }
			}
		}
		sort(v.begin(), v.end());

		int ans = 0;
		for(int i = 0; i < v.size(); ++i){
			ans = max(ans, v[i] + upper_bound(v.begin(), v.end(), m - v[i])[-1]);
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) >= K) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
# row = [int(input().rstrip()) for _ in range(n)]

def resolve():
    import sys
    input = sys.stdin.readline

    n, m = [int(x) for x in input().rstrip().split(" ")]

    ab = {}
    for _ in range(n):
        a, b = [int(x) for x in input().rstrip().split(" ")]
        if a not in ab:
            ab[a] = 0
        ab[a] += b

    a_list = sorted(ab.keys())
    ans = 0
    for a in a_list:
        if m <= ab[a]:
            ans += m * a
            break
        else:
            ans += ab[a] * a
            m -= ab[a]

    print(ans)



if __name__ == "__main__":
    resolve()


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

using namespace std;

int n, k;

int sche[100];

int dp[100][4][4];

int rec(int day, int a, int b) // a = i - 2 ??\???, b = i - 1 ??\???
{
    if (day == n) return 1;

    if (dp[day][a][b] >= 0) return dp[day][a][b];
    
    int res = 0;
    
    if (sche[day]) {
        if (sche[day] != a || sche[day] != b) {
            res += rec(day + 1, b, sche[day]);
            res %= 10000;
        }
    } else {
        for (int i = 1; i <= 3; ++i) {
            if (a == b && b == i) continue;
            res += rec(day + 1, b, i);
            res %= 10000;
        }
    }

    return dp[day][a][b] = res;
}

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

    for (int i = 0; i < k; ++i) {
        int day; cin >> day; --day;
        cin >> sche[day];
    }

    memset(dp, -1, sizeof(dp));

    printf("%d\n", rec(0, 0, 0));
}

Measured memory_bytes: 1152
#include <iostream>
 
using namespace std;
int main(){
  int n,x;
  cin>>n;
  cin>>x;
  int l,coor,count;
for(int i=0; i<n;i++){
  cin>>l;
  coor+=l;
  if(coor<=x) count++;
  else break;
}
  cout<<count+1;
 
    return 0;
    
}


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

using namespace std;
int N,K;

int GetCountCoinNum(int num)
{
    int result = num;
    int count = 0;
    while(result < K)
    {
        result = result * 2;
        count++;
    }
    return count;
}

int main()
{

	cin >> N >> K;
    int count = 0;
    double winRate = 0;
    for(int i = 1; i <= N; i++)
    {
        double test = pow(1.0 /2.0,GetCountCoinNum(i));
        winRate += (1.0/double(N)) * pow(1.0 /2.0,GetCountCoinNum(i));
    }

    cout << fixed << setprecision(12) << winRate << endl;

    return 0;

}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, k = map(int, input().split())

    if k == 1:
        print(0)
    else:
        print(n - k)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
from itertools import accumulate

N = int(input())

S = []
for _ in range(N):
  S.append(int(input()))

if sum(S)%10 != 0:
  print(sum(S))
  exit()  
  
S.sort()

T = list(accumulate(S))

for i,v in enumerate(T):
  if v%10 != 0:
    print(T[-1]-S[i])
    exit()
    
print(0 if T[-1]%10 == 0 else T[-1])  

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==b){
		if(a<c) printf("%d %d %d\n",a,b,c);
		else printf("%d %d %d\n",c,a,b);
	}else if(a==c){
		if(a<b) printf("%d %d %d\n",a,c,b);
		else printf("%d %d %d\n",b,a,c);
	}else if(b==c){
		if(a<c) printf("%d %d %d\n",a,b,c);
		else printf("%d %d %d\n",b,c,a);
	}else if(a==b && b==c)printf("%d %d %d\n",a,b,c);

	else if(a<b){
		if(a<c){
			if(b<c) printf("%d %d %d\n",a,b,c);
			else printf("%d %d %d\n",a,c,b);
		}if(c<a){
			printf("%d %d %d\n",c,a,b);
		}
	}else if(b<a){
		if(a<c){
			printf("%d %d %d\n",b,a,c);
		}if(c<a){
			if(b<c) printf("%d %d %d\n",b,c,a);
			else printf("%d %d %d\n",c,b,a);
		}
	}

	return 0;
}

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

int cnt[100001] = {};

int main() {
    int N;
    int a, ans = 1;
    const int M = 1000000007;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;

        if (cnt[a] == 0) {
            if (a == 0 && N % 2 == 1) {
                cnt[a]++;
            } else {
                ans *= 2;
                ans %= M;
                cnt[a]++;
            }
        } else if (cnt[a] == 1) {
            if (a == 0 && N % 2 == 1) {
                ans = 0;
                break;
            } else {
                cnt[a]++;
            }
        } else {
            ans = 0;
            break;
        }
    }

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

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

int main() {
  int r,c;
  cin >> r >> c;
  int table[101][101] = {0};
  for(int a = 0; a < r; ++a) {
    for(int b = 0; b < c; ++b) {
      cin >> table[a][b];
    }
  }
 for (int tate = 0; tate < r; ++tate) {
  for (int yoko = 0; yoko < c; ++yoko) {
    table[tate][c] += table[tate][yoko];
    table[r][yoko] += table[tate][yoko];
  }
  table[r][c] += table[tate][c];
 }
 for(int tate = 0; tate <= r; ++tate) {
   for(int yoko = 0; yoko < c; ++yoko) {
     cout << table[tate][yoko] << " ";
   }
   cout << table[tate][c] << endl;
 }
}

Measured memory_bytes: 3140
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 29)
#define LLINF (1LL << 61)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define TO_STRING(VariableName) # VariableName

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

int main() {
	bool c[26] = { false };
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i) {
		c[s[i] - 'a'] = true;
	}

	for (int i = 0; i < 26; ++i) {
		if (c[i] == false) {
			cout << (char)('a' + i) << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 512
from collections import deque

def reversedeq(deq):
    newdeq = deque()
    for _ in range(len(deq)):
        c = deq.pop()
        newdeq.append(c)
    
    return newdeq


S = deque(list(input()))
Q = int(input())
reverse_state = False

for _ in range(Q):
    Query = [x for x in input().split()]
    if len(Query) == 1:
        reverse_state = reverse_state ^ 1
    else:
        if reverse_state:
            if Query[1] == '1':
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if Query[1] == '1':
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if reverse_state:
    S = reversedeq(S)

print("".join(S))

Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e16
typedef long long ll;
typedef pair<ll,int> edge;
vector<edge> g[1000];
ll dp[1000];
bool usedV[1000];
map<pair<int,int>,bool> usedE;

int main(void){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        --a,--b;
        g[a].push_back({c,b});
    }

    priority_queue<edge,vector<edge>> pq;
    pq.push({dp[0]=0,0});
    while(pq.size()){
        edge pr = pq.top(); pq.pop();
        int from = pr.second;
        if(usedV[from] && pr.first < dp[from]) continue;
        for(edge e : g[from]){
            ll cost = e.first;
            int to = e.second;
            if(dp[to] >= INF) continue;
            if(!usedV[to] || dp[to] < dp[from]+cost){
                dp[to] = (usedE[{from,to}] ? INF : dp[from]+cost);
                pq.push({dp[to],to});
                usedV[to] = true;
                usedE[{from,to}] = true;
            }
        }
    }
    if(dp[n-1] >= INF) cout<<"inf"<<endl;
    else cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int MAX_D=400;
struct Integer{
    Integer(int i=0):n(0){
        fill_n(digits,MAX_D,0);
        while(i){digits[n++]=i%10;i/=10;}
    }
    int digits[MAX_D],n;
};
Integer operator*(const Integer& lhs,const Integer& rhs){
    Integer res;
    for(int i=0;i<MAX_D;i++){
        for(int j=0;j<MAX_D;j++){
            if(i+j>=MAX_D)continue;
            int x=lhs.digits[i]*rhs.digits[j]+res.digits[i+j];
            res.digits[i+j]=x%10;
            if(i+j+1<MAX_D)res.digits[i+j+1]+=x/10;
        }
    }
    return res;
}

const string unit[]={
    "","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan",
    "Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts",
};
int main(){
    int N,M;
    while(scanf("%d%d",&M,&N),N||M){
        Integer a(M),num(1);
        while(N){
            if(N&1)num=num*a;
            a=a*a;
            N>>=1;
        }


        int mx;
        for(int i=MAX_D-1;i>=0;i--){
            if(num.digits[i]!=0){
                mx=i;
                break;
            }
        }
        for(int i=mx;i>=0;){
            int x=0;
            while(true){
                x=x*10+num.digits[i];
                if(i%4==0)break;
                i--;
            }
            if(x>0){
                cout<<x<<unit[i/4];
            }
            i--;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1232
/* Range */
#include <stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a,&b,&c);

    if(a < b && b < c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2100
n, k = map(int, input().split())
a = list(map(int, input().split()))

max_digit = 40

# xのn桁目が1かどうか
def JudgeDigitN(x, n):
    return x >> n & 1 == 1 
    
c1 = [0] * max_digit
for i in a:
    for j in range(max_digit):
        if JudgeDigitN(i,j):
            c1[j] += 1
b = []

for i in range(max_digit-1,-1,-1):
    if not JudgeDigitN(k,i):
        continue
    tmp = 0
    for j in range(max_digit-1,i,-1):
        if JudgeDigitN(k,j):
            tmp += 2**j * (n-c1[j])
        else:
            tmp += 2**j * c1[j]
    tmp += 2**i * c1[i]
    for j in range(i-1, -1, -1):
        tmp += 2**j * max(c1[j], n-c1[j])
    b.append(tmp)
    
tmp = 0    
for i in range(max_digit):
    if JudgeDigitN(k,i):
        tmp += 2**i * (n-c1[i])
    else:
        tmp += 2**i * c1[i]
b.append(tmp)

print(max(b))

Measured memory_bytes: 14620
L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

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

public class Main {


    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] str2 = str.split(" ");
        int[] n = new int[str2.length];
        for (int i = 0; i < str2.length; i++) {
            n[i] = Integer.parseInt(str2[i]);
        }
        if(n.length == 2){
            System.out.print(n[0] * n[1] + " ");
            System.out.println((n[0] + n[1]) * 2);

        }
    }
}

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

int main()
{
    map<string, int> m ={
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        { "WED", 4},
        { "THU", 3},
        { "FRI", 2},
        { "SAT", 1}
    };
    string s;
    cin >> s;

    cout << m[s] << endl;


    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  vi arr(3);
  rep(i,3) cin >> arr[i];
  sort(all(arr));
  int a = arr[2] - arr[0];
  int b = arr[2] - arr[1];
  int ans = (a + b) / 2;
  if ((a + b) % 2) ans += 2;
  cout << ans << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  2019
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll l,r;
  cin >> l >> r;
  ll ans;
  if(r-l>=2018) ans=0;

  else{
    ans=3e9;
    for(ll i=l; i<=r-1; i++){
      for(ll j=i+1; j<=r; j++){
        //cout << (i*j)%MOD << endl;
        if(ans>(i*j)%MOD) ans=(i*j)%MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
 {
  	string s;
  	cin>>s;
  	int sum=0;
  	for(int i=0;i<s.size();i++){
    	sum+=s[i]-'0';
      	sum%=9;
    }
 	if(sum==0) cout<<"Yes";
  	else cout<<"No";
	return 0;
}

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

int main(){
    int n,k; string s;
    cin>>n>>k>>s;
    vector<int>a;
    int x=0;
    rep(i,n)if(s[i]=='1')x++;
    if(x==s.size()){cout<<x<<endl; return 0;}
    if(s[0]=='0')a.push_back(0);
    int cnt=1;
    rep(i,n-1){
        if(s[i]==s[i+1])cnt++;
        else a.push_back(cnt),cnt=1;
    }
    if(s[n-1]==s[n-2])a.push_back(cnt);
    else a.push_back(1);
    if(s[n-1]=='0')a.push_back(0);
    if(a.size()/2<k){cout<<s.size()<<endl; return 0;}
    int cnt2=0;
    rep(i,2*k+1)cnt2+=a[i];
    int ans=cnt2;
    for(int i=1; i<a.size()-2*k; i+=2){
        cnt2-=a[i]+a[i-1];
        cnt2+=a[i+2*k]+a[i+2*k+1];
        ans=max(ans,cnt2);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

int main() {
  int n=gi();
  int ac=0;
  vi a(10,0);
  for(int i=0;i<n;i++){
    int v=gi(), ok=1;
    for(int j=1;j<=8 && ok;j++)
    if(v<j*400){
      ok=0;
      a[j]++;
    }
    if(ok)ac++;
  }
  int cc=0;
  for(int i=1;i<=8;i++)
  if(a[i]){
    cc++;
  }
  if(cc)cout<<cc<<" ";
  else cout<<1<<" ";
  cout<<cc+ac<<endl;
  return 0;
}

Measured memory_bytes: 256
function sumArray (array) {
	return array.reduce((a, c) => a + c);
}

// inputに入力データ全体が入る
function Main(input) {
	var N = input;
	if (N == 7) {
		console.log('YES');
		return;
	}
	if (N == 5) {
		console.log('YES');
		return;
	}
	if (N == 3) {
		console.log('YES');
		return;
	}
	console.log('NO');
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22076
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 505;
const int A = 1000;

int n,m,h,w;
int main()
{
	#ifdef Amberframe
		freopen("agc016c.in","r",stdin);
		freopen("agc016c.out","w",stdout);
	#endif
	scanf("%d %d %d %d",&n,&m,&h,&w);
	if (n%h||m%w) {
		puts("Yes");
		int B=-(h*w-1)*A-1;
		for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			printf("%d%c",(i%h||j%w)?A:B," \n"[j==m]);
	}
	else puts("No");
	return 0;
}

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

void solve(long long A, long long B, long long C, long long K)
{
    long sum = 0;
    if (A < K)
        sum += A, K -= A;
    else
        sum += K, K = 0;
    if (B < K)
        K -= B;
    else
        K = 0;
    if (0 < K)
        sum -= K;
    cout << sum << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 3720
#include<stdio.h>
int main(){
  int a, b, d, r;
  double f;
  scanf("%d %d", &a, &b);
d=a/b;
 r=a-b*d;
 f=(double)a/b;
   printf("%d %d %f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 636