akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  private[this] var cnt = 0
  private[this] val l = new Array[Int](260000)
  private[this] val r = new Array[Int](260000)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

 def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w = w/2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

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

int main() {
  int N;
  cin>>N;
    vector<int> vec(N) ;
  for (int i=0;i<N;i++) cin>>vec[i];
    sort(vec.begin(), vec.end()); 
	int x=0,k=0;
    for (int i = 0; i < N; i++) {
        if(vec[i]>k) {x++; k=vec[i];}
      else if(vec[i]==k) continue;
      else break;
    }
    cout<<x<<endl;
}

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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<int> vc;
   for(int i = 0;i < n;i++) {
      int x;
      cin >> x;
      vc.push_back(x);
   }
   sort(vc.begin(), vc.end());
   reverse(vc.begin(), vc.end());
   int alis = 0;
   int bob = 0;
   for(int i = 0;i < n;i++) {
      if(i%2==0) {
         alis += vc[i];
      } else {
         bob += vc[i];
      }
   }
   cout << alis - bob << endl;
}



Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = abs(b - a);
    int bc = abs(c - b);
    int ac = abs(c - a);

    if ((ab <= d && bc <= d) || ac <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int num_row,col_half,N;

int main(){

	scanf("%d %d %d",&num_row,&col_half,&N);

	int goal_row = num_row,goal_col = col_half+1;

	vector<int> V;

	int tmp_row,tmp_col;
	for(int i = 0; i < N; i++){

		scanf("%d %d",&tmp_row,&tmp_col);

		if(tmp_col > col_half){
			tmp_col += 1;
		}
		V.push_back(goal_row-tmp_row+abs(goal_col-tmp_col));
	}
	sort(V.begin(),V.end());

	int current = 0;

	for(int i = 0; i < V.size(); i++){

		current = max(V[i],current+1);
	}

	printf("%d\n",current+1);

	return 0;
}



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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray = br.readLine().split(" ");
		int[] a = new int[n];
		long allSum = 0;
		for(int i = 0; i < n ; i++){
			a[i] = Integer.parseInt(tmpArray[i]);
			allSum += a[i];
		}
		
		//探索開始
		long absMin = Long.MAX_VALUE;
		long sunukeSum = 0;
		for(int i = 0; i < n - 1; i++){
			sunukeSum += a[i];
			long araiSum = allSum - sunukeSum;
			long tmpAbs = Math.abs(araiSum - sunukeSum);
			
			if(tmpAbs < absMin){
				absMin = tmpAbs;
			}
		}
		
		System.out.println(absMin);
	}

}


Measured memory_bytes: 48224
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

const char OCC = '#';

const int INF = 1e9;

int n, m;
vector<string> a;

void Solve()
{
    vector<vector<int>> result(n, vector<int>(m, INF));
    auto calc = [] (auto previous, auto current) {
        return previous != current && current == OCC;
    };
    result[0][0] = (a[0][0] == OCC);
    for (int j = 1; j < m; ++j) {
        result[0][j] = result[0][j - 1] + calc(a[0][j - 1], a[0][j]);
    }
    for (int i = 1; i < n; ++i) {
        result[i][0] = result[i - 1][0] + calc(a[i - 1][0], a[i][0]);
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            result[i][j] = min(
                result[i - 1][j] + calc(a[i - 1][j], a[i][j]),
                result[i][j - 1] + calc(a[i][j - 1], a[i][j]));
        }
    }
    cout << result[n - 1][m - 1] << endl;
}

bool Read()
{
    if (!(cin >> n >> m)) {
        return false;
    }
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    return true;
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int main(){
  string s;
  cin >> s;
  int ans = 700;
  rep(i, 3){
    if (s[i] == 'o') ans += 100;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define p(p) cout<<(p)<<" ";
#define pb push_back
#define mp make_pair
#define INF 1<<25

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pi;
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
int n,m,l,r;
int H,W;
int d[10][10];
int A[201][201];
void input(){
	cin>>H>>W;
	rep(i,10)rep(j,10)cin>>d[i][j];
	rep(i,H){
		rep(j,W)cin>>A[i][j];
	}
}
const int MAX_V = 10;
#define V 10 
 
void warshall_floyd() {
	for (int k = 0; k<V; k++) {
		for (int i = 0; i<V; i++) {
			for (int j = 0; j<V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
void first() {
	for (int i = 0; i < MAX_V; i++) {
		for (int j = 0; j < MAX_V; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	first();
	input();
	warshall_floyd();
	ll ans=0;
	rep(i,H)rep(j,W){
		ans+=d[A[i][j]][1];
	}
	P(ans);
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, 0, n){
        cin >> lis[i];
        if(lis[i] % 2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
}

Measured memory_bytes: 4052
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;

	vector<int> sum(s.size() + 1);
	for (int i = 0; i < s.size(); i++)
	{
		if (i != s.size() - 1)
		{
			if (s[i] == 'A' && s[i + 1] == 'C')
			{
				sum[i + 1] = sum[i] + 1;
			}
			else
			{
				sum[i + 1] = sum[i];
			}
		}
		else
		{
			sum[i + 1] = sum[i];
		}
	}

	for (int i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		cout << sum[r] - sum[l] << endl;
	}
}

Measured memory_bytes: 1408
N,K=map(int,input().split())
A=list(map(int,input().split()))

for i in range(50):
    if K<(1<<i):
        break

keta=i

NOW=1
ANS=0

for i in range(keta-1,-1,-1):
    #print(i)
    if NOW==1 and K & (1<<i)!=0:
        #print("")
        A0=0
        A1=0
        for a in A:
            if a & (1<<i) ==0:
                A1+=(1<<i)
            else:
                A0+=(1<<i)

        if A1>A0:
            ANS+=(1<<i)
        else:
            ANS+=0
            NOW=0

    elif NOW==1 and K&(1<<i)==0:
        A0=0
        for a in A:
            if a & (1<<i) !=0:
                A0+=(1<<i)

        ANS+=0

    elif NOW==0:
        A0=0
        A1=0
        for a in A:
            if a & (1<<i) ==0:
                A1+=(1<<i)
            else:
                A0+=(1<<i)

        if A1>A0:
            ANS+=(1<<i)
        else:
            ANS+=0

#print(ANS)
SUM=0
for a in A:
    SUM+=ANS^a

print(SUM)
        


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

const int MAX = 1e5;
vector<int> mapp[MAX + 5], diss[MAX + 5];
int st, n;
long long dis[MAX + 5];
bool vis[MAX + 5];
queue<int> q;

int main()
{
    scanf("%d", &n);
    int a, b, c;
    for(int i = 0; i < n - 1; ++i)
    {
        scanf("%d%d%d", &a, &b, &c);
        mapp[a].push_back(b);
        diss[a].push_back(c);
        mapp[b].push_back(a);
        diss[b].push_back(c);
    }
    int qq;
    scanf("%d%d", &qq, &st);
    memset(dis, 0, sizeof(dis));
    memset(vis, 0, sizeof(vis));
    q.push(st);
    vis[st] = 1;
    int fr;
    while(!q.empty())
    {
        fr = q.front();
        q.pop();
        for(int i = 0; i < mapp[fr].size(); ++i)
        {
            if(!vis[mapp[fr][i]])
            {
                vis[mapp[fr][i]] = 1;
                dis[mapp[fr][i]] = dis[fr] + diss[fr][i];
                q.push(mapp[fr][i]);
            }
        }
    }
    for(int i = 0; i < qq; ++i)
    {
        scanf("%d%d", &a, &b);
        cout << dis[a] + dis[b] << endl;
    }
    return 0;
}


Measured memory_bytes: 14320
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    A = int(input()) # 500
    B = int(input()) # 100
    C = int(input()) # 50
    X = int(input())

    ans = 0
    for i_500 in range(A+1):
        sum500 = 500*i_500
        if sum500 > X: break
        for i_100 in range(B+1):
            sum500_100 = 500*i_500+100*i_100 
            if sum500_100 > X: break
            for i_50 in range(C+1):
                sum500_100_50 = 500*i_500 + 100*i_100 + 50*i_50
                if sum500_100_50 > X:
                    break
                if sum500_100_50 == X:
                    ans += 1
                    break
    print(ans)

                        


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int A[100009];

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

	int N, L; cin >> N >> L;
	for (int i = 1; i <= N; i++) cin >> A[i];

	int pos = 1; // pos,pos+1の結び目から始めればよい
	while (pos < N) {
		if (A[pos] + A[pos + 1] >= L) break;
		else pos++;
	}

	if (pos == N) cout << "Impossible" << endl;
	else {
		stack<int> S;
		S.push(pos);
		for (int i = pos + 1; i < N; i++) S.push(i);
		for (int i = pos - 1; i >= 1; i--) S.push(i);
		cout << "Possible" << endl;
		while (!S.empty()) {
			cout << S.top() << endl;
			S.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 1624
S = input()
ans = 0
for i in range(len(S)):
    for j in range(i,len(S)):
        flag = True
        for k in S[i:j+1]:
            if not (k=='A' or k=='C' or k=='G' or k=='T'):
                flag = False
                break
        if flag:
            ans = max(ans, len(S[i:j+1]))
print(ans)

Measured memory_bytes: 38384
package main

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

func main() {
	sc = initScanner(os.Stdin)
	n, m := scanInt(sc), scanInt(sc)

	solve(n, m)
}

func solve(n, m int) {
	ans := make([]int, n)

	for i := 0; i < m; i++ {
		ans[scanInt(sc)-1]++
		ans[scanInt(sc)-1]++
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define REPC(var, start, end) for(int var = start; var <= (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

const LL INF = (LL)1e18;
int n;
VL cards, psum;
LL mindiff()
{
	LL ans = INF; LL sum = 0;
	for(int i = 1; i <= n - 1; ++i)
	{
		sum += cards[i];
		ans = min(ans, abs(sum - (psum[n] - psum[i])));
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	cards.resize(n + 1); psum.resize(n + 1);
	REPC(i, 1, n) {
		 cin >> cards[i];
		psum[i] = cards[i] + psum[i - 1];
	}

	cout << mindiff() << endl;

	return 0;
}

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

const int N=105;

char str[N];

int main()
{
	scanf("%s",str+1);
	int n=strlen(str+1);
	if (n&1) {puts("No");return 0;}
	for (int i=1;i<n;i+=2)
		if (str[i]!='h'||str[i+1]!='i')
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  long n, a, b, divid, remain, ans;

  // 標準入力からの値取得
  scanf("%ld %ld %ld\n", &n, &a, &b);

  // 計算
  divid = n / (a + b);
  remain = n % (a + b);
  ans = a * divid + ((remain < a) ? remain : a);

  // 出力
  printf("%ld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){

    int card[52]={0};
    int i,n,a,m,s;
    char b;

    scanf("%d",&n);

    for (i=0; i<2*n; i++) {
        scanf("%c %d",&b,&a);
        if (b=='S'){
            m=4*(a-1);
            card[m]=1;
        }
        else if (b=='H'){
            m=4*(a-1)+1;
            card[m]=1;
        }
        else if (b=='C'){
            m=4*(a-1)+2;
            card[m]=1;
        }
        else if (b=='D'){
            m=4*(a-1)+3;
            card[m]=1;
        }
        m=0;
    }
    for (i=0; i<52; i++) {
        if(card[i]==0&&i%4==0){
             s=i/4;
            printf("S %d\n",s+1);
        }
    }
    for (i=0; i<52; i++) {
        if (card[i]==0&&i%4==1){
             s=i/4;
            printf("H %d\n",s+1);
        }
    }
        for (i=0; i<52; i++) {
        if (card[i]==0&&i%4==2){
            s=i/4;
            printf("C %d\n",s+1);
        }
    }
    for (i=0; i<52; i++) {
        if (card[i]==0&&i%4==3){
             s=i/4;
            printf("D %d\n",s+1);
        }
    }
    return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,m,ans;
int h[MAXN];
vector<int> v[MAXN];

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> h[i];

	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}

	for (int i = 1; i <= n; ++i)
	{
		bool f = true;
		for (int j = 0; j < v[i].size(); ++j)
			if(h[v[i][j]] >= h[i])
			{
				f = false;
				break;
			}
		ans += f;
	}

	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 11504
def divisors(n):
    i = 1
    table = set()
    while i * i <= n:
        if not n % i:
            table.add(i)
            table.add(n//i)
        i += 1
    table = list(table)
    return table


N = int(input())
A = list(map(int, input().split()))
temp = [0] * N
for n in reversed(range(1,N+1)):
    if (A[n-1] + temp[n - 1])%2 == 0:
        temp[n - 1] = 0
        continue
    for a in divisors(n):
        temp[a-1] += 1


res = list(i+1 for i, _ in enumerate(temp) if temp[i])
print(len(res))
print(*res)

"""
4
1 1 1 1
"""

Measured memory_bytes: 98468
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}


Measured memory_bytes: 2768
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int N,D,X,A,ans=0,tmp;

	cin >> N >> D >> X;
	ans += X;
	for(int i=0;i<N;i++){
		cin >> A;
		ans += (D-1)/A + 1;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main (){
    int N, D;
    cin>>N>>D;
    vector <vector<double>> Vec(N, vector<double>(D));
    for (int i=0; i <N; i ++){
        for (int j =0; j <D; j ++){
            cin>>Vec.at(i).at(j);
        }
    }
    int count = 0;
    for(int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            double DisDbl=0;
            for (int k=0; k<D; k++){
                DisDbl+=pow(Vec.at(i).at(k)-Vec.at(j).at(k), 2.0);
            }
            int DisDblDwn= pow(DisDbl, 0.5);
            if(DisDbl==DisDblDwn*DisDblDwn){
                count ++;
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int num[100001], n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> num[i];
    int light = 1;
    for (int i = 1; i < n; i++) {
        light = num[light];
        if (light == 2) {
            cout << i << endl;
            break;
        }
    }
    if (light != 2) cout << -1 << endl;
}


Measured memory_bytes: 640
input()
a=[int(i) for i in input().split()]
cnt=0
flg=True
while flg:
  b=[]
  for i in a:
    if bin(i)[-1]=="1":
      flg=False
      break
    else:
      b.append(i>>1)
  if flg:
    cnt+=1
    a=b
print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int dp[N], vis[N];
vector<int> gr[N];

void dfs(int v) {
	vis[v] = 1;
	for(auto to: gr[v]) {
		if(!vis[to]) {
			dfs(to);
		}
		if(dp[v] < dp[to] + 1) {
			dp[v] = dp[to] + 1;
		}
	}
}

void solve() {
	//soln
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;
		gr[l].pb(r);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			dfs(i);
		}
		ans = max({ans, dp[i]});		
	}
	cout << ans << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


Measured memory_bytes: 22740
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String[] strings = new String[N];
		for (int i = 0; i < N; i++) {
			strings[i] = scanner.next();
		}
		Arrays.parallelSort(strings);

		ArrayList<String> resultStrings = new ArrayList<String>();

		String tempString = "";
		int max = 0;
		int count = 0;

		for (int i = 0; i < N; i++) {
			if (strings[i].equals(tempString)) {
				count++;
			} else {
				count = 0;
				tempString = strings[i];
			}
			if (count == max) {
				resultStrings.add(tempString);
			} else if (count > max) {
				max = count;
				resultStrings.clear();
				resultStrings.add(tempString);
			}
		}
		resultStrings.forEach(s -> System.out.println(s));

	}

}


Measured memory_bytes: 79716
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

LL extgcd(LL a,LL b,LL&x,LL&y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    LL q=a/b;
    LL g=extgcd(b,a-q*b,x,y);
    LL z=x-q*y;
    x=y;
    y=z;
    return g;
}

vector<pair<int,P>> G[1<<17];
struct F{
LL memo[1<<17];
LL mod;
F(LL m){
    mod = m;
    for(int i=0;i<1<<17;i++) memo[i] = 0;
}


bool dfs(int v,int u, LL x){
    if(memo[v]){
        if(memo[v] == x) return true;
        else return false;
    }
    memo[v] = x;
    bool f = true;
    for(int i=0;i<G[v].size();i++){
        LL s,t;
        extgcd(G[v][i].second.second,mod,s,t);
        s%=mod;
        if(s<0) s+=mod;
        f = f && dfs(G[v][i].first,v,x * G[v][i].second.first % mod * s %mod);
    }
    return f;
}
};
        

int main(){
    int n,m;cin >> n >> m;
    for(int i=0;i<m;i++){
        LL a,b,x;cin >> a >> b >> x;
        a--,b--;
        G[a].push_back({b,{1LL,x}});
        G[b].push_back({a,{x,1LL}});

    }
    F a(1000000009);
    F c(1000000021);
    F d(1000000097);
    F e(1000000087);
    F f(1000000093);
    F h(1000500013);
    F l(1000500077);
    for(int i=0;i<n;i++){
        if(a.memo[i]) continue;
        if(!a.dfs(i,-1,1LL)
            ||!c.dfs(i,-1,1LL)
            ||!d.dfs(i,-1,1LL)
            ||!e.dfs(i,-1,1LL)
            ||!f.dfs(i,-1,1LL)
            ||!h.dfs(i,-1,1LL)
            ||!l.dfs(i,-1,1LL)
            ){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}



Measured memory_bytes: 25184
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )
#define ullrep(i, a, b) for(ull i = (a); i < (b); ++i )
#define ullrrep(i, a, b) for(ull i = (a); i > (b); --i )
#define ullREP(i, a, b) for(ull i = (a); i <= (b); ++i )
#define ullRREP(i, a, b) for(ull i = (a); i >= (b); --i )
int H, W;
int S[50][50];

int check(int i, int j) {
    if ((i >= 0) && (i < H) && (j >= 0) && (j < W)) {
        if (S[i][j] == 1) {
            return 1;
        }
    }
    return 0;
}

int main() {
    cin >> H >> W;
    rep(i, 0, H){
        rep(j, 0, W) {
            char c;
            cin >> c;
            if (c == '.') {
                S[i][j] = 0;
            }else{
                S[i][j] = 1;
            }
        }
    }
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (S[i][j] == 1) {
                int sum = check(i-1, j) + check(i+1, j) + check(i, j-1) + check(i, j+1);
                if (sum == 0) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    string s=stin(),t=stin();
    ll ans=1,mod=1000000007;
    int id=0;
    bool bl;
    if(s[0]==t[0]){
        ans=3;
        id=1;
        bl=true;
    }else{
        ans=6;
        id=2;
        bl=false;
    }
    while(id<n){
        if(bl){
            if(s[id]==t[id]){
                id++;
            }else{
                bl=false;
                id+=2;
            }
            ans=ans*2%mod;
        }else{
            if(s[id]==t[id]){
                bl=true;
                id++;
            }else{
                ans=ans*3%mod;
                id+=2;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble();
        double b = scan.nextDouble();
        double angle = scan.nextDouble();

        double S = 0.5 * a * b * Math.sin(Math.PI * angle / 180.0);
        double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.PI * angle / 180.0));
        double h = (2 * S) / a;

        System.out.println(S);
        System.out.println(L);
        System.out.println(h);
    }

}


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

#define NCOIN 6
const int coins[NCOIN] = {1,5,10,50,100,500};
const int infty = 1<<28;

int PaymentAndChange(int N, int v[], bool &possible){
  int ret = 0;
  for(int i = NCOIN-1; i >= 0; --i){
    int t = N/coins[i];
    if( t > v[i] ){
      N -= coins[i] * v[i];
      ret += v[i];
    }else{
      N -= coins[i] * t;
      ret += t;
    }
  }
  if( N == 0 ) possible = true;
  else possible=false;
  return ret;
}

int main()
{
  while(true){
    int ans = infty;
    int P,maxP=0;
    int vc[NCOIN]={0,};
    scanf("%d",&P);
    if(P==0)break;
    for(int i = 0; i < NCOIN; ++i){
      scanf("%d",&vc[i]);
      maxP+=vc[i]*coins[i];
    }
    for(int iP = P; iP <= maxP; ++iP){
      bool pos;
      int t = PaymentAndChange(iP,vc,pos);
      if( !pos ) continue;
      if( t >= ans ) continue;
      t += PaymentAndChange(iP-P,vc,pos);
      if( !pos ) continue;
      ans = min( ans, t );
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 880
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    string s;
    cin>>s;
    if(s[0]=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(s[1]=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(s[2]=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
n,d,a = gets.split.map(&:to_i)
monsters = n.times.map{ gets.split.map(&:to_i) } 

monsters.map!{ |xh| xh[1] = (xh[1]+a-1)/a; xh }.sort_by!{ |x,h| x }

deq = []
acc_damage = 0
ans = 0
monsters.each do |x,h|
  
  while deq.size > 0 && deq[0][0] < x do
    acc_damage -= deq.shift[1]
  end
  
  need = h - acc_damage
  # need = 0 if need < 0
  
  if need > 0
    acc_damage += need
    ans += need
    deq.push( [x + d*2, need] )
  end
end

puts ans

Measured memory_bytes: 22520
// https://atcoder.jp/contests/abc144/tasks/abc144_d

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  double a, b, x, V, arg;
  cin >> a >> b >> x;
  V = a * a * b;
  if(V < 2 * x){
    arg = 90 - atan2(a, 2 * (V - x) / (a * a)) * 180 / M_PI;
  }else{
    arg = atan2(b, 2 * x / (a * b)) * 180 / M_PI;
  }

  cout << fixed << setprecision(10) << arg << '\n';

  return 0;
}


Measured memory_bytes: 384
use std::cmp::*;
use std::io::Read;
use std::iter::Scan;

trait Ext {
    fn try_fold_<B, F>(&mut self, init: B, mut f: F) -> Option<B>
    where
        Self: Sized + Iterator,
        F: FnMut(B, Self::Item) -> Option<B>,
    {
        let mut accum = init;
        while let Some(x) = self.next() {
            if let Some(new_accum) = f(accum, x) {
                accum = new_accum;
            } else {
                return None;
            }
        }
        Some(accum)
    }
}
impl<I, St, F> Ext for Scan<I, St, F> {}

fn cost(a: &[i64], bits: u32) -> Option<i64> {
    a.iter()
        .enumerate()
        .scan(0, |cur_height, (i, &height)| {
            let (next_height, expected_height) = if (bits >> i) & 1 != 0 {
                (max(*cur_height + 1, height), max(*cur_height + 1, height))
            } else {
                (*cur_height, min(*cur_height, height))
            };
            *cur_height = next_height;
            Some((height, expected_height))
        })
        .try_fold_(0, |cost, (height, expected_height)| {
            if height > expected_height {
                None
            } else {
                Some(cost + expected_height - height)
            }
        })
}

fn solve(n: usize, k: usize, a: Vec<i64>) -> i64 {
    (0u32..(1 << n))
        .filter(|&bits| bits.count_ones() >= (k as u32))
        .filter_map(|bits| cost(&a, bits))
        .min()
        .unwrap()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let a = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    let r = solve(n, k, a);
    println!("{}", r);
}


Measured memory_bytes: 4352
#include <cstdio>

int N, M;
int c[100005];

int main() {
    scanf("%d %d", &N, &M);
    for (int i = 0, a, b; i < M; i++) scanf("%d %d", &a, &b), c[a]++, c[b]++;
    for (int i = 1; i <= N; i++) if (c[i]&1) {
        printf("NO\n");
        return 0;
    }
    printf("YES\n");
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;

long dict[1048576] = {};

void makeDict(long A[], long n){
	for (long i = 0; i < pow(2, n); i++){
		dict[i] += (i % 2) * A[0];
		for (long j = 1; j < n; j++){
			dict[i] += (fmod(i, pow(2, j + 1)) - fmod(i, pow(2, j))) / pow(2, j) * A[j];
		}
	}
}

int main(){
	long n, q, A[20], m[200];
	cin >> n;
	for (long i = 0; i < n; i++) cin >> A[i];
	makeDict(A, n);
	int p = pow(2, n);
	sort(dict, dict + p);
	cin >> q;
	for (long i = 0; i < q; i++){
		cin >> m[i];
		if (binary_search(dict, dict + p, m[i])) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>
#include<cmath>
#include<queue>

typedef long long ll;
using namespace std;
#define mod 10007

int main(void){
  int N;cin >> N;
  vector<int>d(N);
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans+=d[i]*d[j];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int r, d, x;
  scanf("%d%d%d", &r, &d, &x);
  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    printf("%d\n", x);
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 2147483647;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

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

int H,W;
char field[410][410];
bool table[410][410];

pair<ll,ll> cnt(int y,int x){
  ll brack = 1,white = 0;
  memset(table,sizeof(table),true);
  queue<tuple<int,int,bool>> Q;
  Q.emplace(y,x,true);
  table[y][x] = false;
  while(Q.size()){
    int y,x;bool frag;
    tie(y,x,frag) = Q.front();
    Q.pop();
    rep(i,4){
      int ny = y + dy[i],nx = x + dx[i];
      if(0 <= ny && ny < H && 0 <= nx && nx < W){
        if(frag && field[ny][nx] == '.' && table[ny][nx]){
          white++;
          table[ny][nx] = false;
          Q.emplace(ny,nx,false);
        }
        if(! frag && field[ny][nx] == '#' && table[ny][nx]){
          brack++;
          table[ny][nx] = false;
          Q.emplace(ny,nx,true);
        }
      }
    }
  }
  return make_pair(white,brack);
}

int main(){
  cin >> H >> W;
  rep(i,H) rep(j,W) cin >> field[i][j];
  rep(i,H) rep(j,W) table[i][j] = true;
  ll ans = 0;
  rep(i,H) rep(j,W){
    if(table[i][j] && field[i][j] == '#'){
      ll a,b;
      tie(a,b) = cnt(i,j);
      ans += a * b;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int A,B,C; cin >> A >> B >> C;
  if(A==B && A!=C) cout << "Yes" << endl;
  else if(A==C && A!=B) cout << "Yes" << endl;
  else if(B==C && A!=B) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
c500=int(input())
c100=int(input())
c50=int(input())
Total_fee=int(input())
count=0
for ac in range(c500+1):
    for bc in range(c100+1):
        for cc in range(c50+1):
            temp_total=ac*500+bc*100+cc*50
            if temp_total==Total_fee:
                count+=1
print(count)

Measured memory_bytes: 3060
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    INF = 10**18
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    A = [0]
    for i in range(n):
        A.append(a[i] + A[i])
    B = [0]
    for i in range(m):
        B.append(b[i] + B[i])

    ans = 0
    j = m
    for i in range(n + 1):
        if A[i] > k:
            break
        while k < A[i] + B[j]:
            j -= 1
        ans = max(ans, i + j)
    print(ans)

main()

Measured memory_bytes: 47784
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
//#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}

signed main() {
	
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i+=2) {
		cout << s[i];

	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  if((N/10)%111 == 0)
  {
    cout<<"Yes"<<endl;
  }else if((N%1000)%111 == 0)
  {
    cout<<"Yes"<<endl;
  }else
  {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct BIT{
	int bit[SIZE];
	int n;
	
	void add(int k,int x){
		while(k<=n){
			bit[k]+=x;
			k=k+(k&-k);//一番右端
		}
	}
	
	int sum(int k){
		int ret=0;
		while(k>0){
			ret+=bit[k];
			k=k-(k&-k);
		}
		return ret;
	}
	
	int sum(int a,int b){
		return sum(b)-sum(a-1);
	}
	
	
};
BIT bit;
	
int main(){
	int N;
	cin>>N;
	ll K;
	cin>>K;
	vector<ll>data,data2,data3;
	rep(i,N){
		ll a;
		cin>>a;
		a-=K;
		data.pb(a);
	}
	
	bit.n = N+3;
	ll sum=0;
	data2.pb(sum);
	data3.pb(sum);
	rep(i,N){
		sum+=data[i];
		data2.pb(sum);
		data3.pb(sum);
	}
	sort(all(data2));
	map<ll,int> indexed;
	for(int i=0;i<data2.size();i++){
		indexed[data2[i]]=i;
	}
	/*rep(i,data2.size())cout<<data3[i]<<" ";
	cout<<endl;
	rep(i,data2.size())cout<<indexed[data3[i]]<<" ";
	cout<<endl;*/
	ll ans=0;
	for(int i=0;i<data3.size();i++){
		int now = indexed[data3[i]]+1;
		ans += (ll)bit.sum(now);
		bit.add(now,1);
		
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 18672
import sys
n = input()
list_num =list(map(int,input().split()))
output = 1
if 0 in list_num:
    print(0)
    sys.exit()
for i in list_num:
    output = output * i
    if output > 10 ** 18:
        print(-1)
        sys.exit()
print(output)


Measured memory_bytes: 21620
#include <iostream>
using namespace std;
int main()
{
	char c, m;
	cin >> c;
	while (c == 'z' || isupper(c))
	{
		cout << "Please enter a letter before z and small\n";
		cin >> c;
	}
	m = c + 1;
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	string s;
	int k[4] = {}, i;

	cin >> s;

	for(i = 0; i < s.size(); i++){
		if(s[i] == 'N')k[0] = 1;
		if(s[i] == 'W')k[1] = 1;
		if(s[i] == 'S')k[2] = 1;
		if(s[i] == 'E')k[3] = 1;
	}

	if((k[0] && k[2] || !(k[0] || k[2])) && (k[1] && k[3] || !(k[1] || k[3]))){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a=0;
		for(int i=0;i<n;i++) {
			a+=sc.nextInt()-1;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 26096