akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char[][] grid = new char[h][w];
      for(int i = 0; i < h; i++)
        grid[i] = sc.next().toCharArray();

      int[][][] count = new int[h][w][4];// 0:up 1:right 2:down 3:left
      // 3: left
      for(int i = 0; i < h; i++) {
        for(int j = 1; j < w; j++) {
          if(grid[i][j] == '#') continue;
          count[i][j][3] = count[i][j-1][3] + (grid[i][j-1] == '#' ? 0 : 1);
        }
      }
      // 1: right
      for(int i = 0; i < h; i++) {
        for(int j = w-2; j >= 0; j--) {
          if(grid[i][j] == '#') continue;
          count[i][j][1] = count[i][j+1][1] + (grid[i][j+1] == '#' ? 0 : 1);
        }
      }
      // 0: up
      for(int col = 0; col < w; col++) {
        for(int row = 1; row < h; row++) {
          if(grid[row][col] == '#') continue;
          count[row][col][0] = count[row-1][col][0] + (grid[row-1][col] == '#' ? 0 : 1);
        }
      }
      // 2: down
      for(int col = 0; col < w; col++) {
        for(int row = h-2; row >= 0; row--) {
          if(grid[row][col] == '#') continue;
          count[row][col][2] = count[row+1][col][2] + (grid[row+1][col] == '#' ? 0 : 1);
        }
      }
      int max = 0;
      for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
          if(grid[i][j] == '#') continue;
          max = Math.max(max, 1 + count[i][j][0] + count[i][j][1] + count[i][j][2] + count[i][j][3]);
        }
      }
      System.out.println(max);
  }
}

Measured memory_bytes: 203420
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


vector<pair<ll, ll> > prime_factorize(ll N) {
	vector<pair<ll, ll> > res;
	for (ll a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		ll ex = 0; // 指数

		// 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back(make_pair(a, ex));
	}
	// 最後に残った数について
	if (N != 1) res.push_back(make_pair(N, 1));
	return res;
}


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

	const auto& res = prime_factorize(n);

	if (res.size() == 0) {
		cout << 0;
		return 0;
	}

	ll ans = 0;
	for (auto p : res) {
		ll num = p.second;
		ll t = 0;
		while (num >= 0) {
			t++;
			num -= t;
		}
		ans += (t - 1);
		
	}

	cout << ans;

	

	/*vector<ll> data(m + 1, 0);
	for (ll i = 0; i < m + 1; i++) {
		data[i] = (i * (i + 1)) / 2;
		//if(i < 100)
		//cout << data[i] << " ";
	}

	ll ans = 0;

	vector<ll>::iterator position;  // auto position; で良い．
	ll idx_lower;
	for (ll i = 2; i <= m; i++) {
		if (x[i] == 0) {
			continue;
		}
		position = upper_bound(data.begin(), data.end(), x[i]);  // a[i] を二分探索
		idx_lower = distance(data.begin(), position);
		//cout << i << ":" << idx_lower << endl;
		ans += (idx_lower-1);
	}*/



}




Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
import collections
import bisect

def main():
	#A, B, Q = map(int, input().split(" "))
	N = int(input())
	d = list(input().split(" "))
	d = [int(s) for s in d]
	d.sort()
	base = (len(d))//2
	
	ans = 0
	for k in range(d[0]-1, d[-1]+2):
		tmp = bisect.bisect_left(d,k)
		if tmp == base:
			ans+=1
	
	print(ans)	
	
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    cout<<(A*B>C*D?A*B:C*D)<<endl;
}

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

int main() {

    int n, m;

    cin >> n >> m;

    vector<vector<int>> v(n);

    for(int i = 0; i < m; ++i) {
        int a, b;

        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);

    }

    vector<int> done(n, -1);

    queue<int> q;

    q.push(0);

    done[0] = 1;

    while(!q.empty()) {

        int index = q.front(); q.pop();
        

        for(int i = 0; i < v[index].size(); ++i) {

            if(done[v[index][i]] == -1) {
                done[v[index][i]] = index + 1;
                q.push(v[index][i]);
            }

        }

    }


    bool isTrue = true;

    for(int i = 0; i < n; ++i) {
        if(done[i] == -1) {
            isTrue = false;
            break;
        }
    }

    if(isTrue) {
        cout << "Yes" << endl;
        for(int i = 1; i < n; ++i)
            cout << done[i] << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;

}

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

int checking(int x)
{
    for(int i=2; i*i<=x; i++)
    {
        if(x%i == 0)
            return false;
    }
    return true;
}

int main()
{
    int tmp,N;

    cin >> N;
    cout << N << ":";

    if(checking(N))
    {
        cout <<' '<< N << endl;
        return 0;
    }
    tmp = N;
    int c = 2;
    while(1)
    {
        if(tmp <= 1)
            break;
        for(int i = c; i<=N; i++)
        {
            if(tmp%i == 0)
            {
                cout <<" "<< i;
                tmp=tmp/i;
                c = i;
                break;
            }
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< long long > vll;
typedef pair< int,int > ii;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define nl "\n"
ll gcd (ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd (b, a % b);
}

unsigned long long factorial[1000004]; 
    /*factorial[0] = 1; 
    for (int i = 1; i <= n; i++) {
        factorial[i] = (factorial[i - 1] * i) % mod3; 
    }*/




unsigned long long power(unsigned long long x, 
                         int y, int p) 
{ 
    unsigned long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 



  
// Returns n^(-1) mod p 
unsigned long long modInverse(unsigned long long n, int p) 
{ 
    return power(n, p - 2, p); 
} 
unsigned long long nc(unsigned long long n, 
                                 int r, int p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
 
  
    return (factorial[n]* modInverse(factorial[r], p) % p * modInverse(factorial[n - r], p) % p) % p; 
} 



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vi h(n+1);
    fo(i,n){
        cin>>h[i+1];
    }
    vi c(n+1);
    c[2]= abs(h[1]-h[2]);
    for(int i=3;i<=n;i++){
        c[i]= min(c[i-1]+ abs(h[i]-h[i-1]) , c[i-2]+abs(h[i-2]-h[i]));
    }
        
    cout<<c[n]<<nl;
    

    


	return 0;
}


Measured memory_bytes: 3924
using System;
using System.Diagnostics;
using System.Numerics;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        Console.WriteLine(Parse(sc.Next()) + Parse(sc.Next()));
    }

    public BigInteger Parse(string s)
    {
        BigInteger result = 0;
        StringBuilder sb = new StringBuilder();
        int minus = s[0] == '-' ? 1 : 0;

        for (int i = minus; i < s.Length; i++)
        {
            sb.Append(s[i]);
            if ((i + 1) % 18 == minus)
            {
                result *= (long) 1e18;
                result += long.Parse(sb.ToString());
                sb = new StringBuilder();
            }
        }

        result *= (long) Math.Pow(10, sb.Length);
        result += long.Parse(sb.ToString());
        return minus == 1 ? -result : result;
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 42884
# 初期入力
from copy import copy
K = int(input())

#
lunlun_start =["1","2","3","4","5","6","7","8","9"]
lunlun_roop =copy(lunlun_start)
lunlun =[]
ans =copy(lunlun_start)
x=""
while len(ans) <K:
#for i in range(1,10):
    lunlun =[]
    for i in lunlun_roop:
        if i[-1] =="0":
            lunlun.append(i+"0")
            lunlun.append(i+"1")
        elif i[-1] =="9":
            lunlun.append(i+"8")
            lunlun.append(i+"9")
        else:
            x =int(i+i[-1])-1
            lunlun.append((str(x) ))
            x +=1
            lunlun.append((str(x) ))
            x +=1
            lunlun.append((str(x) ))
        if len(lunlun) >K:
            break
    lunlun_roop =copy(lunlun)
    ans.extend(lunlun)
print(ans[K-1])

Measured memory_bytes: 22688
#include <iostream>
#include <string>
#include <stdlib.h>
#define INF 0x7fffffff
#define MAX_V 100
using namespace std;

int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];
int V; // V<=100

int prim(){
  for( int i=0;i<V;++i ){
    mincost[i]=INF;
    used[i] = false;
  }
  mincost[0] = 0;
  int res = 0;
  while( true ){
    int v=-1;
    for( int u=0;u<V;u++ ){
      if( !used[u] && (v==-1 || mincost[u] < mincost[v])) v=u;
    }
    if( v==-1 ) break;
    used[v] = true;
    res += mincost[v];

    for( int u=0;u<V;u++ )
      mincost[u] = min( mincost[u], cost[v][u] );
  }
  return res;
}

int main(){
  int m;
  string line;
  char buf[256];

  while(  cin >> V,V ){
    cin >> m;
    //    cout << "V="<<V <<" m="<<m<<endl;

    int x,y;
    int k;
    for( int i=0;i<V;i++ )
      for( int j=0;j<V;j++ )
	cost[i][j] = INF;
    for( int i=0,j;i<m;i++ ){
      cin >> line;
      for( j=0;j<line.size();j++ ) buf[j] = line.at(j);
      buf[j] = '\0';
      x = atoi( buf );
      for( j=0; buf[j]!=',';j++ );
      y = atoi( ++j+buf );
      for( ; buf[j]!=',';j++ );
      k = atoi( ++j+buf );
      //       cout << x <<"_"<<y<<"_"<<k<< endl;
      k = k/100 -1; // ÂÂÂUÂÃÂÂ
      cost[x][y] = k;
      cost[y][x] = k;
    }
    cout << prim() << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a[5];
    int ans = 1e9;
    rep(i,5){
        cin>>a[i];
    }
    vector<int>v={0,1,2,3,4};
    do{
        int sum =0;
        rep(i,4){
            sum+=(a[v[i]]%10!=0)?(a[v[i]]+(10-a[v[i]]%10)):a[v[i]];
        }
        sum+=a[v[4]];
        ans = min(ans,sum);
    }while(next_permutation(v.begin(),v.end()));
    co(ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	k := 0
	X := make([]int, 5)
	fmt.Scan(&X[0], &X[1], &X[2], &X[3], &X[4], &k)
	f1 := true
	for i := 1; i < 5; i++ {
		if X[i]-X[0] > k {
			f1 = false
			break
		}
	}

	if f1 {
		fmt.Println("Yay!")
	} else {
		fmt.Println(":(")
	}

}


Measured memory_bytes: 512
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    ll a = (x / 500) * 1000;
    ll b = ((x - (x / 500) * 500) / 5) * 5;
    cout << a + b << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[](n);
  foreach(i; 0..n) rd(a[i]);

  sort(a);
  auto rec=new int[](n);
  foreach(i; 0..n){
    int mx=0;
    foreach(j; 0..i)if(a[j]<a[i]){
      mx=max(mx, rec[j]);
    }
    rec[i]=mx+1;
  }

  writeln(reduce!(max)(rec));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int mod=1000000007;

signed main(){
	int n=read(),m=read();
	int p=0,q=0;
	REP(i,n){
		int x=read()+mod;
		p=(p-x*(n-1-i)%mod+x*i+mod)%mod;
	}
	REP(i,m){
		int y=read()+mod;
		q=(q-y*(m-1-i)%mod+y*i+mod)%mod;
	}
	cout<<p*q%mod<<endl;
}


Measured memory_bytes: 256
s = input()
t = input()
n = 0
c = 0
for e in t:
    try:
        i = s[c:].index(e)
        n += i + 1
        c = (c + i + 1) % len(s)
    except ValueError:
        try:
            i = s.index(e)
            n += len(s) - c + i + 1
            c = i + 1
        except ValueError:
            n = -1
            break
print(n)

Measured memory_bytes: 3316
def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import deque
    N, Q = (int(i) for i in input().split())
    G = [[] for _ in range(N)]
    cost = [0]*N
    for _ in range(N-1):
        a, b = (int(i) for i in input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    for _ in range(Q):
        p, x = (int(i) for i in input().split())
        cost[p-1] += x

    def bfs(s):
        G_color = ['WHITE' for _ in range(len(G))]
        G_color[s] = 'GRAY'
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    cost[v] += cost[u]
                    Q.append(v)
            G_color[u] = 'BLACK'

    bfs(0)
    print(*cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 90960
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vi A(N);
  cin >> A;
  unordered_map<int, int> cnt;
  rep(i, 0, N) cnt[A[i]]++;
  int ans = 0;
  rep(i, 0, N) {
    cnt[A[i]]--;
    int tmp = 0;
    rep(x, 1, A[i] + 1) {
      if (x * x > A[i]) break;
      if (A[i] % x == 0) {
        int d1 = x;
        int d2 = A[i] / x;
        tmp += cnt[d1];
        if (d1 != d2) {
          tmp += cnt[d2];
        }
      }
    }
    if (!tmp) {
      ans++;
    }
    cnt[A[i]]++;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 33240
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    yn(a * b % 2 != 0);
}


Measured memory_bytes: 4352
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

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

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  char c;
  cin >> c;
  if (c >= 'A' && c <= 'Z') {
    cout << 'A' << endl;
    return 0;
  }
  cout << 'a' << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>

// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, b;
    std::cin >> a >> b;
    if (b%a==0) std::cout << a + b << std::endl;
    else std::cout << b - a << std::endl;
    return 0;
}

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

int main(){

    int n;
    cin >> n;

    vector<int> v;

    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        if(a==0){
            int b; cin >> b;
            v.push_back(b);
        }
        else if(a==1){
            int b; cin >> b;
            cout << v[b] << endl;
        }
        else{
            v.pop_back();
        }

    }


}


Measured memory_bytes: 3844
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    vector<int> C(N - 1);
    rep(i, N) cin >> A.at(i);
    rep(i, N) cin >> B.at(i);
    rep(i, N - 1) cin >> C.at(i);

    int ans = 0;
    rep(i, N) {
        ans += B.at(A.at(i) - 1);
        if (i > 0 && A.at(i) == A.at(i - 1) + 1) ans += C.at(A.at(i - 1) - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	rep(i, n){
		if((i + 1) == k) s[i] = (char)s[i] + 32;
	}
	cout << s << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
signed main() {
    int N;cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        int m=N/i;
        ans+=i*m*(m+1)/2;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,m,c,ans=0;
    cin>>n>>m>>c;
    vi b(m);
    rep(i,m) cin>>b[i];
    rep(i,n){
        lli now=0;
        rep(j,m){
            lli a;
            cin>>a;
            now+=a*b[j];
        }
        if(now+c>0) ans++;
    }
    out(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;	
	cout<<(1000-(n%1000))%1000<<endl;
	return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  long long int ans=0;
  for(long long int i=1; i<=n; i++){
    long long int y=n/i;
    ans+=i*(y*(y+1))/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  string s1 = "maerd";
  string s2 = "remaerd";
  string s3 = "esare";
  string s4 = "resare";
  bool fail_flag = false;
  for (int i = 0; i < S.length(); i++) {
    if (S.substr(i, s1.length()) == s1) {
      i += s1.length() - 1;
    } else if (S.substr(i, s2.length()) == s2) {
      i += s2.length() - 1;
    } else if (S.substr(i, s3.length()) == s3) {
      i += s3.length() - 1;
    } else if (S.substr(i, s4.length()) == s4) {
      i += s4.length() - 1;
    } else {
      fail_flag = true;
      break;
    }
  }

  string ans = (fail_flag) ? "NO" : "YES";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
//#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;


const ll mod = 1e9;

vector<ll> q,p;

bool ok(ll x,ll n,ll k)
{
    ll ans = 0;
    sort(q.begin(),q.end(),greater<ll>());
    sort(p.begin(),p.end());
    int s1 = q.size(),s2 = p.size();
    for(int i = 0; i < s1; ++i)
    {
        int l = i,r = s1-1;
        while(l < r)
        {
            int mid = l + r +1 >>1;
            if(q[i]*q[mid] <= x) l = mid;
            else r = mid - 1;
        }
        if(l > i) ans += l -i ;
    }
    for(int i = 0; i < s2; ++i)
    {
        int l = i,r = s2 - 1;
        while(l < r)
        {
            int mid = l + r + 1 >> 1;
            if(p[i]*p[mid] <= x) l = mid;
            else r = mid - 1;
        }
        if(l > i) ans += l - i ;
    }
    if(ans >= k) return 1;
    reverse(q.begin(),q.end());
    reverse(p.begin(),p.end());
    for(int i = 0; i < s1; ++i)
    {
        int l = -1,r = s2-1;
        while(l < r)
        {
            int mid = l + r + 1>>1;
            if(q[i] * p[mid] <=  x) l = mid;
            else r = mid - 1;
        }
        if(l != -1) ans += l + 1;
    }
    return ans >= k;


}
int main()
{
    ll n,k,a;
    scanf("%lld%lld",&n,&k);

    for(int i = 1; i <= n; ++i)
    {
        scanf("%lld",&a);
        if(a<0) q.push_back(a);
        else  p.push_back(a);
    }
    ll l = - mod * mod ,r = mod *mod;
    while(l < r)
    {
        ll mid = l + r >>1;
        if(ok(mid,n,k)) r = mid;
        else l = mid + 1;
    }
    cout << r;
}





Measured memory_bytes: 2548
#include <iostream>
#include <stdio.h>
#include <string>
#include <fstream>
#include <string.h>

#define MOD 1000000007
using namespace std;

int main(){
  long long x ,y;
  long long a, b;
  int n,m;
  cin >> n >> m;
  a = b = 0;
  for(int i = 0; i < n; i++){
    cin >> x;
    //cout << x  << endl;
    a += (x*(i-(n-i-1)));
    a %= MOD;
  }
  for(int i = 0; i < m; i++){
    cin >> y;
    // cout << y << endl;
    b += (y*(i-(m-i-1)));
    b %= MOD;
  }
  cout << ((a*b) % MOD) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int *dp = new int[n];
  for(int i=0;i<n;i++)
    dp[i] = INT_MAX;
  dp[0]=0;
  int *arr = new int[n];
  for(int i=0;i<n;i++)
	cin >> arr[i];
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;j++){
	if(j<n)
	  dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
    }

  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define Int int64_t
#define pb push_back
using namespace std;

int main()
{
   Int N;cin>>N;
   Int Nn=N;
   auto change=[&](Int &N){
       N=(N)*(N+1)*(N+2);
       N/=6LL;
   };
   change(N);
   for(int i=1;i<Nn;++i){
       Int u,v;
       cin>>u>>v;
       if(u>v) swap(u,v);
       N-=(u)*(Nn-v+1);
   }
   cout<<N<<"\n";
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
string s;
cin >> s;
if(s>"2019/04/30")
    cout << "TBD" << endl;
else
    cout << "Heisei" << endl;
}

Measured memory_bytes: 256
s = input()
depth_list = [0]*len(s)
max_depth = [0]*len(s)
d = 0
for i, c in enumerate(s):
    if c == "\\":
        d -= 1
    elif c == "/":
        d += 1
    depth_list[i] = d

m_d = d
for i in range(len(s)-1, -1, -1):
    if s[i] == "\\":
        d += 1
    elif s[i] == "/":
        d -= 1
    max_depth[i] = m_d
    m_d = max(m_d, d)

d = 0
m_d = 0
water = 0
puddles = [0]
for i, n in enumerate(depth_list):
    up = min(m_d, max_depth[i])
    if d < up and d != n or d == up and d > n:
        water += 0.5
    if d < n:
        d = n
    water += max(0, up - d)
    d = n
    m_d = max(m_d, d)

    if d == up and sum(puddles) < int(water):
        m_d = d
        puddles.append(int(water - sum(puddles)))
print(int(water))
print(str(len(puddles)-1)+(" "if len(puddles)>1 else "")+" ".join([str(n) for n in puddles[1:]]))

Measured memory_bytes: 8824
# coding: utf-8
# Your code here!

while 1:
    q=int(input())
    if q==-1: break
    x=q/2
    while abs(x**3-q)>=0.00001*q:
        x=x-(x**3-q)/(3*x**2)
    print(f'{x:.6f}')


Measured memory_bytes: 5680
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [, , X, Y] = input[0].map(Number);
  const x = input[1].map(Number);
  const y = input[2].map(Number);

  const maxX = Math.max(...x);
  const minY = Math.min(...y);

  if (maxX >= Y || minY <= X || maxX >= minY) {
    return "War";
  } else {
    return "No War";
  }
};

console.log(main(read()));


Measured memory_bytes: 29580
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair
 #define pb push_back
 const int N =(1e5) + 1;

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

int arr[n+1];

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

int dp[n+1] = {};
for(int i = 0 ; i <= n ; i ++)
  dp[i] = INT_MAX;

dp[1] =0;

dp[2] = abs(arr[1] - arr[2]); 

for (int i = 3; i <=n; ++i)
{
  for (int j = 1; j <=k && (i - j) >= 1; ++j)
  {
  
  dp[i]=min( dp[i] , dp[i-j] + abs(arr[i-j] - arr[i]));
  }
}
  

cout<<dp[n];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> ans(N,0);

  for(int i = 0; i < N-1; ++i){
    int tmp;
    cin >> tmp;
    --tmp;
    ++ans[tmp];
  }

  for(auto v : ans){
    cout << v << endl;
  }

  return 0;
}


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

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

	int N;
	cin >> N;
	int cnt = 0, mx = 0;
	for (int i = 0; i < N; ++i) {
		int a,b;
		cin >> a >> b;
		if (a==b) {
			cnt++;
		} else {
			cnt = 0;
		}
		// cout << "e " << i << " " << cnt << endl;
		mx = max(cnt, mx);
	}
	// cout << cnt <<endl;
	if (mx >= 3) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

using namespace std;


//ifstream in("input.txt");
//ofstream out("output.txt");
//ios::sync_with_stdio(false);
typedef pair<int,int> pii;
typedef long long int ll;

int N,A[100005],ans;

int main()
{

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

    for(int i=0;i<N;i++)
        if(A[i]==i+1)
        {
            swap(A[i],A[i+1]);
            ans++;
        }

    cout<<ans;

}

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

	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 (a>b) { a=b; return 1; } return 0; }

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

		ll a, b, c, d;
		cin >> a >> b >> c >> d;

		cout << max({a * c, a * d, b * c, b * d}) << endl;
	}


Measured memory_bytes: 3648
#include <stdio.h>

double base[10] = {
	48.0, 51.0, 54.0, 57.0, 60.0, 64.0, 69.0, 75.0, 81.0, 91.0
};
char *name[11] = {
	"light fly", "fly", "bantam", "feather", "light", "light welter",
	"welter", "light middle", "middle", "light heavy", "heavy"
};

int main() {
	int i;
	double weight;

	while (scanf(" %lf ", &weight) != EOF) {
		for (i = 0; i < 10; i++) {
			if (weight <= base[i])
				break;
		}
		puts(name[i]);
	}
	return 0;
}

Measured memory_bytes: 612
/*
ID: duttonl1
TASK: H_Grid_1.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

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


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define MOD 1000000007

char G[1005][1005];
ll dp[1005][1005];

void run() {
    int h, w; cin >> h >> w;
    fr(i,h) fr(j,w)
        cin >> G[i][j]; 

    dp[0][0] = 1; bool flag = false;
    for (int i = 1; i < h; i++) {
        if (G[i][0] == '#') flag = true; 
        dp[i][0] = flag ? 0 : 1;
    }

    flag = false;
    for (int j = 1; j < w; j++) {
        if (G[0][j] == '#') flag = true;
        dp[0][j] = flag ? 0 : 1; 
    }

    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j] = (((G[i][j-1] == '#' ? 0 : dp[i][j-1] + MOD) % MOD +
                       (G[i-1][j] == '#' ? 0 : dp[i-1][j] + MOD) % MOD)  + MOD)
                       % MOD;
        }
    }

    cout << dp[h-1][w-1] << endl;
}




Measured memory_bytes: 9088
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[101000], A, B;
bool Pos(int a) {
	int i;
	int AA = A - B;
	long long s = 0;
	for (i = 1; i <= n; i++) {
		long long t = max(w[i] - 1ll * a*B, 0ll);
		s += (t + AA - 1) / AA;
		if (s > a)return false;
	}
	return true;
}
int main() {
	int i;
	scanf("%d%d%d", &n, &A, &B);
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	int b = 1, e = 1e9, mid, r = 0;
	while (b <= e) {
		mid = (b + e) >> 1;
		if (Pos(mid))r = mid, e = mid - 1;
		else b = mid + 1;
	}
	printf("%d\n", r);
}

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

const int MAX = 110;

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; i++) cin >> h[i];
    int ans = h[0];
    for (int i=1; i<n; i++) {
        if (h[i] > h[i-1]) ans += h[i] - h[i-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1010;

bool dp[N][N][2];
bool use[N][N][2];
int f;

bool dfs(int e, int o, int turn){
    if(use[e][o][turn]) return dp[e][o][turn];
    if(e+o==2){
        if(o==2){
            return f%2==0;
        }
        else{
            return f%2==1;
        }
    }

    bool ret;
    if(turn==0){
        ret = false;
        if(o>=2) ret |= dfs(e+1,o-2,!turn);
        if(e>=1 && o>=1) ret |= dfs(e-1,o,!turn);
        if(e>=2) ret |= dfs(e-1,o,!turn);
    }
    else{
        ret = true;
        if(o>=2) ret &= dfs(e+1,o-2,!turn);
        if(e>=1 && o>=1) ret &= dfs(e-1,o,!turn);
        if(e>=2) ret &= dfs(e-1,o,!turn);
    }

    use[e][o][turn] = true;
    return dp[e][o][turn] = ret;
}

int main(){
    int V;
    cin >>V;
    vector<string> a(V);
    rep(i,V) cin >>a[i];

    int E = 0;
    vector<vector<int>> G(V);
    rep(i,V)rep(j,V)if(a[i][j]=='Y'){
        G[i].pb(j);
        ++E;
    }
    E /= 2;

    int e = 0, o = 0;
    vector<bool> vis(V);
    rep(i,V)if(!vis[i]){
        int ct = 1;
        vis[i] = true;
        queue<int> que;
        que.push(i);
        while(!que.empty()){
            int now = que.front();
            que.pop();
            for(int nx:G[now]){
                if(!vis[nx]){
                    vis[nx] = true;
                    ++ct;
                    que.push(nx);
                }
            }
        }

        if(ct%2==0) ++e;
        else ++o;
    }

    f = V*(V-1)/2 - E;
    cout << (dfs(e,o,0)?"Taro":"Hanako") << endl;
    return 0;
}



Measured memory_bytes: 6160
from collections import defaultdict

h, w, m = map(int, input().split())

row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
    row, col = map(int, input().split())
    row_dict[row] += 1
    col_dict[col] += 1
    row_col_dict[row].add(col)

max_row = max(row_dict.values())
max_col = max(col_dict.values())

max_rows = [k for k, v in row_dict.items() if v == max_row]
max_cols = [k for k, v in col_dict.items() if v == max_col]
ans = max_row + max_col - 1
flg = False
if ans < m:
    for row in max_rows:
        for col in max_cols:
            if not col in row_col_dict[row]:
                ans += 1
                flg = True
                break
        if flg:
            break

print(ans)


Measured memory_bytes: 238792
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int arr[1 << 18];
int n, k;
pii dp[1 << 18];
int ans[1 << 18];

int main() {
	cin >> k;
	n = (1 << k);
	for (int i = 0; i < n; i++) cin >> arr[i];
	dp[0] = make_pair(0, -1);
	ans[0] = arr[0];
	dp[1] = make_pair(0, 1);
	ans[1] = arr[0] + arr[1];
	if (arr[0] < arr[1]) swap(dp[1].first, dp[1].second);
	for (int i = 2; i < n; i++) {
		dp[i] = make_pair(i, -1);
		for (int j = 0; j < k; j++) {
			if (i & (1 << j)) {
				int mask = i ^ (1 << j);//((i >> (j + 1)) << (j + 1)) | (1 << j) - 1;
				pii p = dp[mask];
				if (p.first != dp[i].first) {
					if (arr[p.first] >= arr[dp[i].first]) {
						dp[i].second = dp[i].first;
						dp[i].first = p.first;
						if (p.second >= 0 && arr[p.second] > arr[dp[i].second]) 
							dp[i].second = p.second;
					} else if (dp[i].second < 0 || arr[dp[i].second] < arr[p.first]) {
						dp[i].second = p.first;
					}
				} else if (dp[i].second < 0 || 
					(p.second != - 1 && arr[dp[i].second] < arr[p.second])) {
					dp[i].second = p.second;
				}
			}
		}
		ans[i] = arr[dp[i].first] + arr[dp[i].second];
	}
	// for (int i = 0; i < n; i++) cout << dp[i].first << " " << dp[i].second << endl;
	for (int i = 1; i < n; i++) ans[i] = max(ans[i], ans[i - 1]);
	for (int i = 1; i < n; i++) cout << ans[i] << endl;
	return 0;
}

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

#define ll long long int


int main()
{
	// cin.sync_with_stdio(0);
 //    cin.tie(0);
	
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(a+b,min(a+c,b+c))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, a[100010], b[100010], c[100010];
signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
		if (a[i] > 0)c[i] = a[i];
		if (i) {
			b[i] += b[i - 1];
			c[i] += c[i - 1];
		}
	}
	int ans = 0;
	rep(i, n - k + 1) {
		int cnt = 0;
		if (i)cnt += b[i + k - 1] - b[i - 1];
		else cnt += b[i + k - 1];
		cnt = max(cnt, (ll)0);
		if(i)cnt += c[i - 1];
		cnt += c[n - 1] - c[i + k - 1];
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
import Control.Applicative

import Data.List
    (intercalate)

type Problem = [Int]

type Result = [Int]

slice :: Int -> Int

slice 0
    = 1
    
slice n
    = n + slice (n - 1)
    
solve :: Problem -> Result

solve list
    = map slice list
    
main :: IO ()

main
    = do
        list <- map read <$> lines <$> getContents
        putStrLn $ intercalate "\n" $ map show $ solve list

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define _5day ""

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int n;
int a[N], dp[N], t[N << 2];

void upd(int p, int x, int v = 1, int tl = 0, int tr = n) {
  if (tl == tr) {
    t[v] = x;
    return;
  }
  int tm = tl + tr >> 1;
  if (p <= tm) upd(p, x, v + v, tl, tm);
  else upd(p, x, v + v + 1, tm + 1, tr);
  t[v] = min(t[v + v], t[v + v + 1]);
}
int get(int l, int r, int v = 1, int tl = 0, int tr = n) {
  if (l <= tl && tr <= r) return t[v];
  if (tl > r || tr < l) return inf;
  int tm = tl + tr >> 1;
  return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));
}

int main() {
  #ifndef _5day
    freopen (_5day".in", "r", stdin);
    freopen (_5day".out", "w", stdout);
  #endif

  scanf ("%d", &n);
  rep(i, 1, n) {
    scanf ("%d", &a[i]);
    dp[i] = inf;
  }

  deque <int> l, r;
  rep(i, 1, n) {
    if (sz(l) && a[l.back()] > a[i]) {
      while (sz(l)) l.pp();
    }
    if (sz(r) && a[r.back()] < a[i]) {
      while (sz(r)) r.pp();
    }

    if (i == 1) dp[i] = 1;

    if (sz(l)) dp[i] = min(dp[i], get(l.front() - 1, l.back() - 1) + 1);//, cout << l.front() - 1 << ' ' << l.back() - 1 << ' ' << i << nl;
//    else dp[i] = 1;
    if (sz(r)) dp[i] = min(dp[i], get(r.front() - 1, r.back() - 1) + 1);
//    else dp[i] = 1;
    l.pb(i), r.pb(i);
    upd(i, dp[i]);
  }

  cout << dp[n];
  ioi
}


Measured memory_bytes: 2432