akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
signed main(){
  int n,m;
  cin >> n >> m;
  
  if( max(n,m) - min(n,m) > 1 ){
    cout << 0 << endl;
    return 0;
  }
  
  int N = 1;
  for(int i=1;i<=n;i++){
    N *= i;
    N %= mod;
  }
  
  int M = 1;
  for(int i=1;i<=m;i++){
    M *= i;
    M %= mod;
  }
  
  int ans = N * M;
  if( n == m ) ans *= 2;
  ans %= mod;
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

std::string S;
int Q;
bool flip = false;
std::deque<char> ans;

int main()
{
  std::cin >> S >> Q;

  rep( i, S.size() )
    ans.emplace_back( S[i] );

  rep( q, Q )
  {
    std::string T;
    std::cin >> T;

    if( T == "1" )
    {
      flip ^= true;
    }
    else if( T == "2" )
    {
      std::string F, C;
      std::cin >> F >> C;

      if( (F[0]-'1')^flip )
        ans.emplace_back( C[0] );
      else
      {
        ans.emplace_front( C[0] );
      }
    }
  }

  if( flip )
  {
    for( int i = ans.size()-1; i >= 0; --i )
      std::cout << ans[i];

    std::cout << std::endl;
  }
  else
  {
    rep( i, ans.size() )
      std::cout << ans[i];

    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int t;
    string num;
    cin >> t >> num;
    if(t==0&&num=="0") return 0;
    vector<pair<int,vector<int> > >answers;
    REP(i,1<<(num.size()-1)){
      vector<int> sep;
      sep.push_back(0);
      REP(j,num.size()-1) if(1&(i>>j)) sep.push_back(j+1);
      sep.push_back(num.size());
      int tmpans=0;
      vector<int> vi;
      REP(j,sep.size()-1){
	int tmp=stoi(string(num.begin()+sep[j],num.begin()+sep[j+1]));
	tmpans+=tmp;
	vi.push_back(tmp);
      }
      if(tmpans<=t) answers.push_back(make_pair(tmpans,vi));
    }
    SORT(answers);
    if(answers.empty()) cout << "error" << endl;
    else{
      int as=answers.size();
      if(as==1||answers[as-2].first!=answers[as-1].first){
	cout << answers[as-1].first;
	for(int p:answers[as-1].second) cout << ' ' << p;
	cout << endl;
      }else{
	cout << "rejected" << endl;
      }
    }
  }
}

Measured memory_bytes: 3112
#include<stdio.h>
int main(void)
{
	int i, n, x;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		x = i;
		if ((x % 3) == 0)
			printf(" %d", i);
		else
			while (x) {
				if (x % 10 == 3) {
					printf(" %d", i);
					break;
				}
				x = x / 10;
			}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int a,b,t;
    cin >> a >> b >> t;
    int ans = 0;
    ans = (int) (t+0.5) / a * b;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;

	set<char> s;
	REP(i,0,n){
		char tmp;
		cin>>tmp;
		s.insert(tmp);
	}
	if(s.size()==3)cout<<"Three"<<endl;
	else if(s.size()==4)cout<<"Four"<<endl;

	return 0;
}

Measured memory_bytes: 256
// 修改自提交记录：235469
// 原记录作者：E.Space (UID: 1579)
// 修改自提交记录：235395
// 原记录作者：E.Space (UID: 1579)
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
struct qu
{
	int x,l,r,v;
}q[222222];
int pq;
bool operator <(const qu &x,const qu &y)
{
	return x.x<y.x;
}
int f[222222];
struct st
{
	int add;
	int min;
	int l,r;
}t[555555];
void pd(int o)
{
	if(t[o].add)
	{
		t[o].min+=t[o].add;
		if(t[o].l==t[o].r){t[o].add=0;return;}
		t[o<<1].add+=t[o].add;
		t[o<<1|1].add+=t[o].add;
		t[o].add=0;
	}
}
inline void MT(int o)
{
	t[o].min=dmin(t[o<<1].min+t[o<<1].add,t[o<<1|1].min+t[o<<1|1].add);
}
void BT(int o,int l,int r)
{
	t[o].l=l,t[o].r=r;
	if(l==r){t[o].min=f[l]+l;return;}
	int mid=l+r>>1;
	BT(o<<1,l,mid);
	BT(o<<1|1,mid+1,r);
	MT(o);
}
int L,R,V;
void ad(int o)
{
	if(t[o].l>=L&&t[o].r<=R)
	{
		t[o].add+=V;
		return;
	}
	pd(o);
	int mid=t[o].l+t[o].r>>1;
	if(L<=mid)ad(o<<1);
	if(R>mid)ad(o<<1|1);
	MT(o);
}
void add(int l,int r,int v)
{
	L=l,R=r,V=v;
	ad(1);
}
int ans;
void que(int o)
{
	pd(o);
	if(t[o].l>=L&&t[o].r<=R)
	{
		cmin(ans,t[o].min);
		return;
	}
	int mid=t[o].l+t[o].r>>1;
	if(L<=mid)que(o<<1);
	if(R>mid)que(o<<1|1);
}
int query(int l,int r)
{
	if(l>r)return 0;
	L=l,R=r,ans=0x3f3f3f3f;
	que(1);
	return ans;
}
int main()
{
	int n=io::F(),m=io::F();
	for(register int i=1;i<=n;++i)
	{
		int x=io::F(),y=io::F();
		if(x+1!=y)q[++pq]=(qu){y+1,x,m,1},f[x]--;
	}
	for(register int i=1;i<=m;++i)
		f[i]+=f[i-1];
	BT(1,0,m);
	std::sort(q+1,q+pq+1);
	int now=1;
	int ans=dmin(0,m-n);
	for(register int i=1;i<=m+1;++i)
	{
		while(now<=pq&&q[now].x==i)
		{
			add(q[now].l,q[now].r,q[now].v);
			++now;
		}
		int tmp=query(0,i-2);
		cmin(ans,tmp+m+1-i);
	}
	printf("%d\n",-ans);
	return 0;
}

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

long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

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

    long long MOD = 1000000007LL;
    long long inv2 = powmod(2, MOD-2, MOD);
    long long px = -1;
    long long py = -1;
    long long ans = 0;
    for (long long y=0; y<N; y++)
        for (long long x=0; x<M; x++)
        {
            ans += y*(y+1)%MOD*inv2%MOD*M%MOD
                + (N-y-1)*(N-y)%MOD*inv2%MOD*M%MOD
                + x*(x+1)%MOD*inv2%MOD*N%MOD
                + (M-x-1)*(M-x)%MOD*inv2%MOD*N%MOD;
            ans %= MOD;
        }
    ans *= inv2;
    ans %= MOD;

    for (long long i=2; i<K; i++)
    {
        ans *= (N*M-i);
        ans %= MOD;
    }
    for (long long i=0; i<K-2; i++)
    {
        ans *= powmod(i+1, MOD-2, MOD);
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N){
        cin >> A[i];
    }
    sort(ALL(A),greater<int>());

    int sum = accumulate(ALL(A),0);

    if(sum / (double)(4*M) <= A[M-1]){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

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

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

    vector<vector<int>> graph(N, vector<int>(N, 1 << 29));
    for (int i = 0; i < N; i++) {
        graph[i][i] = 0;
    }
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        if (C < graph[A][B]) {
            graph[A][B] = graph[B][A] = C;
        }
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (graph[i][k] + graph[k][j] < graph[i][j]) {
                    graph[i][j] = graph[i][k] + graph[k][j];
                }
            }
        }
    }

    int shortest = 1 << 29;
    do {
        int cost = 0;
        for (int i = 0; i < R - 1; i++) {
            cost += graph[r[i]][r[i + 1]];
        }
        if (cost < shortest) {
            shortest = cost;
        }
    } while (next_permutation(r.begin(), r.end()));
    cout << shortest << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(a * b);
		
	}

}


Measured memory_bytes: 35700
#include<iostream>
using namespace std;
int n,sum;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	int len=s.size();
	cout<<s;
	if(s[len-1]=='s') cout<<"es";
	else cout<<"s";
	
}

Measured memory_bytes: 3128
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: Checker
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_K = 1000;
const int MAX_K2 = MAX_K * 2;

/* typedef */

/* global variables */

int bfs[MAX_K2 + 1][MAX_K2 + 1], wfs[MAX_K2 + 1][MAX_K2 + 1];

/* subroutines */

inline int box(int flds[MAX_K2 + 1][MAX_K2 + 1],
	       int x0, int y0, int x1, int y1) {
  return flds[y1][x1] - flds[y1][x0] - flds[y0][x1] + flds[y0][x0];
}

inline int count(int flds[MAX_K2 + 1][MAX_K2 + 1],
		 int k, int k2, int x0, int y0) {
  int x1 = x0 + k, y1 = y0 + k;
  return
    box(flds, 0, 0, x0, y0) +
    box(flds, x1, 0, k2, y0) +
    box(flds, x0, y0, x1, y1) +
    box(flds, 0, y1, x0, k2) +
    box(flds, x1, y1, k2, k2);
}

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int k2 = k * 2;

  for (int i = 0; i < n; i++) {
    int x, y;
    char cs[2];
    scanf("%d%d%s", &x, &y, cs);
    x %= k2, x++;
    y %= k2, y++;
    if (cs[0] == 'B') bfs[y][x]++;
    else wfs[y][x]++;
  }

  for (int y = 0; y < k2; y++)
    for (int x = 0; x < k2; x++) {
      bfs[y + 1][x + 1] += bfs[y + 1][x] + bfs[y][x + 1] - bfs[y][x];
      wfs[y + 1][x + 1] += wfs[y + 1][x] + wfs[y][x + 1] - wfs[y][x];
    }

  int ball = bfs[k2][k2], wall = wfs[k2][k2];
  int maxd = 0;

  for (int y = 0; y <= k; y++)
    for (int x = 0; x <= k; x++) {
      int d0 = count(bfs, k, k2, x, y) + (wall - count(wfs, k, k2, x, y));
      int d1 = count(wfs, k, k2, x, y) + (ball - count(bfs, k, k2, x, y));
      int d = max(d0, d1);
      if (maxd < d) maxd = d;
    }
  printf("%d\n", maxd);
  return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    ll b[m];
    rep(i, m) { cin >> b[i]; }

    ll a_sum[n + 1], b_sum[m + 1];
    a_sum[0] = 0;
    rep(i, n) { a_sum[i + 1] = a_sum[i] + a[i]; }
    b_sum[0] = 0;
    rep(i, m) { b_sum[i + 1] = b_sum[i] + b[i]; }

    ll ans = 0;
    rep(i, n + 1) {
        ll time_a = a_sum[i];
        if (time_a > k) {
            continue;
        }
        if (time_a + b_sum[m] <= k) {
            ans = max(ans, i + m);
            continue;
        }

        ll l = 0, r = m;
        while (r - l > 1) {
            ll mid = (l + r) / 2;
            ll time_b = b_sum[mid];
            if (time_a + time_b > k) {
                r = mid;
            } else {
                l = mid;
            }
        }
        ans = max(ans, i + l);
    }

    cout << ans << endl;

    return 0;
}



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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

int h,w;
char s[105][105];
int main(){
	scanf("%d%d",&h,&w);
	
	memset(s,'#',sizeof s);
	rep(k,1,h+1){
		scanf(" ");
		rep(i,1,w+1)scanf("%c",&s[k][i]);
	}
	
	rep(k,0,h+2){
		rep(i,0,w+2)printf("%c",s[k][i]);line;
	}
	return 0;
}


Measured memory_bytes: 256
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,35001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    z = random.randint(min(x,y),max(x,y))
    na[y-1] = na[x-1]
    na[y-1] = na[z-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 300-(298*k/40000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 90800
import java.util.Scanner;

public class Main {

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

Measured memory_bytes: 26352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    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)];
    }
};
vector<int> v;
int n,m,a=0,b=0,c=0,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        if(aa[i]%4==0) a++;
        elif(aa[i]%2==0) b++;
        else c++;
    }
    if((a>0&&a-c>=0)||(b==0&&a-c==-1)||c==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 11228
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cmath>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
#define downint greater<int>()
#define downchar greater<char>()
#define downstring greater<string>()
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  ll a[LIMIT2]={0},b[100]={0};
  
  cin >> n;
  rep(i,n) cin >> a[i];
  
  rep(i,n){
    tmp=a[i];
    j=0;
    while(tmp>0){
      b[j] += (tmp%2);
      tmp /= 2;
      j++;
    }
  }
  rep(i,61){
    tmp = b[i];
    tmp = (tmp*(n-b[i]))%MOD1;
    tmp = (tmp*modpow(2,i,MOD1))%MOD1;
    result += tmp;
    result %= MOD1;
  }
  
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
char c;
cin>>c;
if(c=='a'||c=='o'||c=='u'||c=='i'||c=='e')cout<<"vowel";
else cout<<"consonant";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int s=700;
    char a,b,c;
    cin>>a>>b>>c;
    if(a=='o'){s+=100;}
    if(b=='o'){s+=100;}
    if(c=='o'){s+=100;}
    cout<<s;

    return 0;
}


Measured memory_bytes: 3140
N = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mina = min(a)
a.insert(0, 0), a.append(0)
total = 0
for i in range(N + 1):
    total += abs(a[i] - a[i + 1])

for i in range(N):
        ans = total - abs(a[i] - a[i + 1]) - abs(a[i + 1] - a[i + 2]) + abs(a[i] - a[i + 2])
        print(ans)

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


int main(){
    vector<int> A(3);
    for(auto& a : A){
        cin >> a;
    }
    sort(A.begin(), A.end());
    for(int ii=0; ii<3; ii++){
        if(ii!=0) cout << " ";
        cout << A[ii];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3096
n=int(input())
s=input()
r=[0]*n
g=[0]*n
b=[0]*n
for i in range(n):
    if s[i]=="R":
        r[i]+=1
    elif s[i]=="G":
        g[i]+=1
    elif s[i]=="B":
        b[i]+=1
import itertools as it
acr=list(it.accumulate(r))
acg=list(it.accumulate(g))
acb=list(it.accumulate(b))


ans=0
memo=set()
for j in range(n):
    if g[j]==1:
        ans+=acr[j]*(acb[-1]-acb[j])
        ans+=acb[j]*(acr[-1]-acr[j])
        for x in range(1,min(j,n-j-1)+1):
            if j-x>=0 and s[j-x]!=s[j+x] and s[j-x]!="G" and s[j+x]!="G":
                ans-=1
    if r[j]==1:
        ans+=acg[j]*(acb[-1]-acb[j])
        ans+=acb[j]*(acg[-1]-acg[j])
        for x in range(1,min(j,n-j-1)+1):
            if j-x>=0 and s[j-x]!=s[j+x] and s[j-x]!="R" and s[j+x]!="R":
                ans-=1
    if b[j]==1:
        ans+=acr[j]*(acg[-1]-acg[j])
        ans+=acg[j]*(acr[-1]-acr[j])
    
        for x in range(1,min(j,n-j-1)+1):
            if j-x>=0 and s[j-x]!=s[j+x] and s[j-x]!="B" and s[j+x]!="B":
                ans-=1

print(ans)
        


Measured memory_bytes: 69632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n) , b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<ll> ab_comb(n);
    rep(i,n) {
        vector<int>::iterator p;
        p = upper_bound(a.begin(), a.end(), b[i]-1);
        if(p == a.end()) ab_comb[i] = n;
        else ab_comb[i] = distance(a.begin(), p);
        //cout << *p << endl;
        //cout << ab_comb[i] << endl;
    }
    vector<ll> bc_comb(n);
    rep(i,n) {
        vector<int>::iterator p;
        p = upper_bound(c.begin(), c.end(), b[i]);
        if(p == c.end()) bc_comb[i] = 0;
        else bc_comb[i] = distance(p,c.end());
    }
    ll ans = 0;
    rep(i,n) ans+=ab_comb[i]*bc_comb[i];
    cout << ans << endl;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;

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

int main() {
    ll n, c = -1, d, e;
    cin >> n;
    vector<ll> a(n + 1), b(n, 0), f(n + 2, 1);
    rep(i, n + 1) {
        cin >> a[i];
        a[i]--;
        b[a[i]]++;
    }
    rep(i, n) {
        if (b[i] == 2) e = i;
    }
    //cout << "e=" << e << endl;
    rep(i, n + 1) {
        if (a[i] == e) {
            if (c == -1) c = i;
            else d = i;
        }
    }
    //cout << "c=" << c << " d=" << d << endl;
    rep(i, n + 1) {
        f[i + 1] = (f[i] * (i + 1)) % MOD;
        //cout << i + 1 << " " << f[i + 1] << endl;
    }
    rep(i, n + 1) {
        // n+1 C i+1
        ll ans = f[n + 1];
        ans *= mod_pow(f[i + 1], MOD - 2, MOD);
        //cout << ans << " ";
        ans %= MOD;
        //cout << ans << " ";
        ans *= mod_pow(f[n - i], MOD - 2, MOD);
        //cout << ans << " ";
        ans %= MOD;
        //cout << ans << " ";
        ll n0 = c + n - d;
        //cout << "n0=" << n0 << " ";
        if (i + 1 <= n0 + 1) {
            ll ans0 = f[n0];
            ans0 *= mod_pow(f[i], MOD - 2, MOD);
            ans0 %= MOD;
            ans0 *= mod_pow(f[n0 - i], MOD - 2, MOD);
            ans0 %= MOD;
            ans -= ans0;
            ans += MOD;
            ans %= MOD;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3584
from collections import deque
H, W = map(int, input().split())

maze = [['#']*(W+2)]
for i in range(H):
    maze.append(list('#'+input()+'#'))
maze.append(['#']*(W+2))
ans = 0

for ii in range(1,H+1):
    for jj in range(1,W+1):
        if maze[ii][jj]=='#':continue
        temp = deque()
        temp.append([ii,jj])
        mazenum = [[0]*(W+2) for _ in range(H+2)]
        mazenum[ii][jj] = 0
        visited = [[False]*(W+2) for _ in range(H+2)]
        visited[ii][jj] = True


        while temp:
            p = temp.popleft()
            m = mazenum[p[0]][p[1]]
            for i, j in [[p[0]-1,p[1]], [p[0]+1, p[1]], [p[0],p[1]-1],[p[0],p[1]+1]]:
                if maze[i][j]=='.':
                    if not visited[i][j]:
                        temp.append([i, j])
                        mazenum[i][j] = m + 1
                        visited[i][j]= True        
        ans = max(ans, max(max(x) for x in mazenum))

print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s;
	int a,b,c,d;
	while(true){
	cin>>s;
	if(s=="#")break;
	cin>>a>>b>>c>>d;
	bool t[10][10]={0};
	int h,w,y=0,x=0;
	for(int u=0;u<s.size();u++){
		if(s[u]=='/')w=x,y++,x=0;
		if(s[u]=='b')t[y][x]=1,x++;
		if(s[u]>'0'&&s[u]<='9')x+=s[u]-'0';
	}
	h=y+1;
	t[a-1][b-1]=0,t[c-1][d-1]=1;
	for(int i=0;i<h;i++){
		if(i)cout<<"/";
		int cnt=0;
		for(int j=0;j<w;j++){
			if(t[i][j]){
				if(cnt)cout<<cnt;
				cout<<"b";
				cnt=-1;
			}
			cnt++;
		}
		if(cnt)cout<<cnt;
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
n = int(input())

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    x = (10 ** 9) + 7
    a = (10 ** n) % x
    b = (9 ** n) % x
    c = (8 ** n) % x
    y = a - b * 2 + c
    if y < 0:
        y += x
    y %= x
    print(y)

Measured memory_bytes: 10712
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
 

int main() {
    int64_t a,b,tmp,r,x;
    cin>>a>>b;
    
     x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
    cout<< x/b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//マス目を一筆がきで動けばいいのでは
int main(){
  ll H,W,N,b=1; cin>>H>>W>>N;
  queue<ll> q;
  stack<ll> st;
  for(int i=0; i<N; i++){
    ll a; cin>>a;
    while(a>0){
      q.push(b); a--;
    }
    b++;
  }
  for(int i=0; i<H; i++){
    if(i%2==0){
      for(int j=0; j<W; j++){
        cout<<q.front();
        q.pop();
        if(j<W-1) cout<<" ";
        else cout<<endl;
      }
    }
    else{
      ll j=0;
      for(; j<W; j++){
        st.push(q.front());
        q.pop();
      }
      while(j>0){
        cout<<st.top();
        st.pop();
        if(j>1) cout<<" ";
        else cout<<endl;
        j--;
      }
    }
  }
}

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

const int INF = 1000000007;

int H, W, c[10][10], A[209][209];

int main() {
    cin >> H >> W;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) cin >> c[i][j];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> A[i][j];
    }

    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == -1) continue;
            ans += c[A[i][j]][1];
        }
    }

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

Measured memory_bytes: 384
def ascan; gets.split.map(&:to_i);end

loop do
    n,r = ascan
    break if n == 0 && r == 0
    cards = (1..n).to_a.reverse
    r.times do
        i, c = ascan
        i-=1
        cards = (cards[i...(i+c)]||[]) + (cards[0...i]||[]) + (cards[(i+c)..-1]||[])
    end
    p cards[0]
end


Measured memory_bytes: 7136
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
ll i,j;
int main()
{IOS;
int t;
t=1;
while(t--)
{
	ll n;
	cin>>n;
	if(n%1000==0)cout<<0<<endl;
	else 
	{
		cout<<(((n/1000)+1)*1000)-n<<endl;
	}
}
return 0;}



Measured memory_bytes: 3648
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;

int main() {


	char s[5];
	scanf("%s", s);
	int n1 = 1, n2 = 0;
	char c1 = s[0], c2 = 0;
	for (int i = 1; i < 4; i++) {
		if (s[i] == c1) {
			n1++;
		}
		else if (s[i] == c2) {
			n2++;
		}
		else if (c2 == 0) {
			c2 = s[i];
			n2++;
		}
	}
	printf((n1 == 2 && n2 == 2) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>  
#include <cstring>  
#include <algorithm> 
using namespace std; 
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d)
    {
	    if(min(b,d)-max(a,c)<=0)cout<<0<<endl;
    	else cout<<min(b,d)-max(a,c)<<endl; 	
    }
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
cand = [0, 0, 0, 0, 0]
ans = 0
for i in range(N):
	if S[i][0] == 'M':
		cand[0] += 1
	elif S[i][0] == 'A':
		cand[1] += 1
	elif S[i][0] == 'R':
		cand[2] += 1
	elif S[i][0] == 'C':
		cand[3] += 1
	elif S[i][0] == 'H':
		cand[4] += 1
for i in range(len(cand)):
	for j in range(i + 1, len(cand)):
		for k in range(j + 1, len(cand)):
			ans += cand[i] * cand[j] * cand[k]
print(ans)

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int n;
    cin >> n;
    int p[n], q[n];
    rep(i, n) {
        cin >> p[i];
    }
    rep(i, n) {
        cin >> q[i];
    }

    std::vector<ll> v;
    rep(i, n) {
        v.push_back(i+1);
    }

    int ii = 1;
    int a = 0;
    int b = 0;
    do {
        int k = 0;
        int l = 0;
        rep(i, n) {
            if ( v[i] == p[i] && a == 0 ) {
                k++;
                //cout << "k = " << k << endl;
            }
            if ( v[i] == q[i] && b == 0 ) {
                l++;
                //cout << "l = " << l << endl;
            }
        }
        if ( k == n ) {
            //cout << "k == " << k << endl;
            a = ii;
        }
        if ( l == n ) {
            //cout << "l == " << l << endl;
            b = ii;
        }
        ii++;
        //cout << "ii = " << ii << endl;
    } while(next_permutation(ALL(v)));
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

signed main()
{
	int n,x,t;
	scanf("%d %d %d",&n,&x,&t);
	printf("%d\n",(int)ceil((double)n/(double)x)*t);
}

Measured memory_bytes: 3284
from collections import deque

A = deque(list(input()))
B = deque(list(input()))
C = deque(list(input()))

def main(A, B, C):
    u = A.popleft()
    while True:
        if u == "a":
            if len(A) == 0:
                return "A"
            u = A.popleft()
        elif u == "b":
            if len(B) == 0:
                return "B"
            u = B.popleft()
        else:
            if len(C) == 0:
                return "C"
            u = C.popleft()

print(main(A, B, C))



Measured memory_bytes: 3444
def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = max(A)

    while abs(right-left)>1:
        cent = (right+left)//2
        
        ct = 0
        for a in A:
            ct+=a//cent
            if a%cent==0:
                ct-=1
        
        if ct <= k:
            right=cent
        else:
            left=cent
    
    print(right)
main()

Measured memory_bytes: 30732
using System;
using System.Linq;
public class Program
{
    public static void Main()
    {
        var res = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        if(res[0] <= 8 && res[1] <= 8)
        {
            Console.WriteLine("Yay!");
        }
        else
        {
            Console.WriteLine(":(");
        }
    }
}

Measured memory_bytes: 11348
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N;
		N=scan.nextInt();
		int A[]=new int[N];
		int B[]=new int[N];
		int i,j;
		for(i=0;i<N;i++){
			A[i]=scan.nextInt();
			B[A[i]-1]=i+1;
		}
		for(i=0;i<N;i++){
			System.out.print(B[i]+" ");
		}
		
		
	}
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;

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

    int arr[n];

    int result = 0;

    REP(i, n) {
        cin >> arr[i];
    }

    int last = arr[0];
    int counter = 1;

    for (int i = 1; i < n; i++) {
        if (arr[i] == last) {
            counter++;
        } else {
            result += floor(counter / 2);
            last = arr[i];
            counter = 1;
        }
    }

    if (counter != 1) {
        result += floor(counter / 2);
    }

    cout << result;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define endl "\n"
#define with_tests int t; cin >> t; while(t--){ solve(); cout << endl; }
#define without_tests solve(); cout << endl;
#define CEIL(x, y) (ll)ceil((long double)(x)/(long double)(y))
#define epsilon 1e-9 
typedef long long ll;
const int mod = 1e9+7;
const int N = 3e3+1;

// vector<int> adj[N];
// int vis[N];
// int dp[N];
// int n, u, v;

// // int dp[N][N];

// int dfs(int u){

//     if(vis[u] == 1){
//         return dp[u];
//     }
//     vis[u] = 1;
//     for(int v: adj[u]){
//         dp[u] = max(dp[u], dfs(v)+1);
//     }
//     return dp[u];
// }


void solve(){
    
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> dp(k+1);
    for(int i=0; i<=k; i++){
        for(int j=0; j<n; j++){
            if(i >= a[j] && !dp[i-a[j]]){
                dp[i] = 1;
            }
        }
    }
    // for(int i=0; i<=k; i++){
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << (dp[k]? "First": "Second");

}

int32_t main(){

    fast_cin;
    // with_tests;
    without_tests;

    return 0;
}


Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[110];
int main(){
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n-2;i++){
		for(int j=i+1;j<=n-1;j++){
			for(int k=j+1;k<=n;k++){
				if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
					if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i])ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# 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 REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k, a[101010];
LL rui[101010];//rui[i]までの和
LL rui2[101010];

int main() {
	cin >> n >> k;
	REP(i, n)cin >> a[i];
	REP(i, n) {
		if (i) {
			rui2[i] = rui2[i - 1] + a[i];
			rui[i] = rui[i - 1] + (a[i] > 0 ? a[i] : 0);
		}
		else rui[i] = (a[i] > 0 ? a[i] : 0), rui2[i] = a[i];
	}
	LL ans = 0;
	REP(i, n - k + 1) {
		LL num = rui[i - 1] + (rui[n - 1] - rui[i + k - 1]);
		LL num2 = rui2[i + k - 1] - rui2[i - 1];
		ans = max(ans, max(num + num2, num));
	}
	cout << ans << endl;
}

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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    VI l(n), r(n);
    FOR(i,0,n-1) {
        cin >> l[i] >> r[i];
    }

    VI lMaxPref, lMaxSuff, rMinPref, rMinSuff;

    auto makePrefSuff = [&]() {
        lMaxPref = l, lMaxSuff = l;
        rMinPref = r, rMinSuff = r;

        FOR(i,1,n-1) {
            lMaxPref[i] = max(lMaxPref[i], lMaxPref[i-1]);
            rMinPref[i] = min(rMinPref[i], rMinPref[i-1]);
        }

        FORD(i,n-2,0) {
            lMaxSuff[i] = max(lMaxSuff[i], lMaxSuff[i+1]);
            rMinSuff[i] = min(rMinSuff[i], rMinSuff[i+1]);
        }
    };

    makePrefSuff();

    int ans = 0;

    FOR(i,0,n-1) {
        int here = r[i] - l[i] + 1;

        int lRest = 0;
        if (i > 0) lRest = max(lRest, lMaxPref[i-1]);
        if (i < n-1) lRest = max(lRest, lMaxSuff[i+1]);

        int rRest = 1e9 + 1;
        if (i > 0) rRest = min(rRest, rMinPref[i-1]);
        if (i < n-1) rRest = min(rRest, rMinSuff[i+1]);

        if (lRest <= rRest) {
            here += rRest - lRest + 1;
        }

        ans = max(ans, here);
    }

    VP pairs(n);
    FOR(i,0,n-1) pairs[i] = {l[i], r[i]};

    sort(pairs.begin(), pairs.end(), [&](const pii &a, const pii &b) {
        if (a.nd != b.nd) {
            return a.nd < b.nd;
        } else {
            return a.st > b.st;
        }
    });

    VP rest;

    for (auto &p : pairs) {
        if (rest.empty() || p.st > rest.back().st) {
            rest.push_back(p);
        }
    }

    n = SIZE(rest);

    if (n > 1) {
        l.resize(n);
        r.resize(n);

        FOR(i,0,n-1) {
            l[i] = rest[i].st;
            r[i] = rest[i].nd;
        }

        makePrefSuff();

        FOR(i,0,n-2) {
            int lLeft = lMaxPref[i], rLeft = rMinPref[i];
            int lRight = lMaxSuff[i+1], rRight = rMinSuff[i+1];

            int here = 0;

            if (lLeft <= rLeft) here += rLeft - lLeft + 1;
            if (lRight <= rRight) here += rRight - lRight + 1;

            ans = max(ans, here);
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    
    int n;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int r=0,b=0;
    char a;
    rep(i,n){
        cin >> a;
        if(a == 'R') r++;
        else b++;
    }
    if(r > b) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){
  int n;cin>>n;
  int h[n];
  REP(i,n){
    cin>>h[i];
  }
h[0]--;
  for(int i=0;i<n;i++){
    if(h[i-1] < h[i]){
      h[i]--;
    }else if(h[i-1] == h[i]){

    }else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

 

  return 0;
}

Measured memory_bytes: 640
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int h1, m1, h2, m2, k;

void read_input()
{
    cin >> h1 >> m1 >> h2 >> m2 >> k;
}

void solve()
{
    int cur1 = h1 * 60 + m1;
    int cur2 = h2 * 60 + m2;
    cur2 = cur2 - k - cur1;
    cout << cur2 << '\n';
}

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



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
int main(void){
	double a,s;
	int n;
	while (std::cin>>a){
		s=a;
		n=9;
		while(n--){
			(n%2)?a/=3:a*=2;
			s+=a;
		}
		printf ("%.8f\n",s);
	}
} 

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if (a%b==0) return b;
	gcd(b,a%b);
} 
int main(){
	int a,b;
	cin >> a >> b;
	if (a-b>0) cout << a-b << endl;
	else cout << 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    int a,b; cin >> a >> b;
    int ans = max(a+b, a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]

#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64
    }
    if a * n < b {
        println!("{}", a * n);
    } else {
        println!("{}", b);
    }
}

Measured memory_bytes: 4352
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  var output = [];
  var i = 0;
  while( '-' != data[i] ) {
    var cards = data[i++];  
    var m = data[i++];
    for( var j=0; j<m; j++ ) {
      var h = data[i++];
      cards = cards.substr( h )+cards.substr( 0, h );
    }
    output.push( cards );
  }
  console.log( output.join( '\n' ) );
});

Measured memory_bytes: 7640
A = [[0 for j in range(3)] for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())

N = int(input())

s = [[False for j in range(3)] for i in range(3)]
for k in range(N):
    b_k = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b_k:
                s[i][j] = True

bingo = False
if s[0][0] and s[0][1] and s[0][2]:
    bingo = True
if s[1][0] and s[1][1] and s[1][2]:
    bingo = True
if s[2][0] and s[2][1] and s[2][2]:
    bingo = True
if s[0][0] and s[1][0] and s[2][0]:
    bingo = True
if s[0][1] and s[1][1] and s[2][1]:
    bingo = True
if s[0][2] and s[1][2] and s[2][2]:
    bingo = True
if s[0][0] and s[1][1] and s[2][2]:
    bingo = True
if s[2][0] and s[1][1] and s[0][2]:
    bingo = True

if bingo:
    print('Yes')
else:
    print('No')


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

int main(void) {
	long long a, b, c;

	std::cin >> a >> b >> c;

	long long ans = 0;

	if (c <= a) {
		std::cout << b + c << std::endl;
		return 0;
	}

	ans += a;
	c -= a;

	if (c >= b) {
		std::cout << ans + b * 2 + (c == b ? 0 : 1) << std::endl;
		return 0;
	}

	std::cout << ans + b + c << std::endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())

answer = 0

for m in range(1, n+1):
    if m % 2 == 0:
        continue

    d = [1, m]

    for i in range(2, m//2 + 1):
        if m % i == 0:
            d.append(i)

    if len(d) == 8:
        answer += 1

print(answer)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import sys
N,M,X=map(int, sys.stdin.readline().split())
CA=[ map(int, sys.stdin.readline().split()) for _ in range(N) ]

ans=float("inf")

for n in range(2**N):
    #先頭列が金額、後は各アルゴリズムの理解度の合計値
    L=[ 0 for _ in range(M+1) ]
    for keta in range(N):
        if n%2==1:
            for i,t in enumerate(CA[keta]):
                L[i]+=t
        n/=2
        if X<=min(L[1:]):
            ans=min(ans,L[0])

if ans==float("inf"):
    print -1
else:   
    print ans

Measured memory_bytes: 93120
// abc126_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
	string S;
	cin >> S;
	int a = 10 * (S[0] - '0') + (S[1] - '0');
	int b = 10 * (S[2] - '0') + (S[3] - '0');
	bool a_month = false;
	bool b_month = false;
	if (a >= 1 && a <= 12) {
		a_month = true;
	}
	if (b >= 1 && b <= 12) {
		b_month = true;
	}
	if (a_month && b_month) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (a_month && !b_month) {
		cout << "MMYY" << endl;
	}
	else if (!a_month && b_month) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
using namespace std;
int n,m,E[100005][2];
bitset<405> s[405],c;
bool vis[405];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&E[i][0],&E[i][1]);
	for(int i=n;i;i--){
		s[i][i]=1;
		for(int p=m;p;p--){
			int x=E[p][0],y=E[p][1];
			if(s[i][x]&&s[i][y]){
				vis[i]=1;break;
			}
			if(!s[i][x]&&!s[i][y]) continue;
			s[i][x]=s[i][y]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int p=1;p<i;p++)if(!vis[i]&&!vis[p]){
			c=s[i]&s[p];
			if(!c.any()) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024