akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define ll long long
#define ull unsigned long long

#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >

#define vi vector < int >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >

#define pb push_back

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

ll a[maxn], cs[maxn];

int main()
{
    fast;

    int n, k;

    cin >> n >> k;

    for(int i = 1; i <= n; i++) cin >> a[i], cs[i] = cs[i - 1] + a[i];

    for(int i = k; i < n; i++){
        ll sum1 = cs[i] - cs[i - k];
        ll sum2 = cs[i + 1] - cs[i - k + 1];

        if(sum2 > sum1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}




Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k <= a)
		cout<<k<<endl;
	else if(a + b >= k)
		cout<<a<<endl;
	else {
		ll v = k - (a + b);
		cout<<a - v<<endl;
	}
	return 0;
}  


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
import math


def solve(N: int, D: int, X: "List[int]", Y: "List[int]"):
    cnt=0
    for i in range(N):
        ditance=math.sqrt((X[i]*X[i])+(Y[i]*Y[i]))
        if ditance<=D :cnt=cnt+1
    print(cnt)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    Y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    solve(N, D, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main()
{
    string S;
    cin >> S;
    int cnt0 = 0, cnt1 = 0;
    rep(i, S.size())
    {
        if (S[i] == '0')
            cnt0++;
        else
            cnt1++;
    }
    cout << min(cnt0, cnt1) * 2 << endl;
    return 0;
}


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

int main(){
 int n;
 cin >> n;
 map<string, int> mp;
 for (int i=0;i<n;i++){
   string s;
   cin >> s;
   mp[s]++;
 }
  
 int mx=0;
 for (auto p:mp) mx=max(mx, p.second);
 for (auto p:mp){
   if (p.second!=mx) continue;
   cout << p.first << endl;
 }
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int my_compare(const void *a, const void *b)
{
    int x = *(int*)a;
    int y = *(int*)b;
    return x - y;
}

int main(int argc, void **arg)
{
    int n, n1, n2;
    int d[100000];
    int d1[100000];
    int d2[100000];
    int i, j, k;
    int max = 0;
    int half = 0;
    int m1 = 0;
    int m2 = 0;

    scanf("%d", &n);

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

    qsort(d, n, sizeof(int), my_compare);

    j = d[n/2] - d[n/2-1];
    printf("%d\n", j);

    return 0;
}


Measured memory_bytes: 892
//semicolon less Java with Stream API
import java.util.stream.*;
import java.util.*;
class Main{
    public static void main(String[] args){
        if(Stream.<String[]>of(new String[]{
            new java.util.Scanner(System.in).next(),
            "CODEFESTIVAL2016"})
            .peek(str -> System.out.println(
                IntStream.range(0, 16)
                .filter(i -> str[0].charAt(i) != str[1].charAt(i))
                .count())
        ).count() > 0){}
    }
}

Measured memory_bytes: 15828
n,m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
dp = [[[0]*(n+1) for i in range(256)] for i in range(n+1)]
dp[1][a[0]][1],x,mod,ans = 1,[0,1],10**9+7,0
for i in range(n+1): dp[i][0][0] = 1
for i in range(2,n+1):
	for j in range(256):
		for k in range(1,i+1): dp[i][j][k] = dp[i-1][j^a[i-1]][k-1]+dp[i-1][j][k]
for i in range(2,257): x.append((x[-1]*i)%mod)
for i in range(n+1): ans = (ans+dp[-1][m][i]*x[i])%mod
print(ans)

Measured memory_bytes: 66560
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	FastScanner sc;

	void run() {
		sc = new FastScanner();
		String[] cards = new String[3];
		for (int i = 0; i < 3; i++) {
			cards[i] = sc.next();
		}

		int[] cardsNum = new int[3];

		final int PLAYER_A = 0;
		final int PLAYER_B = 1;
		final int PLAYER_C = 2;
		int player = PLAYER_A;

		cardsNum[PLAYER_A] = cards[PLAYER_A].length();
		cardsNum[PLAYER_B] = cards[PLAYER_B].length();
		cardsNum[PLAYER_C] = cards[PLAYER_C].length();

		String winner = "";
		while (true) {
			if (cardsNum[player] == 0) {
				break;
			}
			char tmp = cards[player].charAt(cards[player].length() - cardsNum[player]);
			cardsNum[player] = cardsNum[player] - 1;

			player = Character.getNumericValue(tmp) - 10;
		}

		if (player == PLAYER_A) {
			winner = "A";
		} else if (player == PLAYER_B) {
			winner = "B";
		} else {
			winner = "C";
		}

		System.out.println(winner);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans=a*x+b*y,sum;
    sum=ans;
    int tmp=0;
    // cout << sum << endl;
    while(x>0||y>0){
        if(x>0) sum-=a;
        if(y>0) sum-=b;
        sum=sum+2*c;
        x--;y--;tmp+=2;
        if(sum<ans) ans=sum;
        // cout << x << ' '<< y << ' ' << tmp << ' ' << sum << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
int r[4][2] ={{1,0},{0,1},{-1,0},{0,-1}};//90度毎の回転行列用
 
using namespace std;
 
int main(){
    while(1){
        int n; cin>>n;
        if(!n) break;
 
        int m0; cin>>m0;
        vector<pair<int, int> > t(m0);//探す元となる折れ線
        for(int j=0; j<m0; j++){
            int x, y; cin>>x>>y;
            t[j] = make_pair(x, y);
        }
 
        for(int i=1; i<=n; i++){
            int m; cin>>m;
            vector<pair<int, int> > v(m);
            for(int j=0; j<m; j++){
                int x, y; cin>>x>>y;
                v[j] = make_pair(x, y);
            }
            if(m0 != m) continue;
 
            for(int k=0; k<4; k++){
                int vsin=r[k][0], vcos=r[k][1];
                vector<pair<int, int> > tmp(m);
                for(int j=0; j<m; j++){
                    tmp[j].first  =v[j].first*vcos - v[j].second*vsin;
                    tmp[j].second =v[j].first*vsin + v[j].second*vcos;
                }
 
                bool flag = true;
                int move_x = t[0].first - tmp[0].first;
                int move_y = t[0].second - tmp[0].second;
                for(int j=0; j<m; j++){
                    tmp[j].first += move_x;
                    tmp[j].second += move_y;
                }
                for(int j=0; j<m; j++){
                    if(t[j].first != tmp[j].first || t[j].second != tmp[j].second){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    cout << i << endl;
                    break;
                }
 
                flag = true;
                move_x = t[m-1].first - tmp[0].first;
                move_y = t[m-1].second - tmp[0].second;
                for(int j=0; j<m; j++){
                    tmp[j].first += move_x;
                    tmp[j].second += move_y;
                }
                for(int j=0; j<m; j++){
                    if(t[m-j-1].first != tmp[j].first || t[m-j-1].second != tmp[j].second){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    cout << i << endl;
                    break;
                }
            }
        }
        cout <<"+++++"<< endl;
    }
    return 0;
}


Measured memory_bytes: 3008
cnt500=int(input())
cnt100=int(input())
cnt50=int(input())
price=int(input())

cnt=0
for a in range(cnt500+1):
  if cnt500*a > price:
    break
  for b in range(cnt100+1):
    if cnt100*b > price:
      break
    for c in range(cnt50+1):
      if cnt50*c > price:
        break
      if a*500+b*100+c*50 == price:
        cnt+=1
print(cnt)

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

int main()
{
    int N, A, B;

    cin >> N >> A >> B;

    cout << min(A, B) << " ";

    if( min(A, B) - N + max(A, B) < 0 ) cout << 0 << endl;
    else cout << min(A, B) - N + max(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
def poss(x, r, result):
    if x == 0:
        return result + '0'
    if x % pow(2, r) != 0:
        x -= pow(-2, r-1)
        result += '1'
    else:
        result += '0'
    return poss(x, r+1, result)

if N == 0:
    print('0')
else:
    r = poss(N, 1, '')[::-1]
    print(r.lstrip('0'))


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

vector<vector<int>> to;

void dfs(int node, vector<bool>& visited, int& acc) {
  auto& v = visited;
  v[node] = true;

  if (all_of(v.begin(), v.end(), [](bool b) { return b; }))
    acc++;
  else
    for (auto n : to[node])
      if (!v[n])
        dfs(n, v, acc);

  v[node] = false;
  return;
}

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

  to.resize(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<bool> visited(N, false);
  int ans = 0;
  dfs(0, visited, ans);

  cout << ans << endl;
}

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

int main() {
  long long n;
  long long k;
  cin>>n>>k;
  
  long long d = 0;
  
  vector<int> vec(n);
  
  for (long long i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end()); 
  reverse(vec.begin(), vec.end()); 
    
  for (long long i = k; i < n; i++) {
    d=d+vec.at(i);
    }
  cout<<d<<endl;
    
  
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    int a;
    std::cin >> a;
    
    std::cout << a+a*a+a*a*a << std::endl;

    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
            bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        assert(i>0);
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

signed main(){
    int N, Q;
    cin >> N >> Q;
    BIT bitY(N+2), bitX(N+2);
    bitX.add(1, N);
    bitY.add(1, N);
    ll answer = (N-2)*(N-2);
    rep(qi,0,Q) {
        int type, x;
        cin >> type >> x;
        if (type == 1) {
            auto nearestWhite = bitX.sum(x);
            answer -= nearestWhite - 2;
            if (nearestWhite != 2) {
                auto diff = x - bitY.sum(2);
                if (diff<0) {
                    bitY.add(2,diff);
                    bitY.add(nearestWhite,-diff);
                }
            }
        } else {
            auto nearestWhite = bitY.sum(x);
            answer -= nearestWhite - 2;
            if (nearestWhite != 2) {
                auto diff = x - bitX.sum(2);
                if (diff<0) {
                    bitX.add(2, diff);
                    bitX.add(nearestWhite, -diff);
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 6388
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
ab = [inpl() for i in range(n)]
res = 0
for i in range(n)[::-1]:
    a,b = ab[i]
    tmp = b - (a + res) % b
    if tmp == b:
        continue
    res += tmp
print(res)

Measured memory_bytes: 56412
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    q, mod = divmod(N, K)
    print(min(mod, abs(K - mod)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/**
 *１つの単語 W と文章 T が与えられます。T の中にある W の数を出力するプログラムを作成して下さい。 

文章 T に含まれるスペースまたは改行で区切られた文字列を単語 Ti とします。すべての Ti において単語 W と同じになるものを数えて下さい。 

なお、大文字と小文字は区別しません。 

 */

//スキャナつかうため

import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 単語を1つ受け取る
		String strW = sc.next();
		//受け取る文字、結果の数の変数宣言
		String strT;
		int intCounter = 0;
		
		//break があるまで処理を繰り返す
		while (true) {
			//入力を受け取る
			 strT = sc.next();
			 //受け取った文字がEND_OF_TEXTと一致した場合breakする
			if (strT.contains("END_OF_TEXT")) {
				break;
			//受け取った文字がstrWと一致するたびintCounterに＋１する
			//大文字小文字は区別しない。
			} else if (strW.equalsIgnoreCase(strT)) {
				intCounter++;
			}

		}
		//結果表示
		System.out.println(intCounter);
	}
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 2019;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    ll l, r;
    cin >> l >> r;
    int low, high;
    low = MIN(l % 2019, r % 2019);
    high = MAX(l % 2019, r % 2019);
    if (high == 0 || r - l >= 2019)
    {
        cout << 0 << endl;
        return 0;
    }
    ll res = 12345;
    for (int i = low; i < high; i++)
    {
        for (int j = low + 1; j <= high; j++)
        {
            res = MIN(i * j % 2019, res);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val T = Array.fill(N)(sc.nextLong())

    // 各時計は Ti の倍数の時に 上を向く. n * Ti 秒で上になる
    // つまり, 全ての Ti の最小公倍数を求めればそれが 全て上を向く時になる

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

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

    println(T.reduce((a, b) => lcm(a, b)))
  }

}


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

using namespace std;

int main(void) {
    long h, w;
    cin >> h >> w;

    vector<string> m(h);
    for(auto &x: m) cin >> x;

    vector<vector<long>> hh(h, vector<long>(w));
    vector<vector<long>> ww(h, vector<long>(w));

    for(int i=0; i<h; i++) {
        ww[i][0] = m[i][0] == '.';
        for(int j=1; j<w; j++)
            if(m[i][j] == '.')
                ww[i][j] = ww[i][j-1]+1;
        for(int j=w-1-1; j>=0; j--)
            if(m[i][j] == '.')
                ww[i][j] = max(ww[i][j], ww[i][j+1]);
    }

    for(int j=0; j<w; j++) {
        hh[0][j] = m[0][j] == '.';
        for(int i=1; i<h; i++)
            if(m[i][j] == '.')
                hh[i][j] = hh[i-1][j]+1;
        for(int i=h-1-1; i>=0; i--)
            if(m[i][j] == '.')
                hh[i][j] = max(hh[i][j], hh[i+1][j]);
    }

    long r = 0;
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            r = max(r, ww[i][j] + hh[i][j]);
    
    cout << r-1 << endl;
}


Measured memory_bytes: 67072
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>
#include <iomanip>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 100100100;
const ll llINF = 1LL << 60;
string s = "";
int Size;
ll chmin(ll a, ll b)
{
	return a > b ? b : a;
}
int main()
{
	cin >> s;
	reverse(s.begin(), s.end());
	Size = s.size();
	int i = 0;
	while(i < Size) {
		auto dreamItr = s.find("maerd", i);
		auto dreamerItr = s.find("remaerd", i);
		auto eraseItr = s.find("esare", i);
		auto eraserItr = s.find("resare", i);
		if (i == dreamItr)	i += 5;
		else if (i == dreamerItr)	i += 7;
		else if (i == eraseItr)	i += 5;
		else if (i == eraserItr)	i += 6;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 3776
#include <stdio.h>

int judge(int n);

int main(void)
{
	static int n;
	int i;
	int charge;
	
	
	while (1){
		//puts("---farst n ---");
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		charge = judge(n);
		printf("%d\n", charge);
	}
	
	
	
	return (0);
}

int judge(int n)
{
	int x, y, h, w;
	int size;
	static int charge;
	int tmp;
	int i;
	
	i = n;
	
	/*printf("---judge in---\n");
	printf("n = %d\n", n);
	printf("i = %d\n", i);
	printf("charge = %d\n", charge);*/
	
	if (i == 0){
		tmp = charge;
		charge = 0;
		return (tmp);
	}
	
	scanf(" %d %d %d %d", &x, &y, &h, &w);
	
	size = x + y + h;
	
	if (size <= 60 && w <= 2){
		charge += 600;
	}
	else if (size <= 80 && w <= 5){
		charge += 800;
	}
	else if (size <= 100 && w <= 10){
		charge += 1000;
	}
	else if (size <= 120 && w <= 15){
		charge += 1200;
	}
	else if (size <= 140 && w <= 20){
		charge += 1400;
	}
	else if (size <= 160 && w <= 25){
		charge += 1600;
	}
	else {
	}
	
	i--;
	
	judge(i);
}

Measured memory_bytes: 908
n=int(input())
count=0
answer=0
for i in range(n):
    d=list(map(int, input().split()))
    if(d[0]==d[1]):
        count+=1
    else:
        count=0
    if(count>2):
        answer=1

if(answer==1):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   int ans = 0;
   for(int i = 1; i < n; i++){
      int cnt = 0;
      for(char c = 'a'; c <= 'z'; c++){
         bool left = false, right = false;
         // check left
         for(int j = 0; j < i; j++){
            if(s[j] == c){left = true;}
         }
         // check right
         for(int j = i; j < n; j++){
            if(s[j] == c){right = true;}
         }
         if(left && right){
            cnt++;
         }
      }
      if(ans < cnt){
         ans = cnt;
      }
   }
   cout << ans << endl;

   return 0;
}

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

int n, m, u, v, fa[101000], vis[101000];
vector<int> g[101000], leaf[100010], ans;

void Dfs(int x) {
  vis[x] = 1;
  ans.push_back(x);
  for(int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if(vis[v]) continue;
    Dfs(v);
    return;
  }
}

int main(void) {
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  Dfs(1);
  reverse(ans.begin(), ans.end());
  ans.pop_back();
  Dfs(1);
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++)
    printf("%d ", ans[i]);
  return 0;
}


Measured memory_bytes: 12408
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if (N%10 == 3){
      System.out.println("bon");
    }else if(N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 0 || N%10 == 8){
      System.out.println("pon");
    }else{
      System.out.println("hon");
    }
  }
}

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

int main(void) {
  int n, i, sum;
  double m, std;
  int s[1001];
  while(1) {
    scanf("%d", &n);
    if (n == 0) break;
    sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &s[i]);
      sum += s[i];
    }
    m = (double)sum / n;
    std = 0;
    for (i = 0; i < n; i++) std += (s[i] - m) * (s[i] - m);
    printf("%f\n", sqrt(std / n));
  }
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,n){
        ans += a[i];
    }
    ans -= a[n-1]/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Dish[] arr = new Dish[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = new Dish(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(arr);
		long total = 0;
		for (int i = 0; i < n; i++) {
		    if (i % 2 == 0) {
		        total += arr[i].takahashi;
		    } else {
		        total -= arr[i].aoki;
		    }
		}
		System.out.println(total);
	}
	
	static class Dish implements Comparable<Dish> {
	    int takahashi;
	    int aoki;
	    public Dish(int takahashi, int aoki) {
	        this.takahashi = takahashi;
	        this.aoki = aoki;
	    }
	    
	    public int compareTo(Dish another) {
	        return another.takahashi + another.aoki - takahashi - aoki;
	    }
	}
}


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

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

  int A, B;
  cin >> A >> B;
  if(A >= 1 && A <= 9 && B >= 1 && B <= 9){
    cout << A * B << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

vector<int> v[200001];
int vis[200001]={0};
int P =0;
int dfs(int root, int p)
{
	int i;
	vis[root] = 1;
	P++;
	for(i=0; i<v[root].size(); i++)
	{
		int x = v[root][i];
		if(vis[x]==0)
		dfs(x,p);
	}
	return p;
}
int main()
{
	int n ,m, i;
	cin >> n >> m;
	while(m--)
	{
		int a,b;
		cin >> a>> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int sz = 0;
	for(i=1;i<=n;i++)
	{
		int p = 0;
		P=0;
		if(vis[i]==0){
			dfs(i,0);
			sz = max(sz, P);
		}
			
	}
	cout<<sz<<endl;
}


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

#define int long long
#define P(x) {if (debug) cout << x << endl;} 
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define D(i,n) for (int i=(n); i-->0;)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple

using namespace std;

template<class T> ostream& operator<<(ostream& os, V<T> v) {
F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}

const bool debug = 1;

int n;
vector <int> start, stop;
vector <int> S;

bool check(int up) {
    set <int> adj[51];
    for(int i= 0; i <= 50; i++) adj[i].clear();

    for(int j= 0; j <= 50; j++) {
        for(int i= 1; i <= up; i++) {
            adj[j].insert(j%i);             
        }
        for(int x : S) adj[j].insert(j%x);
    }

    vector <bool> visited(50, false);

    for(int i= 0; i < n; i++) {
        queue <int> bfs;
        bfs.push(start[i]);
        visited.assign(50, false);
        bool ok = false;
        while(!bfs.empty()) {
            int curr = bfs.front();
            bfs.pop();
            if(curr == stop[i]) ok = true;
            if(!visited[curr]) {
                visited[curr] = true;
                for(int x : adj[curr]) {
                    bfs.push(x);
                }
            }
        }
        if(!ok) return false;
    }

    return true;
} 

signed main () {
    
    cin >> n;
    for(int i = 0; i < n; i++) {
    	int a; cin >> a; start.pb(a);
    }

    for(int i = 0; i < n; i++) {
    	int a; cin >> a; stop.pb(a);
    }
    
    int cost = 0;
    for(int i= 50; i >= 1; i--) {
        if(!check(i-1)) {
            S.pb(i); 
            cost = cost | (1LL << i);
        }
    }
    if(check(0)) 
    cout << cost << endl;
    else
    cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	while (1)
	{
		int n, s;
		int ans = 0;
		cin >> n >> s;
		if (n == 0 && s == 0)break;
		int comb = (1 << n) - 1;
		while (comb < (1 << 10))
		{
			int sum = 0;
			for (int i = 0; i < 10; i++)
			{
				if ((comb >> i) & 1)sum += i;
			}
			if (sum == s)ans++;
			int x = comb&-comb, y = comb + x;
			comb = ((comb&~y) / x >> 1) | y;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    XY = [list(map(int, input().split())) for _ in range(N)]

    MAX = 10**5
    Xs = [[] for _ in range(MAX+1)]
    Ys = [[] for _ in range(MAX+1)]
    for i, (x, y) in enumerate(XY):
        Xs[x].append(i)
        Ys[y].append(i)

    ans = 0
    checked = [False]*N
    for i in range(N):
        if checked[i]: continue
        q = [i]
        checked[i] = True
        X = set()
        Y = set()
        c = 0
        while q:
            qq = []
            for p in q:
                x, y = XY[p]
                X.add(x)
                Y.add(y)
                c += 1
                for ni in Xs[x]:
                    if not checked[ni]:
                        checked[ni] = True
                        qq.append(ni)
                for ni in Ys[y]:
                    if not checked[ni]:
                        checked[ni] = True
                        qq.append(ni)
            q = qq
        ans += len(X)*len(Y)-c

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 80476
#include <iostream>
using namespace std;
int main()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H' && b == 'H')
	{
		cout << 'H';
	}
	else if (a == 'H' && b == 'D')
	{
		cout << 'D';
	}
	else if (a == 'D' && b == 'H')
	{
		cout << 'D';
	}
	else if (a == 'D' && b == 'D')
	{
		cout << 'H';
	}

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
def main():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = list(map(int, input().split()))
    C = sorted(list(map(int, input().split())))
    ans = 0
    for b in B:
        ans += bisect_left(A, b) * (n - bisect_right(C, b))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24224
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const NQ = input.shift().split(' ').map(v => Number(v))
  const S = input.shift()
  const ans = []
  const count = [0]

  for (let i = 1; i < NQ[0]; i++) {
    let newCount = count[i-1]
    if (S[i-1]==='A'&&S[i]==='C') newCount++
    count.push(newCount)
  }

  input.forEach(val => {
    const LR = val.split(' ').map(v => Number(v))
    ans.push(count[LR[1]-1] - count[LR[0]-1])
  })

  console.log(ans.join('\n'));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;
const int SIZE = 500;
int dp[50][SIZE][SIZE];
    

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, ma, mb; cin >> N >> ma >> mb;
    int A[N],B[N],C[N];
    rep(i, N) cin >> A[i] >> B[i] >> C[i];
    rep(i, 50) rep(j, SIZE) rep(k, SIZE) dp[i][j][k] = mod;
    dp[0][0][0] = 0;
    rep(i, N){
        rep(j, SIZE){
            rep(k, SIZE){
                int ta = j + A[i], tb = k + B[i];
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][ta][tb] = min(dp[i+1][ta][tb], dp[i][j][k] + C[i]);
            }
        }
    }
    int wa = ma, wb = mb;
    int ans = mod;
    while(wa < SIZE && wb < SIZE){
        ans = min(ans, dp[N][wa][wb]);
        wa += ma; wb += mb;
    }
    ans =  (ans == mod) ? -1 : ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 52456
t = list(input())
n = len(t)

if t[0] == '?':
    if n > 1:
        if t[1] == '?':
            t[0] = 'P'
        else:
            t[0] = 'D'
    else:
        t[0] = 'D'
if t[-1] == '?':
    t[-1] = 'D'
for i in range(1,n-1):
    if t[i] == '?':
        if t[i-1] == 'P':
            t[i] = 'D'
        else:
            if t[i+1] == '?' or t[i+1] == 'D':
                t[i] = 'P'
            else:
                t[i] = 'D'

ans = ''.join(t)
print(ans)

Measured memory_bytes: 10932
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int MAX_N = 3100;

int N;
vector<ll> a;

ll dp[MAX_N][MAX_N];

ll Solve(int i, int j)
{
    if (dp[i][j] != -1000000000000LL) return dp[i][j];

    if (i + j >= N) return 0;

    if ((i + j) % 2 == 0)
    {
        return dp[i][j] = max(a[i] + Solve(i + 1, j), a[N - (j + 1)] + Solve(i, j + 1));
    }
    else
    {
        return dp[i][j] = min(- a[i] + Solve(i + 1, j), - a[N - (j + 1)] + Solve(i, j + 1));
    }
}

void _main()
{
    cin >> N;
    a.resize(N);
    rep(i, 0, N) cin >> a[i];

    rep(i, 0, MAX_N) rep(j, 0, MAX_N) dp[i][j] = -1000000000000LL;

    cout << Solve(0, 0) << endl;
}


Measured memory_bytes: 75520
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A = [0] * M
B = [0] * M
high = [0] * N
low = [0] * N
equal = [0] * N
ans = 0

for i in range(M):
    A[i], B[i] = list(map(int, input().split()))
    
for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        high[A[i]-1] += 1
        low[B[i]-1] += 1
    elif H[A[i]-1] < H[B[i]-1]:
        high[B[i]-1] += 1
        low[A[i]-1] += 1
    else:
        equal[A[i]-1] += 1
        equal[B[i]-1] += 1

for i in range(N):
    if high[i] > 0 and low[i] == 0 and equal[i] == 0:
        ans += 1
    elif high[i] == 0 and low[i] == 0 and equal[i] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 23268
#include <stdio.h>
int main(void)
{
int i,n,tmp;
int long sum=0;
int max,min;

scanf("%d",&n);
for (i = 0;i < n;i++)
{
 scanf("%d",&tmp);
  sum += tmp;
  if(i == 0){
    max = tmp;
    min = tmp;
  }else if(max < tmp)
     max = tmp;
  else if(min > tmp)
     min = tmp;
}
printf("%d %d %ld\n",min,max,sum);
     
return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main(void) {
	int m, n_min, n_max;
	int score[205], gap, ans;

	while (1) {
		cin >> m >> n_min >> n_max;
		if (m == 0 && n_min == 0 && n_max == 0) break;

		gap = 0; ans = 0;
		for (int i = 1; i <= m; i++) {
			cin >> score[i];
		}
		for (int j = n_min; j <= n_max; j++) {
			if (score[j] - score[j + 1] >= gap) {
				gap = score[j] - score[j+1];
				ans = j;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b;
    cin >> a >> b;
    int c;
    if (b % a == 0){
        c = a + b;
    } else
    {
        c = b - a;
    }
    cout << c << endl;
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  set<int> a;

  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    if(a.find(x)!=a.end())a.erase(x);
    else a.insert(x);
  }
  
  cout<<a.size()<<endl;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	for(int i=1;i<=m;i++){
		int x;
		cin>>x;
		sum+=x;
	}
	ll ans=max((ll)-1,n-sum);
	cout<<ans<<'\n';
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <stack>

struct str{
	int x0;
	int y0;
	int z0;
}x1[1010],x2[1010];
std::map<int,int> y1,y2;
int z1[3010],z2[3010];
std::vector<int> V1,V2;

int s = 1, t = 1;
int control = 0;
int check[3010][3010],next[3010][3010][5];
long long int value[3010][3010];
std::stack< std::pair<int,int> > St;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++)
	{
		int c,d,e;
		scanf("%d%d%d",&c,&d,&e);
		x1[i] = {c,d,e};
		V1.push_back(c), V1.push_back(d), V2.push_back(e);
	}
	
	for(int i=1;i<=b;i++)
	{
		int c,d,e;
		scanf("%d%d%d",&c,&d,&e);
		x2[i] = {c,d,e};
		V1.push_back(c), V2.push_back(d), V2.push_back(e);
	}
	std::sort(V1.begin(),V1.end());
	std::sort(V2.begin(),V2.end());
	
	for(int i=0;i<V1.size();i++) if(y1[V1[i]]==0) y1[V1[i]] = s, z1[s++] = V1[i];
	for(int i=0;i<V2.size();i++) if(y2[V2[i]]==0) y2[V2[i]] = t, z2[t++] = V2[i];
	
	for(int i=0;i<s;i++) for(int j=0;j<t;j++) next[i][j][1] = next[i][j][2] = next[i][j][3] = next[i][j][4] = 1;
	
	// 1234 = URDL
	
	for(int i=1;i<=a;i++)
	{
		int c = y1[x1[i].x0], d = y1[x1[i].y0], e = y2[x1[i].z0];
		for(int j=c;j<d;j++)
		{
			next[j][e-1][2] = 0;
			next[j][e][4] = 0;
		}
	}
	
	for(int i=1;i<=b;i++)
	{
		int c = y1[x2[i].x0], d = y2[x2[i].y0], e = y2[x2[i].z0];
		for(int j=d;j<e;j++)
		{
			next[c-1][j][1] = 0;
			next[c][j][3] = 0;
		}
	}
	
	for(int i=1;i<=s-2;i++) for(int j=1;j<=t-2;j++) value[i][j] = (long long int)(z1[i+1]-z1[i])*(z2[j+1]-z2[j]);
	
	int x0 = -1, y0 = -1;
	
	for(int i=1;i<=s-2;i++)
	{
		if(z1[i]<=0 && 0<=z1[i+1])
		{
			x0 = i;
			break;
		}
	}
	
	for(int i=1;i<=t-2;i++)
	{
		if(z2[i]<=0 && 0<=z2[i+1])
		{
			y0 = i;
			break;
		}
	}
	
	if(x0==-1 || y0==-1)
	{
		printf("INF");
		return 0;
	}
	long long int ans = 0;
	
	St.push(std::make_pair(x0,y0));
	
	while(!St.empty())
	{
		x0 = St.top().first;
		y0 = St.top().second;
		St.pop();
		
		if(x0==0 || x0==s-1)
		{
			control = 1;
			break;
		}
		if(y0==0 || y0==t-1)
		{
			control = 1;
			break;
		}
	
		if(check[x0][y0]) continue;
		check[x0][y0] = 1;
	
		ans += value[x0][y0];
		// 1234 = URDL
		if(next[x0][y0][1]==1) St.push(std::make_pair(x0+1,y0));
		if(next[x0][y0][2]==1) St.push(std::make_pair(x0,y0+1));
		if(next[x0][y0][3]==1) St.push(std::make_pair(x0-1,y0));
		if(next[x0][y0][4]==1) St.push(std::make_pair(x0,y0-1));
	}
	
	if(control==1) printf("INF");
	else printf("%lld",ans);
}

Measured memory_bytes: 357872
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int h = S / 3600;
		int m = S % 3600 / 60;
		int s = S % 60;
		System.out.println(h + ":" + m + ":" + s);
	}

}


Measured memory_bytes: 26384
#include <iostream>
using namespace std;
int al[30];
int main(){
  string s;
  while(cin>>s){
    for(int i = 0; s.size() > i; i++){
      if('A' <= s[i] && s[i] <= 'Z')al[s[i]-'A']++;
      else if('a' <= s[i] && s[i] <= 'z')al[s[i]-'a']++;
    }
  }
  for(int i = 0; 'z'-'a'+1 > i; i++){
    cout << (char)(i+'a') << " : " << al[i] << endl;
  }
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int K; cin >> K;
  int A,B; cin >> A >> B;
  
  FOR(i,A,B+1){
    if(i % K ==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3576
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
a = list(map(int, input().split()))

class FenwickTree:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 2)
  def sum(self, l, r):
    s = 0
    while l > 0:
      s -= self.data[l]
      l -= l & -l
    while r > 0:
      s += self.data[r]
      r -= r & -r
    return s
  def add(self, i, x):
    i += 1
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def lowerbound(self, s):
    x = 0
    y = 0
    for i in range(self.n.bit_length(), -1, -1):
      k = x + (1 << i)
      if k <= self.n and (y + self.data[k] < s):
        y += self.data[k]
        x += 1 << i
    return x + 1
fwk = FenwickTree(N)
for x in range(N): fwk.add(x, a[x])
for _ in range(Q):
  q, x, y = map(int, input().split())
  if q: print(fwk.sum(x, y))
  else: fwk.add(x, y)

Measured memory_bytes: 127756
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;

	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	
	return 0;

}


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


void solve(long long N){
    for(int i = 0; i < 10; i++){
        if(N >= pow(2,i)) continue;
        else{
            cout << pow(2,i-1) << endl;
            exit(0);
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
 
 
class UnionFind {
public:
	vector<ll>s, p;
	UnionFind(int size) {
		s.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++)makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		s[x] = 1;
	}
	void setcost(int x, ll cost) { 
		s[x] = cost;
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		x = findSet(x);
		y = findSet(y);
		if (x == y)return;
		if (s[x] < s[y])swap(x, y);
		p[y] = x;
		s[x] += s[y];
	}
	int findSet(int x) {
		if (x == p[x])return p[x];
		return p[x] = findSet(p[x]);
	}
	ll getsize(int x) {
		return s[findSet(x)];
	}
};
 
vector<vector<ll>>E;
vector<pair<int, ll>>Eli[101010];
map<pair<int,int>, int>mpE;
int fl[101010];
int used[101010];
 
void dfs(int now,ll cost) {
	fore(x,Eli[now]){
		int to = x.first;
		ll c = x.second;
		int idx = mpE[{min(now,to),max(now,to)}];
		if (c <= cost) {
			if (!used[idx]) { used[idx] = 1; dfs(to, cost); }
		}
	}
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
 
	int N, M;
	cin >> N >> M;
	UnionFind un = UnionFind(N);
 
	for (int i = 0; i < N; i++) {
		ll X;
		cin >> X;
		un.setcost(i, X);
	}
 
	for (int i = 0; i < M; i++) {
		int A, B, X;
		cin >> A >> B >> X;
		A--, B--;
		E.pb({X,A,B});
		Eli[A].pb({ B,X });
		Eli[B].pb({ A,X });
	}
	sort(all(E));
 
 
	queue<vector<ll>>q;
	for (int i = 0; i < M; i++) {
		ll X = E[i][0];
		int A = E[i][1];
		int B = E[i][2];
		mpE[{min(A, B), max(A, B)}] = i;
		ll S;
		while (q.size() && q.front()[0] < X) {
			S = un.getsize(q.front()[1]);
			fl[q.front()[3]] = (S >= q.front()[0]);
			q.pop();
		}
		un.unite(A, B);
		q.push({X,A,B,i});
	}
 
	while (q.size()) {
		ll S = un.getsize(q.front()[1]);
		fl[q.front()[3]] = (S >= q.front()[0]);
		q.pop();
	}
 
 
	for (int i = M - 1; i >= 0; i--) {
		ll X = E[i][0];
		int A = E[i][1];
		int B = E[i][2];
		if (fl[i] != 1)continue;
		used[i] = 1;
		dfs(A,X);
		dfs(B,X);
	}
 
 
	int ans = M;
	for (int i = 0; i < M; i++)ans -= (fl[i]||used[i]);
	puts(ans);
 
	return 0;
}

Measured memory_bytes: 34096