akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 2e5 + 10;

struct Sec{
	int l, r;
	void read() {
		scanf("%d%d", &l, &r);
	}
	bool operator < (const Sec &A) const {
		return l == A.l ? r < A.r : l < A.l;
	}
	Sec operator + (const Sec &A) const {
		return (Sec) { max(l, A.l), min(r, A.r) };
	}
}da[maxn], presec[maxn], sufsec[maxn];

int n;

int len(Sec s) {
	return max(0, s.r - s.l + 1);
}

int main()
{
	int ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		da[i].read();
		ans = max(ans, da[i].r - da[i].l + 1);
	}
	sort(da + 1, da + n + 1);
	presec[0] = (Sec) { -(1 << 30), (1 << 30) };
	sufsec[n + 1] = (Sec) { -(1 << 30), (1 << 30) };
	for (int i = 1; i <= n; ++i)
		presec[i] = presec[i - 1] + da[i];
	for (int i = n; i; --i)
		sufsec[i] = sufsec[i + 1] + da[i];
	for (int i = 1; i <= n; ++i)
		ans = max(ans, len(presec[i - 1]) + len(sufsec[i]));
	for (int i = 1; i <= n; ++i)
		ans = max(ans, len(presec[i - 1] + sufsec[i + 1]) + len(da[i]));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner kb = new Scanner( System.in);   
         
        while( true ) {
            int H = kb.nextInt();
            int W = kb.nextInt();
             
            if( 0==W && 0==H ) { break; }
             
            boolean cPattern=true;
            for( int i=0; i<H; i++ ) {
                cPattern= (0==(i%2))? true: false;
                for( int j=0; j<W; j++ ) {
                    if( cPattern ) {
                        System.out.print( "#" );
                        cPattern=!cPattern;
                    } else {
                        System.out.print( "." );
                        cPattern=!cPattern;
                    }
                }
                System.out.print( "\n" );
            }
            System.out.print( "\n" );
        }
    }
}

Measured memory_bytes: 31680
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
using namespace std;
int main() {
	string word;
	stack <int> S;
	while(cin >> word) {
		if (word == "+" ) {
			int n = S.top();
			S.pop();
			int m = S.top();
			S.pop();
			S.push(m+n);
		}
		else if (word == "-" ) {
			int n = S.top();
			S.pop();
			int m = S.top();
			S.pop();
			S.push(m-n);
		}
		else if (word == "*" ) {
			int n = S.top();
			S.pop();
			int m = S.top();
			S.pop();
			S.push(m*n);
		}
		else {
			int o = atoi(word.c_str());
			S.push(o);
		}
	}
	cout << S.top() << endl;
}

Measured memory_bytes: 1204
#include <iostream>

#include <algorithm>



constexpr int MAX_N=1001;



int n,m;

int P[MAX_N];



int Data[MAX_N*MAX_N];



int main() {
    while(1){
    std::cin>>n>>m;
    if(n+m==0)
    	break;

    for(int i=1;i<=n;++i)

        std::cin>>P[i];

    for(int i=0;i<=n;++i){

		for(int j=0;j<=n;++j)

	    	Data[i*(n+1)+j]=-(P[i]+P[j]);

    }

    std::sort(Data,Data+(n+1)*(n+1));

    int ans=0;

    for(int i=0;i<=n;++i){

		for(int j=0;j<=n;++j){

	   		int x=P[i]+P[j]-m;

	    	int* v=std::lower_bound(Data,Data+(n+1)*(n+1),x);

	    	if(v!=Data+(n+1)*(n+1))

				ans=std::max(ans,P[i]+P[j]-(*v));

		}

    }

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

    return 0;

}

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

int main(void){
        
   string s;
   int max = 0,count = 0;
   cin >> s;
   int len = s.size();
   
   for(int i=0;i<len;i++){
       if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') s[i] = ' ';
   }
   
   for(int i=0;i<len;i++){
       
       if(s[i] != ' '){
           count++;
       }
       else{
           if(max < count) max = count;
           count = 0;
       }
       
       if(i == len-1){
           if(max < count) max = count;
       }
   }

   cout << max << endl;
}

Measured memory_bytes: 3616
N,K = map(int,input().split())

ans = 0
if(K <= N+1):
 for i in range(K, N+1 +1):
  tmp = i*(N-i+1)+1 % (10**9 + 7)
  ans += tmp
  ans = ans % (10**9 + 7)  
    
print(ans)    

Measured memory_bytes: 9128
# 消費税率が 8 %のとき A 円、10 ％のとき B 円の消費税が課されるような商品の税抜き価格を求めてください。
# ただし、税抜き価格は正の整数でなければならないものとし、
# 消費税の計算において小数点以下は切り捨てて計算するものとします。
# 条件を満たす税抜き価格が複数存在する場合は最も小さい金額を出力してください。
# また、条件を満たす税抜き価格が存在しない場合は -1 と出力してください。

input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i

the_price = -1

10000.times do |i|
    price = i + 1
    tax_8 = price * 8 / 100.0
    tax_10 = price * 10 / 100.0
    if tax_8.to_i == a && tax_10.to_i == b
        the_price = price
        break
    end
end

puts the_price

Measured memory_bytes: 1788
a, b, c, x, y = gets.split(" ").map(&:to_i)
sum = 0
z = [x, y].min

if c * 2 <= a + b
  sum += z * c * 2
  x -= z
  y -= z
end

puts sum + [a, c * 2].min * x + [b, c * 2].min * y


Measured memory_bytes: 1788
#include <stdio.h>
main(){
  int x,y;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0)break;
    if(x<y){
      printf("%d %d\n",x,y);
    }
    else{
      printf("%d %d\n",y,x);
    }
  }
  return 0;
}

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

#include <vector>


int main(){
    int n,m;
    cin>>n>>m;
    
    int ans=0;
    int h[1000000]={};
    int best[1000000]={};
    long long cnt=0;
    /*
    for(int i=0;i<=n;i++){
        for(int j=0;j<n;j++){    
            add[i][j]=-1;
        }
    }
    */
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    
    for(int i=0;i<m;i++){
        int tmp1,tmp2;
        cin>>tmp1>>tmp2;
        
        if(best[tmp1]<h[tmp2]){
            best[tmp1]=h[tmp2];
        }
        if(best[tmp2]<h[tmp1]){
            best[tmp2]=h[tmp1];
        }
    }
    
    for(int i=1;i<=n;i++){
        if(best[i]<h[i]){
            cnt++;
        }
    }
    /*
    for(int i=0;i<m;i++){
        int tmp1,tmp2;
        int flag=0;
        cin>>tmp1>>tmp2;
        for(int k=0;k<cnt[tmp1];k++){
            if(add[tmp1][k]==tmp2){
                flag=1;
            }
        }
        if(flag==0){
            add[tmp1][cnt[tmp1]]=tmp2;
            add[tmp2][cnt[tmp2]]=tmp1;
            cnt[tmp1]++;
            cnt[tmp2]++;
        }
    }
    /*
    for(int i=1;i<=n;i++){
        for(int j=0;j<n;j++){
            cout<<add[i][j]<<" ";
        }
        cout<<"\n";
    }
    */
    /*
    for(int i=1;i<=n;i++){
        for(int j=0;j<n;j++){
            if(add[i][0]==-1){
                ans++;
                break;
            }
            if(h[i]<=h[add[i][j]]){
                break;
            }
            if(add[i][j]==-1){
                ans++;
                break;
            }
        }
    }
    */
    cout<<cnt<<"\n";
    return 0;
}            

Measured memory_bytes: 11392
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll i,j,n,q;
      cin>>n;
      vector<ll>a(n);
      map<ll,ll>mp;
      ll cur=0;
      for(i=0;i<n;i++)
      {
        cin>>a[i];
        mp[a[i]]++;
        cur+=a[i];
      }
      cin>>q;
      while(q--)
      {
        ll b,c;
        cin>>b>>c;
        cur-=b*(mp[b]);
        ll tmp=mp[b];
        cur+=c*tmp;
        mp.erase(b);
        if(mp.find(c)==mp.end())
          mp[c]=tmp;
        else mp[c]+=tmp;
        cout<<cur<<"\n";
      }
    }
    return 0;
   }

Measured memory_bytes: 19040
from scipy.sparse.csgraph import csgraph_from_dense,dijkstra,floyd_warshall
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
N,M,L =LI()
s = []
t = []
dp = [[inf] * (N) for _ in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    dp[a-1][b-1] = c
    dp[b-1][a-1] = c
Q = I()
for i in range(Q):
    a,b = LI()
    s.append(a-1)
    t.append(b-1)

for i in range(N):
    dp[i][i] = 0

#print(warshall_floyd(N,dp))
#d1 = [[0] * (N) for _ in range(N)]
#d1 = warshall_floyd(N,dp)
G = csgraph_from_dense(dp)
d1 = floyd_warshall(G)

newdp = [[inf] * (N) for _ in range(N)]
for i in range(N):
    for j in range(i+1,N):
        if d1[i][j]<=L:
            newdp[i][j] = 1
            newdp[j][i] = 1

for i in range(N):
    newdp[i][i] = 0
#print(newdp)
#print(warshall_floyd(N,newdp))
#d2 = [[0] * (N) for _ in range(N)]
#d2 = warshall_floyd(N,newdp)
G2 = csgraph_from_dense(newdp)
d2 = floyd_warshall(G2)

for i in range(Q):
    ans = d2[s[i]][t[i]]-1
    if ans!= inf:
        print(int(ans))
    else:
        print("-1")

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

int main(){
  int n;

  while(cin >> n, n){
    int minVal = INT_MAX;
    int maxVal = INT_MIN;

    for(int i = 0; i < n; i++){
      int sum = 0;

      for(int j = 0; j < 5; j++){
	int x;
	cin >> x;
	sum += x;
      }

      minVal = min(minVal, sum);
      maxVal = max(maxVal, sum);
    }

    cout << maxVal << " " << minVal << endl;
  }
}

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

t = list(map(int,input().split()))

goukei=sum(t)

ans = 10000000000000

fir = 0

for i in range(n-1):
    fir += t[i]
    sec = goukei-fir
    ans = min(ans,abs(sec-fir))
print(ans)

Measured memory_bytes: 76880
#include<iostream>
#include<algorithm>
int main()
{
  int N;std::cin>>N;
  int max=0,sum=0;
  for(int i=0,p;i<N;i++){std::cin>>p,max=std::max(max,p),sum+=p;}
  std::cout<<sum-max/2<<std::endl;
  return 0;
}

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

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
        var n = input[0];
        var k = input[1];
        var sunuke = new Dictionary<int, int>(n);
        for(var i = 0; i < n; ++i){
            sunuke.Add(i + 1, 0);
        }
        
        for(var i = 0; i < k;++i){
            var d = Int32.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x));
            foreach(var j in a){
                sunuke[j] += 1;
            }
        }
        
        var ret = sunuke.Where(x => x.Value == 0).ToList();
        Console.WriteLine(ret.Count);
    }
}


Measured memory_bytes: 19668
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	string s;
	cin>>s;
	if(s=="SUN")
		puts("7");
	else if(s=="MON")
		puts("6");
	else if(s=="TUE")
		puts("5");
	else if(s=="WED")
		puts("4");
	else if(s=="THU")
		puts("3");
	else if(s=="FRI")
		puts("2");
	else if(s=="SAT")
		puts("1");
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a;cin >> n >> a;
	cout << n*n-a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll a[100001];
VI e[100001];
bool f = true;

ll dfs(int now, int past){
    ll sum = 0;
    if (e[now].size() == 1) return a[now];
    ll ma = 0;
    REP(i,e[now].size()){
        int next = e[now][i];
        if (next == past) continue;
        ll x = dfs(next, now);
        sum += x;
        ma = max(ma, x);
    }
    ll ret = 2*a[now] - sum;
    if (a[now] < ma) f = false;
    if (ret < 0 || ret > sum) f = false;
    // printf("now %d a %d sum %lld\n", now, a[now], sum);
    return ret;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) scanf("%lld", &a[i]);
    REP(i,n-1){
        int x, y;
        scanf("%d %d", &x, &y);
        x--;
        y--;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    if (n == 2){
        cout << (a[0] == a[1] ? "YES" : "NO") << endl;
        return 0;
    }

    int root;
    REP(i,n) if (e[i].size() > 1) root = i;
    // printf("root %d\n", root);

    if (dfs(root,-1) > 0) f = false;

    cout << (f ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 13568
program ec12;
var 
	n,m,i,j,x,max:longint;
	a:array[0..100002] of longint;
begin 
	fillchar(a,sizeof(a),0);
	readln(n);
	for i:=1 to n do 
	begin
		read(x);
		inc(a[x]);
	end;
	max:=a[0]+a[1];
	for i:=1 to 100000 do 
	begin 
		if max<a[i]+a[i-1]+a[i+1] then 
		max:=a[i]+a[i-1]+a[i+1];
	end;
	writeln(max);
end. 

Measured memory_bytes: 512
process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const arr = n.split(' ');
    const a = Number(arr[1]);
    const r2 = Number(arr[2].replace("\n", ""));
    const l2 = Number(arr[0]);
    if (l2<a&&a<r2){
        console.log("Yes");
    }else{
        console.log("No");
    }
});


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

int main(){
    int n;cin>>n;
    map<int,int> m;
    
    int a;
    for(int i=0; i<n; i++){
        cin>>a;
        m[a]++;
    }
    
    vector<int> b(1000001,0);
    int ans = 0;
    for(auto p : m){
        int x = p.first;
        int c = p.second;
        for(int i=x; i<=1000000; i+=x){
            b[i] += c;
        }
        if(b[x]==1)ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16292
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
  int m, n;
  int q[20][20];
  int cnt[20]={0};

  cin >> m >> n;

  for(int i = 0 ; i < m ; i++) {
    for(int j = 0 ; j < n ; j++) {
      cin >> q[i][j];
      if(q[i][j] == 1) cnt[i]++;
    }
  }
  sort(cnt, cnt+m);
  
  cout << cnt[m-1] << endl;
  return 0;
}

Measured memory_bytes: 0
op = 'a'

while op != '?':
    a, op, b = input().split()
    if op == '+':
        print(int(a)+int(b))
    elif op == '-':
        print(int(a)-int(b))
    elif op == '*':
        print(int(a)*int(b))
    elif op == '/':
        print(int(a)//int(b))
    else:
        break



Measured memory_bytes: 5596
let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0], m = nl[1], q = nl[2]
var a = [Int](repeating: 0, count: q)
var b = [Int](repeating: 0, count: q)
var c = [Int](repeating: 0, count: q)
var d = [Int](repeating: 0, count: q)
var maybeMax = 0
for i in 0..<q {
  let s = readLine()!.split(separator: " ").map { Int($0)! }
  a[i] = s[0]; b[i] = s[1]; c[i] = s[2]; d[i] = s[3]
}

func solve(f: [Int], n: Int, range: Range<Int>) {
  if f.count != n {
    for i in range {
      solve(f: f + [i], n: n, range: i..<range.max()! + 1)
    }
  } else {
    var t = 0
    for i in 0..<q {
      if f[b[i] - 1] - f[a[i] - 1] == c[i] {
        t += d[i]
      }
    }
    maybeMax = max(t, maybeMax)
  }
}
solve(f: [], n: n, range: 1..<m+1)
print(maybeMax)

Measured memory_bytes: 8300
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int used[8], ans = 0;
vector<vector<int> > g(8);
int n, m;

void dfs(int u) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (used[i]) sum++;
    }
    if (sum == n - 1) ans++;
    for (int i = 0; i < (int)g[u].size(); i++) {
        if (used[g[u][i]] == 0) {
            used[u] = 1;
            dfs(g[u][i]);
            used[u] = 0;
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    N = int(input())
    H = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        ok = True
        for j in range(i):
            if H[j] > H[i]:
                ok = False
                break
        ans += ok

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

mod = 10**9+7

n = int(input())
g = [[] for _ in range(n)]

pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
    pow2[i+1] = pow2[i]*2 % mod

for _ in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

par = [-1]*n
depth = [-1]*n
sizesub = [1 for _ in range(n)]
black = [0 for _ in range(n)]

root = 0
stack = [root]

while stack:
    v = stack.pop()
    if depth[v] == -1:
        if v == root:
            depth[v] = 0
        else:
            depth[v] = depth[par[v]] + 1
            stack.append(v)
        for w in g[v]:
            if depth[w] == -1:
                par[w] = v
                stack.append(w)
    else:
        sizesub[par[v]] += sizesub[v]
        black[par[v]] += pow2[sizesub[v]] - 1


cnt = 0

for i in range(n):
    tmp = pow2[n-1] - pow2[n-sizesub[i]] - black[i]
    tmp %= mod
    cnt += tmp
    cnt %= mod


def inv(a, mod):
    r = [1, 0, a]
    w = [0, 1, mod]
    while w[2] != 1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = w
        w = r_new
    x, y = w[0], w[1]    # a*x+y*mod = 1
    return (mod+x % mod) % mod


print(inv(pow2[n], mod)*cnt % mod)


Measured memory_bytes: 91992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1){
			System.out.println(1);
		}else{
			int ans=1;
			for(int i=1; i<8; i++){
				ans = ans*2;
				if ( n < ans) break;
			}
			System.out.println(ans/2);
		}

	}
}


Measured memory_bytes: 23636
#include <iostream>
using namespace std;
int N, A[1024],Max,Min,Sum;

int main(){
 while(cin >> N && N>0){
 Max=0;
 Min=1000;
  for (int i=0; i<N; ++i)
    cin >> A[i];
  for (int j=0; j<N; ++j){
	if(A[j]>Max) Max=A[j];
    }
  for (int k=0; k<N; ++k){
	if(A[k]<Min) Min=A[k];
	}
  for (int l=0; l<N; ++l){
    Sum += A[l];
	}
  cout<< (Sum-Max-Min)/(N-2) << endl;
  Sum=0;
 }
}	

Measured memory_bytes: 1164
#区間ごとの面積を計算する
def calc_area(v_end, v_start, v_max, dt):
    kouten_v = (v_end + v_start + dt) / 2
    kouten_t = kouten_v - v_start
    if 0 < kouten_t < dt:
        area = (v_start + kouten_v) * kouten_t / 2 #左側
        area +=  (v_end + kouten_v) * (dt - kouten_t) / 2 #右側
        area -=  max(0, (kouten_v - v_max))** 2 #上の三角形
    else:
        area = (v_start + v_end) *  dt / 2
    return area

def main():
    #与えられた入力を受け取る
    n=int(input())
    t=[int(i) for i in input().split()]
    v=[int(i) for i in input().split()]

    #各区間の許容最大速度を計算する
    #（この段階では傾きが-1未満になる可能性がある）
    max_velocity = [0]
    for i in range(1, n):
        max_velocity_ = min(v[i-1], v[i], max_velocity[i-1] + t[i-1])
        max_velocity.append(max_velocity_)
    max_velocity.append(0)

    #後ろから走査して、傾きが-1以上を満たすように許容速度をfittingする
    for i in range(n-1):
        if  max_velocity[-(i+1)] - max_velocity[-(i+2)] < -t[-(i+1)]:
            max_velocity[-(i+2)] = max_velocity[-(i+1)] + t[-(i+1)]

    #各区間の面積を計算して足し合わせる
    ans = 0
    for i in range(n):
        ans += calc_area(max_velocity[i+1], max_velocity[i], v[i], t[i])
    print(ans)

main()


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define dd c=getchar()
inline int read(){
	int a=0,b=1,dd;
	while(!isdigit(c)){if(c=='-')b=-b;dd;}
	while(isdigit(c)){a=a*10+c-'0';dd;}
	return a*b;
}
inline void print(int x){
	static int c[23];
	static int n;
	if(x==0){
		putchar('0');
		return;
	}
	if(x<0){
		putchar('-');
		x=-x;
	}
	n=0;
	while(x>0){
		c[n++]=x%10;
		x/=10;
	}
	while(n-->0){
		putchar(c[n]+'0');
	}
}
inline void printsp(int x){
	print(x);
	putchar(' ');
}
inline void println(int x){
	print(x);
	putchar('\n');
}
#undef dd
int n,ans;
char s[3][1003];
int main(){
	n=read();
	ans=0;
	scanf("%s%s%s",s[0],s[1],s[2]);
	for(int i=0;i<n;i++){
		char&a=s[0][i],&b=s[1][i],&c=s[2][i];
		if(a==b&&b==c){
			ans+=0;
		}else if(a==b||b==c||a==c){
			ans+=1;
		}else{
			ans+=2;
		}
	}
	println(ans);
	return 0;
}

Measured memory_bytes: 256
h,w,d=map(int,input().split())
D=dict()
for i in range(h):
  A=[int(i) for i in input().split()]
  for j in range(w):
    D[A[j]]=[i+1,j+1]
def Dist(x,y):
  return abs(D[x][0]-D[y][0])+abs(D[x][1]-D[y][1])
T=[[0 for _ in range((h*w)//d)] for _ in range(d)]
for i in range(d):
  for j in range((h*w)//d):
    if i+1+d*(j+1)>h*w:
      continue
    elif j==0:
      T[i][j]=Dist(i+1,i+1+d)
    else:  
      T[i][j]=T[i][j-1]+Dist(i+1+d*j,i+1+d*(j+1))
q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  x=l%d
  if r==x:
    print(0)
  elif l==x and x!=0:
    print(T[x-1][(r-x)//d-1])
  elif l==x and x==0:
    print(T[x-1][(r-x)//d-2])
  else:
    ll=(l-x)//d-1
    rr=(r-x)//d-1
    if x==0:
      ll-=1
      rr-=1
    print(T[x-1][rr]-T[x-1][ll])

Measured memory_bytes: 32160
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

bool kisu(int x) { return to_string(x).size() % 2 == 1 ? true : false; }

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (kisu(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x[500010];
char s[500010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%s",&s);
	n=strlen(s);
	reverse(s,s+n);
	for(i=0;i<n;i++)
	  x[i]=(s[i]-'0')*9;
	for(i=0;i<n;i++)
      while(x[i]>9)
        {
         x[i]-=10;
         x[i+1]++;
        }
	for(i=0,k=0;i<=n;i++)
	  k+=x[i];
	for(i=0;k>i*9;i++)
	  {
       x[0]+=9;
       k+=9;
       for(j=0;x[j]>9;j++)
         {
          x[j]-=10;
          x[j+1]++;
          k-=9;
         }
      }
    printf("%d\n",i);
	return 0;
}


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

using namespace std;

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int d, g;
  int p[10], c[10];
  fscanf(stdin, "%d%d ", &d, &g);
//FILE *fp = fopen("C/test/sample-2.in", "r");
//fscanf(fp, "%d%d ", &d, &g);
  g /= 100;
  REP(i,d) {
    fscanf(stdin, "%d%d ", p+i, c+i);
//fscanf(fp, "%d%d ", p+i, c+i);
    c[i] /= 100;
  }
//fclose(fp);
  int res = 1e9;
  REP(i,1<<d) {
    int x = 0, y = 0;
    REP(j,d) if (i&(1<<j)) {
      x += p[j]*(j+1) + c[j];
      y += p[j];
    }
    if (g <= x) {
      res = min(res, y);
      continue;
    }
    for (int j=d-1; j>=0; j--) {
      if ((i&(1<<j))) continue;
//    REP(j,d) if (!(i&(1<<(d-1-j)))) {
//      int q = (g-x)/(j+1); if ((g-x)%(j+1)) q++;
      int q = (g-x)/(j+1); if ((g-x)%(j+1)) q++;
      if (p[j] <= q) continue;
      if (g <= x + q*(j+1)) {
        res = min(res, y+q);
        break;
      }
    }
  }
  fprintf(stdout, "%d\n", res);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int sec, time = 0;
	int x, y;
	
	for (int i=0; i<4; i++)
	{
		cin >> sec;
		time += sec;
	}
	
	x = time / 60;
	time %= 60;
	y = time;
	
	cout << x << endl << y << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    ll p=1;
    int n;
    cin >>n;
    for(int i=0;i<n;i++){
        p *=(i+1);
        p =p%(1000000007);
    }
    cout << p <<endl;
}


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

int a[100010];
vector<int>bad;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 1;
	if (n > 1) {
		for (int i = 1; i < n; i++) {
			if (a[i - 1] == a[i]) {
				count++;
			}
			else {
				if (count != a[i - 1]) {
					if (count > a[i - 1]) {
						bad.push_back(count - a[i - 1]);
					}
					else {
						bad.push_back(count);
					}
				}
				count = 1;
			}
			if (i == n - 1) {
				if (count != a[i - 1]) {
					if (count > a[i - 1]) {
						bad.push_back(count - a[i - 1]);
					}
					else {
						bad.push_back(count);
					}
				}
				count = 1;
			}
		}
	}
	else {
		if (a[0] != 1) {
			bad.push_back(1);
		}
	}
	int ans = 0;
	for (int i = 0; i < bad.size(); i++) {
		ans += bad[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;

vector<int> mp[N];
typedef pair<int, int> P;

void bfs(int n)
{
    queue<P> q;
    int vis[N];
    memset(vis, 0, sizeof(vis));
    vis[1] = 1; vis[n] = 2;
    int a = 0, b = 0;
    q.push(make_pair(1, 1));
    q.push(make_pair(n, 2));
    while(!q.empty())
    {
        P cur = q.front(); q.pop();
        for(int j = 0; j < mp[cur.first].size(); j++)
        {
            int v = mp[cur.first][j];
            if(!vis[v])
            {
                q.push(make_pair(v, cur.second));
                vis[v] = cur.second;
            }
        }
    }
    for(int i = 1; i <= n; i++)
    {
        if(vis[i] == 1) a++;
        if(vis[i] == 2) b++;
    }
    if(a > b) puts("Fennec");
    else puts("Snuke");
}

int main()
{
    int n, u, v;
    scanf("%d", &n);
    for(int i = 1; i < n; i++)
    {
        scanf("%d%d", &u, &v);
        mp[u].push_back(v);
        mp[v].push_back(u);
    }
    bfs(n);
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define MAX_V 1005
#define M 1000000007
using namespace std;
typedef long long ll;

int V; //????????°
vector<int> G[MAX_V]; //??°???????????£??\??????????????¨???
vector<int> rG[MAX_V];//?????????????????????????????°??????
vector<int> vs;       //??°?????????????????????
bool used[MAX_V];     //?????§???????????????
int cmp[MAX_V];       //?±????????????£?????????????????????????????????

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);
  return k;
}

int used2[MAX_V];

ll dfs2(int x){
  if(used[x])return 1;
  used[x]=true;
  ll res=1;
  for(int i=0;i<rG[x].size();i++){
    int nx=rG[x][i];
    ll r=dfs2(nx);
    if(cmp[x]==cmp[nx])r--;
    if(!r)r=1;
    res=(res*r)%M;
  }
  return res+1;
}

int main(){
  int n,m,s,d;
  int goal[MAX_V];
  cin>>n>>m;
  V=n;
  for(int i=0;i<n;i++)goal[i]=1;
  for(int i=0;i<m;i++){
    cin>>s>>d;
    s--; d--;
    add_edge(s,d);
  }
  int k=scc();
  for(int i=0;i<n;i++)
    for(int j=0;j<G[i].size();j++){
      int x=G[i][j];
      if(cmp[i]!=cmp[x])
	goal[cmp[i]]=0;
    }
  ll ans=1;
  for(int i=0;i<n;i++){
    if(!goal[cmp[i]])continue;
    memset(used,0,sizeof(used));
    ans=(ans*dfs2(i))%M;
    goal[cmp[i]]=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int N;
ll K, A[101010];
ll dp[50][2];


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

  for(long long i=0; i<N; i++)
    cin >> A[i];

  for(int i=0; i<50; i++)
      dp[i][0] = dp[i][1] = -1;
    


  long long Amax=0;
  for(int i=0; i<N; i++)
    chmax(Amax, A[i]);

  dp[0][0]=0;
  for(int digit=0; digit<44; digit++)
    {
      long long mask = 1LL << 43-digit;
      int num = 0;

      for(int i=0; i<N; i++)
	{
	  if(mask & A[i])//下からdigit目の桁が1ならnum++
	    num++;
	}

      //XORだから，1のほうが多いときはXのdigitは0
      long long diff0 = mask * num;   //diff0の0はnumが1である．Xのdigitは0
      long long diff1 = mask * (N-num);   //

      //dp[digit][smaller]


	  //smaller->smaller : smallerが存在する場合に限る
	  if(dp[digit][1]>=0)
	    {
	      dp[digit+1][1] = max(dp[digit][1] + diff1, dp[digit][1] + diff0);
	    }

	  //if(dp[digit][0]>=0) //なぜ，これで
	  //{
	      if(K&mask)  //1が立ってる
		{
		  //limit->smaller
		  chmax(dp[digit+1][1], dp[digit][0]+diff0);
		  
		  //limit->limit
		  chmax(dp[digit+1][0], dp[digit][0]+diff1);
		}
	      else
		{
		  //limit->limit
		  chmax(dp[digit+1][0], dp[digit][0]+diff0);
		}
	      //}
    }

  cout << max(dp[44][0], dp[44][1]) << endl;
  


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

// int n;

// int dfs(int now,int nxt,int bit) {
//     int nn = now*10 + nxt;
//     if(nn > n) {
//         if(bit != 7) return 0;
//         else {
//             if(nxt==3) return 1;
//             else if(nxt==5) {
//                 if(nn-2 > n) {
//                     return 0;
//                 } else {
//                     return 1;
//                 }
//             } else {
//                 if(nn-2>n) {
//                     return 0;
//                 } else {
//                     return 1;
//                 }
//             }
//         }
//     }
//     int mask = ((nxt-1)/2)-1;
//     bit |= (1<<mask);
//     // cout << nn << " " << bit <<endl;
//     // if (bit == 7) {
//     //     return dfs(nn,3,sum+1,bit) + dfs(nn,5,sum+1,bit) + dfs(nn,7,sum+1,bit);
//     // } else{
//     //     return dfs(nn,3,sum,bit) + dfs(nn,5,sum,bit) + dfs(nn,7,sum,bit);
//     // }
//     return dfs(nn,3,bit) + dfs(nn,5,bit) + dfs(nn,7,bit);
//     // int p=0;
//     // if(nn * 10 + 3 > n) {
//     //     if(bit == 7) return p+1;
//     //     else return 0;
//     // } else {
//     //     p+=dfs(nn,3,bit);
//     // }
//     // if(nn * 10 + 5 > n) {
//     //     if(bit == 7) return p+1;
//     //     else return 0;
//     // } else {
//     //     p+=dfs(nn,5,bit);
//     // }
//     // if(nn * 10 + 7 > n) {
//     //     if(bit == 7) return p+1;
//     //     else return 0;
//     // } else {
//     //     p+=dfs(nn,7,bit);
//     // }
//     // return p;
// }

// int main () {
//     cin>>n;
//     int ans = dfs(0,3,0) + dfs(0,5,0) + dfs(0,7,0);
//     cout<<ans<<endl;
// }

int main () {
    ll n;cin>>n;
    int ans=0;
    queue<P> que;
    que.push(P(3,1));
    que.push(P(5,2));
    que.push(P(7,4));

    while(1) {
        P p = que.front();que.pop();
        ll now = p.first;int bit = p.second;
        if(now > n) break;
        if(bit == 7) ans++;
        que.push(P(now*10+3,bit|1));
        que.push(P(now*10+5,bit|2));
        que.push(P(now*10+7,bit|4));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4572
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a <= 0 && 0 <= b {
		fmt.Println("Zero")
		return
	} else if 0 < a && 0 < b {
		fmt.Println("Positive")
		return
	} else if a < 0 && 0 < b {
		fmt.Println("Negative")
		return
	}

	if (a-b)%2 == 0 {
		fmt.Println("Negative")
	} else {
		fmt.Println("Positive")
	}
}


Measured memory_bytes: 512
#include<iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  int A,B;
  string s = "Balanced";

  A = a+b;
  B = c+d;

  if (A<B) s = "Right";
  else if(A>B) s = "Left";

  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  int max = 0;
  int ans = 0;
  rep(i,n){
    if(h.at(i)>=max){
      ans++;
      max=h.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#coding:utf-8
N=input()
A=map(int,raw_input().split())
ans=0
s=0
r=0
for l in range(N):
    while (r<N and s+A[r]==s^A[r]):
        s+=A[r]
        r+=1
    ans+=r-l
    if l==r:r+=1
    else: s-=A[l]
print(ans)    




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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    int N;
    cin >> N;
    set<string> S;
    string s;
    cin >> s;
    S.insert(s);
    char pre = s.back();
    for (int i = 0; i < N - 1; i++) {
        string s;
        cin >> s;
        if (S.find(s) != S.end()) {
            cout << "No" << endl;
            return;
        }
        if (pre != s[0]) {
            cout << "No" << endl;
            return;
        }
        pre = s.back();
        S.insert(s);
    }
    cout << "Yes" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val number_of_piece = io.StdIn.readInt
    val numbers         = io.StdIn.readLine.split( " " ).map{_.toInt}
    val operation_num   = io.StdIn.readInt

    var operations: Vector[ ( Int, Int ) ] = Vector.empty
    var nums_map: Map[ Int, Int ]          = Map.empty

    ( 0 until operation_num ).foreach { i =>
      val operation = io.StdIn.readLine.split( " " ).map{_.toInt}
      operations = operations :+ ( operation( 0 ), operation( 1 ) )
    }

    numbers.foreach { i =>
      if( nums_map.contains( i ) ) nums_map += i -> ( nums_map( i ) + 1 )
      else                         nums_map += i -> 1
    }

    var sum = -1.toLong

    operations.foreach { i =>
      var changing_num_of_piece = 0
      if( nums_map.contains( i._1 ) ) {
        changing_num_of_piece = nums_map( i._1 )
        if( nums_map.contains( i._2 ) ) nums_map += i._2 -> ( nums_map( i._1 ) + nums_map( i._2 ) )
        else                            nums_map += i._2 -> nums_map( i._1 )
        nums_map += i._1 -> 0
      }

      if( sum < 0 ) sum = calcSumOfNumsMap( nums_map )
      else          sum += ( ( i._2 - i._1 )*changing_num_of_piece ).toLong
      println( sum )
    }
  }

  def calcSumOfNumsMap( nums_map: Map[ Int, Int ] ): Long = {
    var sum = 0.toLong

    nums_map.foreach{ i =>
      sum += ( i._1 * i._2 ).toLong
    }

    return sum
  }
}

Measured memory_bytes: 84780
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, maks=-1, arr[20];
vector<ll>b[20], c[20];
	
int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> arr[i];
		for(int j=0;j<arr[i];j++){
			ll satu, dua;
			cin >> satu >> dua;
			satu--;
			b[i].pb(satu), c[i].pb(dua);
		}
	}
	for(int mask=0;mask<(1<<n);mask++){
		ll ans=0;
		bool cek=1;
		for(int i=0;i<n;i++){
			if((mask>>i)&1){
				ans++;
				for(int j=0;j<arr[i];j++){
					if((1&(mask>>b[i][j]) && c[i][j])){
						continue;
					}
					else if((!(1&(mask>>b[i][j])) && !c[i][j])){
						continue;
					}
					else{
						cek=0;
						break;
					}
				}
			}
		}
		if(cek){
			maks=max(maks, ans);
		}
	}
	cout << maks << '\n';
}


Measured memory_bytes: 3668
#include <stdio.h>
int main(){

  int hit[21][21]={0},end,x,y,x1,y1,n,m,amount,i,j;
  char hougaku[1];

  while(1){
    
    end=0;
    x1=y1=10;
    scanf("%d",&n);
    
    if(n != 0){
      
      for(i = 0; i < n; i++){
	
	scanf("%d %d",&x,&y);
	
	hit[x][y]=1;
	
      }
      
      scanf("%d",&m);
      
      for(i = 0; i < m; i++){
	
	scanf("%s %d",hougaku,&amount);
	
	if(hougaku[0] == 'N')
	  
	  for(j = 0; j < amount; j++) {
	    
	    y1++;
	    
	    hit[x1][y1]=0;
	    
	  }
	
	if(hougaku[0] == 'E')
	  
	  for(j = 0; j < amount; j++) {
	    
	    x1++;
	    
	    hit[x1][y1]=0;
	    
	  }
	
	if(hougaku[0] == 'S')
	  
	  for(j = 0; j < amount; j++) {
	    
	    y1--;
	    
	    hit[x1][y1]=0;
	    
	  }
	
	if(hougaku[0] == 'W')
	  
	  for(j = 0; j < amount; j++) {
	    
	    x1--;
	    
	    hit[x1][y1]=0;
	    
	  }
	
      }
      
      for(i = 0; i < 21; i++){
	
	for(j = 0; j < 21; j++){
	  
	  if(hit[i][j] == 1){
	    
	    end++;
	    hit[i][j]=0;
	    
	  }
	  
	}
	
      }
      
      if(end != 0) printf("No\n");
      else printf("Yes\n");
      
    } else {
      
      break;
      
    }

  }
  
  return 0;
    
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    double sum=0;
    for(int i=1;i<=n;++i){
        int x=i,count=0;
        while(x<k){
            x*=2;
            ++count;
        }
        sum += 1.0/(n*pow(2,count));
    }
    cout << fixed << setprecision(12) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int modPow(long long a, long long n, long long p) {
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

ll comb(ll n, ll p) {
	if (p * 2 > n) p = n - p;
	if (p > n - p) p = n - p;
	ll a = 1, b = 1;
	rrep(i, p + 1) {
		a = (a * (n - i + 1)) % mod;
		b = (b * i) % mod;
	}
	return a * (modPow(b, mod - 2, mod)) % mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;

	ll res1 = modPow(2, n, mod);
	ll res2 = comb(n, a);
	ll res3 = comb(n, b);

	ll ans = ((res1 - res2 - res3 - 1) % mod + mod) % mod;

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 174 A - Air Conditioner
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/02
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int x;

void solve() {

    if (x > 29)
        printf("Yes\n");
    else
        printf("No\n");

}

int main() {

    scanf("%d", &x);

    solve();

}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int h,w; cin>>h>>w;
    int hh,ww; cin>>hh>>ww;
    cout<<h*w-hh*w-ww*h+hh*ww<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,char> PIIC;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define DEBUG(X) { cout << #X << " = " << (X) << endl; }

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define FOREACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)

#define MOD 1000000007
#define INF 2000000000

int GI(LL& x) { return scanf("%lld", &x); }

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    char buf[w];
    FORN(i, h) {
	scanf("%s", &buf);
	printf(buf);
	printf("\n");
	printf(buf);
	printf("\n");
    }

    return 0;
}

Measured memory_bytes: 384
import kotlin.math.max

fun main() {
    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0
    var cnt = 0
    for (i in 0 until n - 1) {
        if (hs[i] >= hs[i + 1]) {
            cnt++
        } else {
            ans = max(cnt, ans)
            cnt = 0
        }
    }
    ans = max(cnt, ans)
    println(ans)
}


Measured memory_bytes: 51976
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#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 MOD 1000000007
#define INF 1000000000

using namespace std;


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

	cin >> a >> b >> c;

	if (a == b) {
		cout << c << endl;
	}
	if (b == c) {
		cout << a << endl;
	}
	if (c == a) {
		cout << b << endl;
	}

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int dp0, dp1, dp2;
  
  for(int i=0; i<n; i++){
    int a, b, c, s, t, u;
    cin >> a >> b >> c;
    if(i==0){
      dp0 = a;
      dp1 = b;
      dp2 = c;
      continue;
    }
    s = dp0;
    t = dp1;
    u = dp2;
    dp0 = max(t + a, u + a);
    dp1 = max(s + b, u + b);
    dp2 = max(s + c, t + c);
  }
  
  cout << max(max(dp0,dp1), dp2) << endl;
  return 0;
}

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

int main(){
  char c[2+1][3+1];
  for(int i=1; i<=2; i++){
    for(int j=1; j<=3; j++){
      cin >> c[i][j];
    }
  }

  bool flag=true;
  for(int i=1; i<=2; i++){
    for(int j=1; j<=3; j++){
      if(c[i][j]!=c[3-i][4-j]){
        flag=false;
        break;
      }
    }
  }
  string ans;
  if(flag) ans="YES";
  else ans="NO";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// 整数用
func lowerBound(a []int, x int) int {
	l := 0
	r := len(a) - 1
	for l <= r {
		m := (l + r) / 2
		if a[m] >= x {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func upperBound(a []int, x int) int {
	l := 0
	r := len(a)
	for l <= r {
		m := (l + r) / 2
		if len(a) == m {
			break
		}
		if a[m] <= x {
			l = m + 1
		} else {
			r = m - 1
		}
	}
	return l
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	t := getString()

	N := len(s)
	sm := make([][]int, 26)
	for i, v := range s {
		p := int(v - 'a')
		sm[p] = append(sm[p], i)
	}

	ans := 0
	prev := -1
	for _, v := range t {
		p := int(v - 'a')
		list := sm[p]
		if len(list) == 0 {
			out(-1)
			return
		}
		pos := upperBound(list, prev)
		// out(list, prev, pos)
		if prev == -1 {
			pos = list[0]
			ans++
		} else if pos == len(list) || prev == -1 {
			ans++
			pos = list[0]
		} else {
			pos = list[pos]
		}
		// out(pos, "ans", ans)
		prev = pos
	}

	prev++
	// out(ans, prev)
	out(ans*N - (N - prev))
}


Measured memory_bytes: 4992