akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int H,W;

char field[10][10];

int main() {

	scanf("%d %d",&H,&W);

	int i,j;

	for (i = 0; i < H; i++) {
		scanf("%s", field[i]);

	}
	int ans = 0;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (field[i][j] == '#') { ans++; }
		}
	}
	if (ans == H + W - 1) { printf("Possible\n"); }
	else { printf("Impossible\n"); }

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int a[100005];

int main()
{
	int n;
	LL sum = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		sum = sum + abs(a[i] - a[i - 1]);
	}
	sum = sum + abs(a[n]);
	for(int i = 1; i <= n; i++)
	{
		LL p = sum;
		p = p - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]);
		p = p + abs(a[i + 1] - a[i - 1]);
		printf("%lld\n", p);
	}
}

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

int main(){
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  int X[5] = {x1, x2, x3, x4, x5};
  for (int i = 0; i < 5; i++) {
    if (X[i] == 0) {
      cout << i+1;
    }
  }
}

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

int main(){
  char moji[10];
  if(scanf("%s",moji)==1){}
  int len = strnlen(moji,10);
  int bubun = 0;
  int tmp,i,j;
  for(i=0;i<len;i++){
    tmp = 0;
    for(j=i;j<len;j++){
      if(moji[j]=='A'||moji[j]=='C'||moji[j]=='G'||moji[j]=='T')tmp++;
      else break;
    }
    if(tmp > bubun){
      bubun = tmp;
    }
  }
  printf("%d",bubun);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,r,ans;
int main()
{
    scanf("%d%d",&n,&r);
    if(n<10){
        ans=r+100*(10-n);
        printf("%d",ans);
    }else{
        ans=r;
        printf("%d",ans);
    }
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> wyst(n, 0);
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        --a[i];
        ++wyst[a[i]];
    }
    ll wsz = 0;
    for (int i = 0; i < n; ++i)
        wsz += (wyst[i] * (wyst[i] - 1)) / 2;
    for (int i = 0; i < n; ++i)
        cout << wsz - (wyst[a[i]] - 1) << endl;
    return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        int morning = h1 * 60 + m1;
        int evening = h2 * 60 + m2;
        int during = evening - morning;
        int answerTime = during - k;
        
        System.out.println(answerTime);
    }
}

Measured memory_bytes: 35812
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll s1 = a * c, s2 = a * d, s3 = b * c, s4 = b * d;
    s1 = max(s1, s2);
    s3 = max(s3, s4);
    cout << max(s1, s3) << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <ios>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <iomanip>
#include <cmath>

using namespace std;

const int N = (int) 2e5 + 5;
const int M = (int) 1e9 + 7;

typedef long long ll;

int n;
int a[N];
unordered_map<int, int> m;

ll calc(ll x) {
    return x * (x - 1) / 2;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++;

    ll sum = 0;
    for (auto &p: m) sum += calc(p.second);

    for (int i = 0; i < n; i++)
        cout << sum - m[a[i]] + 1 << endl;

    return 0;
}

Measured memory_bytes: 8392
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 1400
#define INF 100000000
using namespace std;
typedef long long ll;
int g[MAX+1][MAX+1],dp[MAX+1][MAX+1],maxsize;
struct rectangle {
	int height;
	int pos;
};
void init(int w,int h)
{
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(g[i][j]) dp[i][j]=0;
			else{
				dp[i][j]=(i>0)?dp[i-1][j]+1:1;
			}
		}
		dp[i][w]=0;//为了使得算法最终停止 
	}
}
void getBiggest(int w,int h)
{
	int mid;
	stack<rectangle> s;
	for(int i=0;i<h;i++)//每一行都计算一次； 
	{
		while(!s.empty()) s.pop();
		struct rectangle rects;
		for(int j=0;j<=w;j++)
		{
			rects.pos=j;rects.height=dp[i][j];
			if(s.empty()){
				s.push(rects);
			}else{
				if(s.top().height<rects.height){
					s.push(rects);
				}else if(s.top().height>rects.height){
					while(!s.empty()&&s.top().height>=rects.height){
						struct rectangle tmp;
						tmp=s.top();s.pop();
						mid=tmp.height*(j-tmp.pos);
						maxsize=max(maxsize,mid);//更新最大值 
						rects.pos=tmp.pos;//更新rect最左边坐标的位置以便入栈 
					}
					s.push(rects);
				}
				//else continue;
			}
			
		}
		
	}
}
int main()
{	
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			scanf("%d",&g[i][j]);
		}
	} 
	init(w,h);
	getBiggest(w,h);
	cout<<maxsize<<endl;
}


Measured memory_bytes: 18568
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define vvl vector<vl>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 1000005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main()
{
    ll n;cin>>n;
    vl a(n);
    f(n)cin>>a[i];
    sort(all(a));
    ll mp[N];
    fill(mp,0);
    f(n){
        mp[a[i]]++;
    }
    if(mp[1]>0){
        if(mp[1]==1){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
        return 0;
    }
    ll ans=0;
    f(n){
        bool flag=false;
        if(mp[a[i]]>1)continue;
        for(ll j=2;j<=sqrt(a[i]);j++){
            if(a[i]%j==0){
                if((a[i]/j)==j){
                    if(mp[j]>0){
                        flag=true;
                        break;
                    }
                }else{
                    if(mp[j]>0||mp[a[i]/j]>0){
                        flag=true;
                        break;
                    }
                }
            }
        }
        if(!flag){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n; cin>>n;
	int64_t t=n;
	unordered_map<int64_t,int64_t>m;
	for(int64_t i=2;i*i<=n;++i){
		while(t%i==0){
			++m[i];
			t/=i;
		}
	}
	if(t>1)++m[t];
	int64_t ans=0;
	for(auto&&i:m){
		int64_t sum=1;
		while(true){
			i.second-=sum;
			if(i.second>=0)++ans;
			else break;
			++sum;
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define  na
#define ll long long 
#define  ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define vvi vector<vector<int> >
#define vii vector<pair<int,int> >
#define pb push_back
#define inf 1000000007
#define f(i,a,b) for(i=a;i<b;i++)
#define re0 return 0
using namespace std;
bool cmp(pair<ll,int > &a,pair<ll,int > &b)
{  
    if(a.ff==b.ff)return a.ss<b.ss;
    
    return a.ff>b.ff;
}
vector<vector<int> > v(100001);
map<pair<int,int>,int>q;
int vis[100001];
int cc;
ll exp(ll j,ll n)
{
	ll i=n,res=1;
	
	while(j>0)
	{
		if(j&1)res*=i;
		res%=(ll)inf;
		 i=i*i;
		 i%=(ll)inf;
		j>>=1;
	}

	return (res-1ll)%(ll)inf;
}
void dfs(int node,int par)
{
    vis[node]=1;
	q[{min(par,node),max(par,node)}]=cc;
	cc--;
	
	for(auto child : v[node])
	{
		if(vis[child]==0)
		{
			dfs(child,node);
		}
	}	
}
int main()
{
	#ifdef ha
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
 
   ll s,i,j;
   cin>>s;
   
   if(s<3)
   {
   	cout<<0;re0;
   }
   ll dp[s+1];
   
   
   f(i,3,s+1)dp[i]=1;
   
   for(i=3;i<=s;i++)
   {
   	  for(j=3;j<=i-3;j++)
   	  {
   	  		dp[i]+=(dp[i-j])%inf;
   	  		dp[i]%=inf;
			 
		 }
   }
   cout<<dp[s];
}

Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e13+7;
ll int mod=(ll int)1e9+7;
ll int const N=(ll int)1e6+10;

ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}



int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij;
T=1;
//cin>>T;
while(T--)
{
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
        cout<<'A';
    else
        cout<<'a';

}
return 0;
}
















Measured memory_bytes: 3612
#include <stdio.h>

int main(void){
	int a[10000];
	int i,n;
	int max,min;
	long sum;

	scanf("%d",&n);
	if(n<=0){
		return 0;
	}

	max=-1000000;
	min=1000000;
	sum=0;

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

	printf("%d %d %ld\n",min,max,sum);

	return 0;
}

Measured memory_bytes: 636
{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import System.IO.Unsafe

newtype UnionFind = UnionFind (VM.IOVector Int, VM.IOVector Int)

findUF :: UnionFind -> Int -> Int
findUF (UnionFind (elems,_)) k = fix (\f (elems,k,path) ->
  case unsafePerformIO (VM.read elems k) of
    n | n == k -> 
      unsafePerformIO (forM_ path $ \p -> VM.write elems p n) `seq`
      n
    n -> f (elems,n,n:path)
  ) (elems,k,[k])

sizeUF :: UnionFind -> Int -> Int
sizeUF (UnionFind (_,sizes)) i = unsafePerformIO (VM.read sizes i)

unionUF :: UnionFind -> Int -> Int -> (UnionFind,Int)
unionUF uf@(UnionFind (elems,sizes)) i j =
  let !pi = findUF uf i; !pj = findUF uf j in
  let !si = sizeUF uf pi; !sj = sizeUF uf pj in
  let !sij = si + sj in
  if pi == pj
    then (uf,0)
    else
      (,)
        (UnionFind (
          unsafePerformIO $ (if si < sj then VM.write elems pi pj else VM.write elems pj pi) >> return elems,
          unsafePerformIO $ (if si < sj then VM.write sizes pj sij >> VM.write sizes pi 0 else VM.write sizes pi sij >> VM.write sizes pj 0) >> return sizes
        ))
        (si * sj)

comb2 k = k * (k - 1) `div` 2

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int
solve n m abs = unsafePerformIO $ V.freeze $ (\(_,_,acc) -> acc) $ V.foldr go (group, 0, unsafePerformIO $ VM.replicate m 0) abs
  where
    go (a,b) (uf,k,acc) =
      let (uf'@(UnionFind (!elems,!sizes)),d) = unionUF uf a b in
      let prev = if k == 0 then 0 else unsafePerformIO $ VM.read acc (k-1) in
        (uf', k+1, unsafePerformIO $ (VM.write acc k (prev+d) >> return acc))

    nC2 = comb2 n

    group :: UnionFind
    group = UnionFind (unsafePerformIO $ V.thaw $ V.enumFromN 0 n, unsafePerformIO $ VM.replicate n 1)

main = do
  let readInt = fmap (second B.tail) . B.readInt
  let readJustInt = fst . (\(Just x) -> x) . B.readInt

  nm <- V.unfoldrN 2 readInt <$> B.getLine
  abs <- V.replicateM (nm V.! 1) ((\vec -> (vec V.! 0 - 1, vec V.! 1 - 1)) . V.unfoldrN 2 readInt <$> B.getLine)

  let solutions =  solve (nm V.! 0) (nm V.! 1) abs
  let nC2 = comb2 $ nm V.! 0

  mapM_ (print . (nC2 -) . (solutions V.!)) [nm V.! 1 - 2, nm V.! 1 - 3 .. 0]
  print nC2


Measured memory_bytes: 38908
N = int(input())

A = []
for i in range(N):
    x = int(input())
    A.append(x)

new_A = sorted(A, reverse=True)

for i in range(N):
    if A[i] == new_A[0]:
        print(new_A[1])
    else:
        print(new_A[0])

Measured memory_bytes: 70360
//G
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
vector<int>G[maxn];
ll f[maxn];
ll dfs(int u){
	if(f[u])return f[u];
	f[u] = 1;
	for(int v:G[u])f[u] = max(f[u],dfs(v)+1);
	return f[u];
}
int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1;i <= m;i++){
		int f,t;
		cin >> f >> t;
		G[f].push_back(t);
	}
	for(int i = 1;i <= n;i++)dfs(i);
	ll ans = -1;
	for(int i = 1;i <= n;i++)ans = max(ans,f[i]);
	cout << ans-1;
	return 0;
}


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

using namespace std;

typedef long long ll;

int a[100031];

unordered_map<int, int> map1;

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

    int n;
    cin >> n;

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

    int ans = 0;
    for (auto x : map1)
    {
        if (x.second >= x.first) {
            ans += x.second - x.first;
        } else {
            ans += x.second;
        }
    }

    cout << ans;
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

const int N = 2e5 + 69;

int n;
int ar[N];
map<int, int> mp;

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }

  if(mp.find(1) != mp.end()) {
    if(mp[1] == 1)
      cout << 1 << '\n';
    else if(mp[1] > 1)
      cout << 0 << '\n';
    return 0;
  }

  int cnt = 0;
  for(int i = 1; i <= n; i++) {
    if(mp[ar[i]] > 1)
      continue;
    bool ok = true;
    for(int j = 2; j * j <= ar[i]; j++) {
      if(ar[i] % j == 0) {
        if(mp.find(j) != mp.end()) {
          ok = false;
          break;
        }
        if(mp.find(ar[i] / j) != mp.end()) {
          ok = false;
          break;
        }
      }
    }
    if(ok)
      cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 13744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double A = 0; double B = 0;
		A = Math.max(0, n-k+1);
		for(int L = 1; L <= Math.min(n, k-1); L++) {
			int l = L;
			int i = 0;
			while(true) {
				if(l >= k) {
					break;
				}else {
					i++;
					l = L * (int)Math.pow(2,i);
				}
			}
			B += Math.pow(0.5, i);
		}
		System.out.println((A+B)/n);
		sc.close();

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a, b, c;
    cin >> a;
    char q;
    cin >> b >> q >> c;
    b = b * 100 + c;
    cout << (a * b) / 100ll;
    return 0;
}




Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256
import Control.Monad

binaryAllSearch :: Int -> [[Int]]
binaryAllSearch n
 | n < 0    = [[]]
 | otherwise = [n:binaryElem | binaryElem <- binaryAllSearch (n - 1)] ++ binaryAllSearch (n - 1)

calcRemainBlackBlock :: [Int] -> [Int] -> Int -> Int -> [[Char]] -> Int
calcRemainBlackBlock row column h w sList
 = length [(i,j) | i<-[0..(h-1)],
                   j<-[0..(w-1)],
                   notElem i row,
                   notElem j column,
                   ((sList !! i) !! j) == '#']

main = do
 [h,w,k] <- map read . words <$> getLine
 sList <- replicateM h getLine
 print $ length $ [(row,column) | row<-binaryAllSearch (h-1),
                                  column<-binaryAllSearch (w-1),
                                  (calcRemainBlackBlock row column h w sList) == k]

Measured memory_bytes: 4944
#include<bits/stdc++.h>
const int maxn = 100001;
const int mod = 1e9 + 7;
typedef long long ll;
int n, m;
std::vector<int> v0, v1;
std::vector<std::pair<int,int>> v;
std::vector<int> o;
int a[maxn], f[maxn];
inline int id(int x){ return std::lower_bound(o.begin(),o.end(),x) - o.begin() + 1; } 
inline void reduce(int & x) { x += x >> 31 & mod; }
int main()
{
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	for(int i = 0, x;i < n;++i) std::cin >> x, v0.push_back(x);
	for(int i = 0, x;i < m;++i) std::cin >> x, v1.push_back(x);
	for(auto & i : v0) 
		if(v1.front() <= i && i <= v1.back()) {
			auto _ = std::lower_bound(v1.begin(),v1.end(),i);
			v.emplace_back(i - *std::prev(_),i - *_);
			o.push_back(*_ - i);
		}
	std::sort(o.begin(),o.end()), o.erase(std::unique(o.begin(),o.end()),o.end());
	std::sort(v.begin(),v.end()), v.erase(std::unique(v.begin(),v.end()),v.end());
	for(int i = 0;i < v.size();++i) {
		f[i]=1;
		for(int x = id(-v[i].second) - 1;x;x &= x - 1) reduce(f[i] += a[x] - mod);
		for(int x = id(-v[i].second);x < maxn;x += x & -x) reduce(a[x] += f[i] - mod);
	}
	int ans = 1;
	for(int i = 1e5;i;i &= i - 1) reduce(ans += a[i] - mod);
	std::cout << ans << '\n';
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, m;
char d[10005][105];
int cw[10005], ce[10005];

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

	cin >> n >> m;
	rep(j, 0, m) rep(i, 0, n) cin >> d[i][j];

	rep(i, 0, n) rep(j, 0, m) {
		if (d[i][j] == 'W') cw[i]++;
		if (d[i][j] == 'E') ce[i]++;
	}

	rep(i, 1, n + 1) {
		cw[i] += cw[i - 1];
		ce[i] += ce[i - 1];
	}

	// [0, i), [i, n), i.e. between i and i + 1
	int minv = 0x3f3f3f3f, bans;
	rep(i, 0, n + 1) {
		int we = i ? ce[i - 1] : 0;
		int ew = cw[n - 1] - (i ? cw[i - 1] : 0);
		//cout << i << "," << i + 1 << ": " << we << ", " << ew << endl;
		if (we + ew < minv) {
			minv = we + ew;
			bans = i;
		}
	}
	cout << bans << " " << bans + 1 << endl;
}



Measured memory_bytes: 4304
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int k, x;

int main(){
    cin >> k >> x;
    for(int i = x - k + 1;i <= x + k - 1;i++){
        if(i != x - k + 1)cout << " ";
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<ll> a(n + 2), b(m + 2);
    ll x;
    a[0] = b[0] = -1ll * mod * mod;
    a[n + 1] = b[m + 1] = 1ll * mod * mod;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    while (q--) {
        cin >> x;
        ll l1 = *--lower_bound(a.begin(), a.end(), x), r1 = *lower_bound(a.begin(), a.end(), x), l2 = *--lower_bound(b.begin(), b.end(), x), r2 = *lower_bound(b.begin(), b.end(), x);
        cout << min({abs(x - l1) + abs(l1 - l2), abs(x - l1) + abs(l1 - r2), abs(x - r1) + abs(r1 - l2), abs(x - r1) + abs(r1 - r2), abs(x - l2) + abs(l2 - l1), abs(x - l2) + abs(l2 - r1), abs(x - r2) + abs(r2 - l1), abs(x - r2) + abs(r2 - r1)}) << '\n';
    }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b, c; cin >> a >> b >> c;
  if (a < b) swap(a, b);
  if (b < c) swap(b, c);
  if (a < b) swap(a, b);
  ll cnt = 0;
  cnt += (a - b) / 2;
  cnt += (a - c) / 2;
  ll x = (a - b) % 2 + (a -c) % 2;
  if (x == 1) {
    cnt += 2;
  }else if (x == 2) {
    cnt += 1;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	int a, b;
	cin >> a >> b;
	loop(i, 1, 1001){
		int A, B;
		A = i*8/100;
		B = i/10;
		if(A == a && B == b){
			cout << i <<endl;
			return 0;
		}
	}
	cout << -1 <<endl;
	return 0;
}

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

int main()
{
  int N, A, B, P[100];
  cin >> N >> A >> B;
  for (int i=0; i < N; i++)
    cin >> P[i];

  // 3問の内何問目かでカウント
  int P1 = 0;
  int P2 = 0;
  int P3 = 0;
  for (int i=0; i < N; i++)
  {
    if (P[i] <= A) P1++;
    else if (A < P[i] & P[i] <= B) P2++;
    else if (B < P[i]) P3++;
  }
  // 最小を求める
  int min = P1;
  if (P2 < min) min = P2;
  if (P3 < min) min = P3;
  
  cout << min << endl;
  return 0;
}


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

#define MAX 101198
int prime[MAX];
int p[11000];

int main(){
  int i,j,k,l,m;
  prime[0]=-1;prime[1]=-1;
  for(k=0,i=2;i<MAX;i++)
    if(!prime[i])
      for(prime[i]=k,p[k++]=i,j=i*2;j<MAX;j+=i)
        prime[j]=-1;
  for(;scanf("%d%d",&l,&m),~l;){
    vector<int> v;
    for(l++;prime[l]<0;l++);
    for(i=prime[l];i<prime[l]+m;i++)
      for(j=i;j<prime[l]+m;j++)
        v.push_back(p[i]+p[j]);
    sort(v.begin(),v.end());
    printf("%d\n",v[m-1]);
  }
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int a,b; cin>>a>>b;
   cout << (a+b>a-b?(a+b>a*b?a+b:a*b):(a-b>a*b?a-b:a*b)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define	inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=2010;
int n,z,w;
int ara[S+5];

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
	while(~sf("%d %d %d",&n,&z,&w))
	{
		
		for(int i=1;i<=n;i++)sf("%d",&ara[i]);
		int mx=0;
		mx=max(mx,abs(ara[n]-w));
		if(n-1>=1)mx=max(mx,abs(ara[n]-ara[n-1]));
		pf("%d\n",mx);
	}
    return 0;
}































Measured memory_bytes: 3736
#!/usr/bin/env python
# coding: utf-8

def readInt():
    return int(input())

def readList():
    return list(input().split())

def readListI():
    return list(map(int, input().split()))

def pattern(n):
    ret = []
    for i in range(pow(2, n)):
        p = [0 for _ in range(n)]
        for j in range(n):
            if (i >> j) & 1:
                p[j] = 1
        ret.append(p)
    return ret

def main():
    n, m = readListI()
    lk = []
    lls = []
    for _ in range(m):
        d = readListI()
        k = d[0]
        ls = [s-1 for s in d[1:]]
        lk.append(k)
        lls.append(ls)
    lp = readListI()
    ret = 0
    for p in pattern(n):
        ok = True
        for i, ls in enumerate(lls):
            if sum(p[s] for s in ls) % 2 != lp[i]:
                ok = False
                break
        if ok:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    sort(ALL(a));
    int l = a.back();
    int s = accumulate(begin(a), end(a) - 1, 0LL);
    if (l < s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include <stack>
    #include <queue>
    #include <map>
    #include <set>
    #include <vector>
    #include <random>
    #include <cmath>
    #include <chrono>
    #include <cstring>
    #include <algorithm>
    #include <string>
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cassert>
    using namespace std;
    using LL = long long;
    #define eps 1e-8
    #define fi first
    #define se second
    #define eb emplace_back
    #define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
    #define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
    #define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
    #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pii;
    mt19937 dlsrand(random_device{}());
    mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
    int rnd(int x) { return mrand() % x;}
    LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
    inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
    const double PI = acos(-1.0);
    constexpr int maxn = 1e6+10;
    constexpr int INF = 0x3f3f3f3f;
    constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
    constexpr int mod = 1e9+7;
    void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
    void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
    int main()
    {
        ll a, b;
        cin >> a >> b;
        cout << min(a%b,abs(a%b-b));
    }

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>

#define P pair<int, int>
using namespace std;

int N;
pair<int, int> ab[100005];
int end[100005] = {0};

priority_queue< P, vector< P >, greater< P > > Q;

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> ab[i].first >> ab[i].second;
	}
	
	for(int i = 1; i <= N; i++){
		Q.push( ab[i] );
	}
	
	int num = 0;
	int max = 0;
	
	
	for(int i = 1; i <= 100005; i++){
		num -= end[i];
		while(Q.top().first == i && (int)Q.size()){
			num++;
			end[Q.top().second + 1]++;
			Q.pop();
		}
		
		if(num >= i-1) max = i;
		//if((int)Q.size() == 0) break;
	}
	
	end:
	cout << max-1 << endl;
	return 0;
}

Measured memory_bytes: 4904
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

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

    double debt = 100;    // * 1000 yen
    while (week--) {
        debt = ceil(debt * 1.05);
    }

    cout << fixed << setprecision(0)
         << (debt * 1000) << endl;

    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt1 = 0, cnt2 = 0;
    if(a%d == 0){
        cnt1 = a/d;
    }
    else{
        cnt1 = a/d + 1;
    }
    if(c%b == 0){
        cnt2 = c/b;
    }
    else{
        cnt2 = c/b + 1;
    }
    if(cnt1 >= cnt2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int main()
{
	int n, k;

	cin>>n>>k;
	int ans = 0;
	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans;
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<pair<long long, long long>> X;
  rep(i, N) {
    int x, l; cin >> x >> l;
    x -= l;
    l += l;
    X.emplace_back(x, l);
  }

  sort(X.begin(), X.end());

  const int INF = 1e9 + 10;

  int ans = 0;
  long long range = -INF;

  rep(i, N) {
    if (range <= X[i].first) {
      ans++;
      range = X[i].first + X[i].second;
    }
    else {
      range = min(range, X[i].first + X[i].second);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 2420
n = int(input())
dia = [[0,0,0] for _ in range(n)]
for i in range(n):
    t, x, y = map(int, input().split())
    dia[i][0] = t
    dia[i][1] = x
    dia[i][2] = y
t = 0
x = 0
y = 0
ans = "Yes"
for i in range(n):
    r = abs(dia[i][1] - x) + abs(dia[i][2] - y)
    if (dia[i][0] - t < r) or (dia[i][0] - t >= r and (dia[i][0] - t - r) & 1) :
        ans = "No"
        break
    t = dia[i][0]
    x = dia[i][1]
    y = dia[i][2]
print(ans)


Measured memory_bytes: 19572
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for(int i=a;i<b;i++)
#define repds(i,a,b) for(int i=a+1;i<=b;i++)
#define rep(i,N) repd(i,0,N)
#define reps(i,N) repds(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
typedef pair<int,int> P;
const int INF=100000000;
const int dx[4]={ 0, 1, 0,-1};
const int dy[4]={ 1, 0,-1, 0};
//--------------------------------------//
int a,b;

int main(){
	cin>>a>>b;
	if(a<=8&&b<=8) cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LSOne(S) ((S) & (-S))
using namespace std;

typedef long long ll;

const int MAXN = 2*1e5 + 10;

ll bit[MAXN],dp[MAXN];
ll h[MAXN],a[MAXN];
int N;

void update(int x, ll val){
	while(x <= N){
		bit[x] = max(bit[x],val);
		x += LSOne(x);
	}
}

ll query(int x){

	ll ans = 0;
	while(x > 0){
		ans = max(ans,bit[x]);
		x -= LSOne(x);
	}

	return ans;

}

int main(){

	scanf("%d",&N);

	for(int i = 1;i<=N;i++){
		scanf("%lld",&h[i]);
	}
	for(int i = 1;i<=N;i++){
		scanf("%lld",&a[i]);
	}

	for(int i = 1;i<=N;i++){
		dp[i] = query(h[i] - 1) + a[i];
		update(h[i],dp[i]);
	}

	ll best = 0;
	for(int i = 1;i<=N;i++) best = max(best,dp[i]);
	printf("%lld\n",best);

	return 0;

}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>

using namespace std;

const long long MOD = 1e9 + 7;

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

    vector<int> num(N);
    for (int i = 0; i < N; i++) {
        num[A[i]]++;
    }
    
    long long ans = 1;
    if (N%2) {
        if (num[0] != 1) ans = 0;
        for (int i = 1; i <= (N - 1)/2; i++) {
            if (num[2*i] != 2) ans = 0;
            else ans = ans*2%MOD;
        }
    } else {
        for (int i = 1; i <= N/2; i++) {
            if (num[2*i - 1] != 2) ans = 0;
            else ans = ans*2%MOD;
        }
    }

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

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, k, d;
    vector<int> f(10);
    scanf("%d%d", &n, &k);
    for (int i = 0; i < k; ++i) scanf("%d", &d), f.at(d) = 1;
    for (int i = n; ; ++i) {
        int o = 0;
        string s = to_string(i);
        for (auto j = s.begin(); j != s.end(); ++j) o |= f.at(*j - '0');
        if (o == 0) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
(defn solve [a b cnt]
  (if (>= a b)
    (inc cnt)
    (if (= cnt 0)
      (solve (dec a) (- b a) (inc cnt))
      (solve a (- b a) (inc cnt)))))

(let [a (int (read))
      b (int (read))]
  (println (if (= b 1) 0 (solve a b 0))))


Measured memory_bytes: 68744
#include <stdio.h>

 int main(void){
   int a,b;
   scanf("%d",&a);
   scanf("%d",&b);
   if(a>b)
   printf("%d",a+a-1);
   else if(a<b)
   printf("%d",b+b-1);
   else
   printf("%d",a+b);

   return 0;
 }


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long int n,m;
    cin>>n>>m;
    if(n*2<m){
        cout<<n + ( ( m-n*2) /4 )<<endl;
    }
    else {
        cout<<m/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
ll sum = 0;
int main(){
	cin>>n;
	int cur = 0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum += abs(cur-a[i]);
		cur = a[i];
	}
	sum += abs(cur-0);
	cur = 0;
	for(int i=1;i<=n;i++){
		int pre = (i==1?0:a[i-1]);
		int cur = a[i];
		int nxt = (i==n?0:a[i+1]);
		printf("%lld\n",sum-abs(pre-cur)-abs(cur-nxt)+abs(pre-nxt));
	}
}

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

using namespace std;
typedef long long Int;

const int MOD = 1000000007;
Int C[2002][2002];

int main()
{
  int N, K;
  
  scanf("%d %d", &N, &K);
  
  for (int i = 0; i <= N + 1; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
    }
  }
  
  for (int i = 1; i <= K; i++) {
    Int ans = C[K - 1][i - 1] * C[N - K + 1][i] % MOD;
    printf("%lld\n", ans);
  }
  
  return 0;
}

Measured memory_bytes: 30080
#include <iostream>
using namespace std;
int main(void){
    int n, a, b, c, x;
    while (cin >> n >> a >> b >> c >> x && n) {
        int f = -1;
        for (int i = 0; i < n; ++i) {
            int r;
            cin >> r;
            while (x != r && f <= 10000) {
                ++f;
                x = (a * x + b) % c;
            }
            ++f;
            x = (a * x + b) % c;
        }
        if (f <= 10000)
            cout << f << endl;
        else
            cout << -1 << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t k; cin >> k;

	if (!(k & 1) || (k % 10) == 5) {
		cout << -1 << endl;
		return 0;
	}

	int64_t r = 1;
	int64_t n = 0;
	int64_t c = 1;

	while (true) {
		n += r * 7;
		n %= k;
		if (n == 0) {
			cout << c << endl;
			return 0;
		}
		r = (r * 10) % k;
		c++;
	}

	return 0;
}

Measured memory_bytes: 3636
N,M = map(int,input().split())

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
L=[]
R=[]
for i in listA:
  L.append(i[0])
  R.append(i[1])
maxL = max(L)
minR = min(R)

count = 0
for i in range(1,N+1):
  if maxL <= i <= minR:
    count+=1
print(count)

Measured memory_bytes: 29000
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($D,$T,$S) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$T = $T * 60;
$t = ($D / $S) * 60;
if ($T >= $t) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = k; i <= n + 1; i++) {
    ans = (ans + i * (n - i + 1) + 1) % MOD;
  }

  cout << ans << endl;
}



Measured memory_bytes: 3640
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:24:09
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    vector<LL> lu(n+1);
    lu[0] = 2; lu[1] = 1;
    for (int i = 2; i <= n; i++) {
        lu[i] = lu[i-1] + lu[i-2];
    }

    cout << lu[n] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
    int K,A,B,ans;
  	scanf("%d%d%d",&K,&A,&B);
  for(int i= A;i<B+1;i++){
	if(i%K==0){
      ans++;
    }
  }
  if(ans!=0){
      printf("OK");
  }else{
    printf("NG");
  }
}

Measured memory_bytes: 3228
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    L = len(str(N))
    ans = sum(map(int, str(N)))

    for d in range(L):
        if str(N)[d] == "0":
            continue
        m = sum(map(int, str(N)[:d + 1])) - 1 + 9 * (L - (d + 1))
        if m > ans:
            ans = m

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
n = int(input())
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    house[b-1][f-1][r-1]+=v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" "+str(house[i][j][k]), end="")
        print()
    if i != 3:
        print("#"*20)


Measured memory_bytes: 5624
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    string res="";
    cin>>n>>s;
    int cnt=0;
    for(auto c:s){
        if(c=='('){
            res+='(';
            cnt++;
        }else{
            res+=')';
            cnt--;
            if(cnt<0){
                res='('+res;
                cnt=0;
            }
        }
    }
    for(int i=0;i<cnt;i++)res+=')';
    cout<<res<<endl;
}

Measured memory_bytes: 384
import Control.Monad.Trans.State( execStateT, get, modify)
main = do
    [n,a,b] <- return . map (read::String->Int) . words =<< getLine
    ranking <- getLine
    let ab = a+b
	judge [] _ = return ()
	judge (co:cos) (aw,bw)
	  | co=='c'    =
		modify (False:) >> judge cos (aw,bw)
	  | otherwise   = do
	    case co of
	     'a'	-> if ab>aw+bw
		then modify (True:) >> judge cos (aw+1,bw)
		else modify (False:) >> judge cos (aw,bw)
	     'b' -> if ab>aw+bw && b>bw
		then modify (True:) >> judge cos (aw,bw+1)
		else modify (False:) >> judge cos (aw,bw)
    result <- return . reverse =<<
		execStateT (judge ranking (0,0)) []
    mapM_ putStrLn $ map (\j->if j then "Yes" else "No") result

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    stack<ll> s;
    s.push(S[0] - '0');
    FOR(i, N, 1) {

        ll n = S[i] - '0';
        if (!s.empty()) {
            ll t = s.top();
            if (t != n) {
                s.pop();
                continue;
            }
        }

        s.push(n);

    }

    cout << N - s.size() << endl;
    return 0;
}

Measured memory_bytes: 1152
MOD = 10**9 + 7
list_size = 400001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % MOD)

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % MOD)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % MOD) * f_r_list[r - 1]) % MOD 
n, k = map(int, input().split())
k = min(k, n-1)
ans = comb(2*n-1, n)
for i in range(n-k-1):
	ans -= comb(n, i+1) * comb(n-1, i)
	ans %= MOD
print(ans)

Measured memory_bytes: 34676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    string s;
    cin >> s;
    int m=(s[5]-'0')*10+s[6]-'0';
    if(m>=5) cout <<"TBD" << endl;
    else cout <<"Heisei" <<endl;
  return 0;
}


Measured memory_bytes: 256