akhauriyash/Code-Regression huggingface dataset:
MOD = 10**9+7
class mint:
    def __init__(self, x):
        self.x = x % MOD if isinstance(x, int) else int(x) % MOD
    def __str__(self):
        return str(self.x)
    __repr__ = __str__
    def __iadd__(self, other):
        self.x += other.x if isinstance(other, mint) else other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __isub__(self, other):
        self.x += MOD-other.x if isinstance(other, mint) else MOD-other
        self.x -= MOD if self.x >= MOD else 0
        return self
    def __imul__(self, other):
        self.x *= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __imod__(self, other):
        self.x %= other.x if isinstance(other, mint) else other
        self.x %= MOD
        return self
    def __add__(self, other):
        return (
            mint(self.x + other.x) if isinstance(other, mint) else
            mint(self.x + other)
        )
    def __sub__(self, other):
        return (
            mint(self.x - other.x) if isinstance(other, mint) else
            mint(self.x - other)
        )
    def __mul__(self, other):
        return (
            mint(self.x * other.x) if isinstance(other, mint) else
            mint(self.x * other)
        )
    def __mod__(self, other):
        return (
            mint(self.x % other.x) if isinstance(other, mint) else
            mint(self.x % other)
        )
    def __truediv__(self, other):
        return (
            mint(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(self.x * pow(other, MOD - 2, MOD))
        )
    def __pow__(self, other):
        return (
            mint(pow(self.x, other.x, MOD)) if isinstance(other, mint) else
            mint(pow(self.x, other, MOD))
        )
    __radd__ = __add__
    def __rsub__(self, other):
        return (
            mint(other.x - self.x) if isinstance(other, mint) else
            mint(other - self.x)
        )
    __rmul__ = __mul__
    def __rmod__(self, other):
        return (
            mint(other.x % self.x) if isinstance(other, mint) else
            mint(other % self.x)
        )
    def __rtruediv__(self, other):
        return (
            mint(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, mint) else
            mint(other * pow(self.x, MOD - 2, MOD))
        )
    def __rpow__(self, other):
        return (
            mint(pow(other.x, self.x, MOD)) if isinstance(other, mint) else
            mint(pow(other, self.x, MOD))
        )

def sumarray(a,b):
    res=b*(b+1)//2
    res-=a*(a-1)//2
    return mint(res)

n,k = map(int, input().split())


ans=mint(0)

for i in range(k,n+2):
    ans+=sumarray(n-i+1,n)-sumarray(0,i-1)+1

print(ans)

Measured memory_bytes: 67972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int x = n % 10;
	if (x == 3) printf("bon\n");
	else if (x == 0 || x == 1 || x == 6 || x == 8) printf("pon\n");
	else printf("hon\n");
	return 0;
}


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

int main() {
   int N,K,x_i,S=0;
   cin >> N >> K;
    
     rep(i, N) {
       cin >> x_i;
       
        if(x_i > (K-x_i)){
          S += (K-x_i);
        }
        else{
          S += x_i;
        }
     }
     cout << 2*S << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    ll N, sum = 0, in;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> in;
        sum += in;
    }
    N = N * (N+1) / 2;
    cout << sum - N << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll h[100005],dp[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdbool.h>
#define H 12
#define W 12

// 島情報
char island[H+2][W+2] = {};

int dir_x[4] = {0,1,0,-1};
int dir_y[4] = {1,0,-1,0};

// (x,y)が島どうか、ついでに陸続きのマスを海に沈める
bool is_island(int x, int y) {
	if(island[y][x]=='1') {
		// マスを'1'以外にする
		island[y][x] = EOF;
		// 4方向の陸続き判定(返り値は使わない)
		for(int d = 0; d < 4; d++) {
			int dx = x+dir_x[d];
			int dy = y+dir_y[d];
			is_island(dx,dy);
		}
		// 陸だったのでtrue確定
		return true;
	}

	// 陸じゃないのでfalse
	return false;
}

int main() {
	while(true) {
		// 各HごとのWの情報
		for(int i = 0; i < H; i++) {
			scanf("%s",&island[i+1][1]);
		}

		// この段階でeofに来てたら処理終了
		if(getchar()==EOF) break;

		// 全マスについてis_islandである数を答えとする
		int ans = 0;
		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				if(is_island(j,i)) {
					ans++;
				}
			}
		}

		printf("%d\n",ans);
	}
}



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

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


void solve(){
    ll a,b,h,m;
    cin >> a >> b >> h >> m;
    double angle, angleh, anglem;
    angleh = 30*h+0.5*m;
    anglem = 6*m;
    angle = abs(angleh-anglem);
    angle = angle*PI/180;
    double ans = a*a+b*b-2*a*b*cos(angle);
    ans = sqrt(ans);
    cout << fixed << setprecision(9);
    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

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


    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    for(int i = 0; i < S.size(); i++) {
        for(int j = 0; j < N; j++) {
            if(S.at(i) == 'Z') {
                S.at(i) = 'A';
            } else {
                S.at(i)++;
            }
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
	scanf("%ld%ld",&x,&y);
	if(x%y!=0)
	{
		printf("%ld\n",x);
		return 0;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

int solve1(void)
{
    ll n, ans;

    cin >> n;

    vector<int> x(n);

    rep(i, 0, n, 1)
    {
        cin >> x[i];
    }

    rep(i, 1, 101, 1)
    {
        ll sum = 0;
        rep(k, 0, n, 1)
        {
            sum += pow(abs(x[k] - i), 2);
        }

        if (i == 1)
        {
            ans = sum;
        }
        else
        {
            ans = min(ans, sum);
        }
    }

    return ans;
}

int solve2(void) //why
{
    ll n, ans;
    ll min, max;

    cin >> n;

    vector<int> x(n);

    rep(i, 0, n, 1)
    {
        cin >> x[i];
    }

    min = *std::min_element(x.begin(), x.end());
    max = *std::max_element(x.begin(), x.end());
    ++max;

    rep(i, min, max, 1)
    {
        ll sum = 0;
        rep(k, 0, n, 1)
        {
            sum += pow(abs(x[k] - i), 2);
        }

        if (i == 1)
        {
            ans = sum;
        }
        else
        {
            ans = std::min(ans, sum);
        }
    }

    return ans;
}

int main(void)
{
    cout << solve1() << endl;
    //cout << solve2() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int n, m;
string a, b;
vector<pair<ll,int>> v;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b,a%b);
}

int main() {
	cin >> n >> m;
	cin >> a >> b;
	ll u = (ll)n*m/gcd(n,m);
	for (int i = 0; i < n; i++) {
		v.push_back({i*u/n,a[i]});
	}
	for (int i = 0; i < m; i++) {
		v.push_back({i*u/m,b[i]});
	}
	sort(v.begin(),v.end());
	bool ok = true;
	for (int i = 1; i < v.size(); i++) {
		if (v[i-1].first == v[i].first) {
			if (v[i-1].second != v[i].second) ok = false;
		}
	}
	if (ok) cout << u << "\n";
	else cout << "-1\n";
}


Measured memory_bytes: 6640
H,W = list(map(int,input().split()))
a = [([c for c in input()] + [0]) for _ in range(H)] + [[0]*(W+1)]

mod = 10**9+7
ij = [[H-1-1,W-1],[H-1,W-1-1]]
a[H-1][W-1] = 1
cnt = 0
while 1:
    i,j = ij[cnt]
    if a[i][j] == ".":
        a[i][j] = 0
        if type(a[i+1][j]) == int:
            a[i][j] += a[i+1][j]
        if type(a[i][j+1]) == int:
            a[i][j] += a[i][j+1]
        a[i][j] %= mod
        if i>0:
            ij.append([i-1,j])
        if j>0:
            ij.append([i,j-1])
    elif a[i][j] == "#":
        a[i][j] = 0
    cnt += 1
    if len(ij) <= cnt:
        break
if a[0][0] == ".":
    a[0][0] = 0
print(a[0][0])

Measured memory_bytes: 316872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	   
	public static void main(String[] args) throws IOException {
		 // TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String lin= br.readLine();
			String[] A = lin.split(" ");
			double a = Double.parseDouble(A[0]);
			double b = Double.parseDouble(A[1]);
			double sum=a+b;
			double x = sum/2;
			long y=Math.round(x);
			System.out.println(y);
	}
}


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

typedef std::vector<int> Ints;

void CountingSort(const Ints& A, Ints& B, int k)
{
	Ints C(k + 1, 0);
	
	//C[i] ??? i ???????????°????¨??????????
	for(unsigned int j = 0; j < A.size(); j++){
		C[A[j]]++;
	}
	//C[i] ??? i ??\????????°???????????°????¨??????????
	for(int i = 1; i <= k; i++){
		C[i] += C[i-1];
	}
	
	for(int j = A.size() - 1; j >= 0; j--){
		B[C[A[j]] - 1] = A[j];
		C[A[j]]--;
	}
}

int main()
{
	int Count;
	std::cin >> Count;
	Ints A(Count);
	Ints B(Count);
	int k = 0;
	for(int i=0; i < Count; i++){
		std::cin >> A[i];
		if(k < A[i]) k = A[i];
	}
	CountingSort(A, B, k);
	for(int i=0; i < Count; i++){
		std::cout << B[i];
		if(i < Count - 1){
			std::cout << " ";
		}else{
			std::cout << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 16800
''' ===========================================
from collections import deque
    appendleft() = push_front(), append = push_back()
    popfleft() = pop_front(), pop() = pop_back()
import heapq #heappush(trgt, val) heappop(trgt) trgt[0] __lt__<
=========================================== '''
##======================================python3
import sys
import collections
from sys import stdin #read(), readline()

sys.setrecursionlimit(10**6)
INF = 1<<50
MINI = 100005

class gv:
    input = None;
    
def build():
    gv.str = input()

def solve():
    slen = len(gv.str)
    if (slen&1) == 1:
        print("No")
        return
    
    for i in range(0,slen,2):
        if (gv.str[i:i+2] == "hi") :
            pass
        else :
            print("No")
            return
    
    print("Yes")
    
    

if __name__ == '__main__':
    build()
    solve()



Measured memory_bytes: 3316
N = int(input())
S = []
for x in range(N):
  S.append(input())

# print(S)
L = 0
K = 0
J = 0
H = 0
for i in range(N):
  if S[i] == "AC":
    L += 1    
  if S[i] == "WA":
    K += 1 
  if S[i] == "TLE":
    J += 1
  if S[i] == "RE":
    H += 1
print("AC x "+str(L))  
print("WA x "+str(K))
print("TLE x "+str(J))
print("RE x "+str(H))

Measured memory_bytes: 16200
#include <iostream>
#include <stdio.h>
#include <ctype.h>
using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	char ch;
    scanf("%c",&ch);

     if(isupper(ch))
     	printf("%c\n",'A' );
     else
     	printf("%c\n", 'a');

   return 0;
}

Measured memory_bytes: 3720
def resolve():
  N, K = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  maxA = max(A)
  base = 10**9+7
  # counter_of_A = [0]*(maxA+1)
  integra_of_counter = [0]*(maxA+1)

  # A の転倒数を数える。
  inversion_num_of_first_A = 0
  for a in reversed(A):
    if a > 1:
      inversion_num_of_first_A += integra_of_counter[a-1]
    
    for x in range(a, maxA+1):
      integra_of_counter[x] += 1


  # B の 2 番目の転倒数を数える
  inversion_num_of_second_A = 0
  for a in reversed(A):
    if a > 1:
      inversion_num_of_second_A += integra_of_counter[a-1]
    
    for x in range(a, maxA+1):
      integra_of_counter[x] += 1
  # print(integra_of_counter)
  # print(inversion_num_of_second_A)

  # print("K =", K, "a =", inversion_num_of_first_A, "d =", inversion_num_of_second_A - inversion_num_of_first_A)
  if K%2 == 0:
    result = K//2 * (2*inversion_num_of_first_A%base + (K-1)*(inversion_num_of_second_A - inversion_num_of_first_A)%base)
  else:
    result = (inversion_num_of_first_A%base + ((K-1)*(inversion_num_of_second_A - inversion_num_of_first_A)//2)%base)*K
  result %= base

  print(result)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 68056
import sys

S = list(input())

odd = S[::2]
even = S[1::2]

flag = True

for i in odd:
      if i == 'L':
            flag = False
            break
for j in even:
      if j =='R':
            flag = False
            break

if flag:
      print('Yes')
else:
      print('No')
            

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
string s;
main()
{
    while(cin>>s)
    {
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='@')
            {
                char c=s[i+2];
                int n=s[i+1]-'0';
                i+=2;
                for(int j=0;j<n;j++)cout<<c;
            }
            else cout<<s[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3048
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(s)
print(i)

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

using ll = long long;

ll n, a, b;

int main(int argc, char *argv[]) {  
	std::ios::sync_with_stdio(false);
	std::cin.tie(0); 
	std::cin >> n >> a >> b;
	if ((b-a)%2==0) {
		std::cout << (b-a)/2 << '\n';
	} else {
		std::cout << std::min(std::min((b-a-1)/2+a, b-1), std::min(n-a, (b-a-1)/2+n-b+1)) << '\n';
	}
}

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[1 << 19][10]; //used, last

ll power(ll k, ll n, int M){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

vector<int> vec[20];

int main(){
  int N, K, M;

  cin >> N >> K >> M;

  if (N >= 2 * K + 1) {
    cout << power(K, N, M) << endl;
    return 0;
  }

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

  for (int i=0; i<(1<<(K*2-1)); i++) {
    int p = __builtin_popcount(i);
    vec[p].push_back(i);
  }

  for (int i=0; i<N-1; i++) {
    for (int p : vec[i]) {
      for (int prev = 0; prev < K; prev++) {
        for (int cur = 0; cur < K; cur++) {
          int d = prev - cur + (K - 1);
          if (p & (1 << d)) continue;

          int nextp = p | (1 << d);
          dp[nextp][cur] = (dp[nextp][cur] + dp[p][prev]) % M;
        }
      }
    }
  }

  ll ans = 0;

  for (int p : vec[N-1]) {
    for (int i=0; i<K; i++) {
      ans += dp[p][i];
    }
  }

  ans = (power(K, N, M) - ans % M + M) % M;

  cout << ans << endl;

  return 0;
}



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

int gcd(int x, int y) {
    return x ? gcd(y%x, x) : y;
}

int main() {
    int K; cin >> K;
    ll sum = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
//Computation - Min, Max and Sum
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		 int n =Integer.parseInt(in.readLine());
		 String[] a = in.readLine().split(" ");

//		int n = Integer.parseInt("10000");

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

		int ai;

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

			ai = Integer.parseInt(a[i]);

			if (ai < min) {
				min = ai;
			}

			if (ai > max) {
				max = ai;
			}

			sum += ai;

		}

		System.out.println(min + " " + max + " " + sum);

	}
}

Measured memory_bytes: 25508
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(N, K, AS):
    for i in range(K, N):
        # debug("i: i,AS[i-K],AS[K]", i, AS[i-K], AS[K])
        if AS[i - K] < AS[i]:
            print("Yes")
        else:
            print("No")


def main():
    # parse input
    N, K = map(int, input().split())
    AS = list(map(int, input().split()))
    solve(N, K, AS)


# tests
T1 = """
5 3
96 98 95 100 20
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
Yes
No
"""

T3 = """
15 7
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
Yes
Yes
No
Yes
Yes
No
Yes
Yes
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 100292
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int n,ans; cin >> n;
 for(int i=0;i<100000;i++){
   int m=n+i;
   bool flag=1;
   for(int j=2;j<m;j++){
     if(m%j==0){
       flag=0;
       break;
   }
 }
   if(flag){
     ans=m;
     break;
   }
 
 
}
cout << ans << endl;
}

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

typedef long long ll;

const int MAX_N = 1e5;

int bit[MAX_N + 1], n;

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
        //cout << i << " ";
    }
    //cout << endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N), s(N + 1, 0);
    map<ll, int> m;
    m[0] = 1;
    rep(i, N) {
        cin >> a[i];
        a[i] -= K;
        s[i + 1] = s[i] + a[i];
        m[s[i + 1]]++;
    }
    /*
    for (auto i : m) {
        cout << i.first << " " << i.second << endl;
    }
    */
    int j = 1;
    n = m.size();
    for (auto i : m) {
        int l = i.second;
        //cout << i.first << " " << i.second << endl;
        add(j, l);
        m[i.first] = j;
        j++;
    }
    /*
    for (auto i : m) {
        cout << i.first << " " << i.second << endl;
    }
    */
    rep(i, N + 1) {
        s[i] = m[s[i]];
        //cout << s[i];
    }
    //cout << endl;
    //cout << n << endl;
    //rep(i, n) cout << sum(i) << " ";
    //cout << endl;
    ll ans = 0;
    rep(i, N + 1) {
        add(s[i], -1);
        //rep(j, n) cout << bit[j] << " ";
        //cout << endl;
        ans += sum(n);
        if (s[i] > 0) ans -= sum(s[i] - 1);
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10940
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Ope = Tuple!(int, "y1", int, "x1", int, "y2", int, "x2");

void main() {
    int N;
    scan(N);

    auto set = redBlackTree!(string)();
    bool ok = true;

    string wp = readln.chomp;
    set.insert(wp);

    foreach (i ; 1 .. N) {
        string w;
        scan(w);
        if (w in set) ok = false;
        if (wp[$ - 1] != w[0]) ok = false;
        wp = w;
        set.insert(w);
    }

    writeln(ok ? "Yes" : "No");
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb  					push_back
#define mp 						make_pair
#define all(v) 					((v).begin()) ,((v).end())
#define let(o,v)				memset(o,v,sizeof (o))
typedef long long 				ll;
typedef vector<int>				vi;
typedef vector<vi>				vvi;
typedef vector<string>			vs;

const int MOD = (int)1e9 + 7;
const int oo = (int)1e9;
const ll OO = (ll)1e18;
const double PI = acos(-1.0);
const int N = (int)1e6 + 9;

bool isprime(int n) {
	if (n <= 1)
		return 0;
	for (int i = 2; i*i <= n; i++)
		if (n%i == 0)
			return false;
}
ll intlog(ll base, ll x) {
	return (log(x) / log(base));
}
bool prime[N];
void primee()
{

	for (int p = 2; p*p <= N; p++)
	{

		if (prime[p] == true)
		{
			for (int i = p * 2; i < N; i += p)
				prime[i] = false;
		}
	}

}
string decToBinary(ll n)
{
	string z = "";
	int i = 0;
	while (n > 0) {

		z += (n % 2) + 48;
		n = n / 2;
		i++;
	}
	reverse(all(z));
	return z;
}
ll n, x;
vector<ll> v,v2;
void getDiv(ll num) {
	for (int i = 1; i * i <= num; i++)
	{
		if (num%i == 0) v2.pb (i),v2.pb(num/i);
	}
	
}
bool check(ll num) {
	for (int i = 0; i < n; i++)
	{
		if ((v[i + 1] - v[i]) % num != 0) return 0;
	}
	return 1;
}
int main()
{
	
	scanf("%lld%lld", &n, &x);
	
	for (int i = 0; i < n; i++)
	{
		ll z;
		scanf("%lld", &z);
		v.pb(z);
	}
	v.pb(x);
	sort(all(v));
	int idx = lower_bound(v.begin(), v.end(), x)-v.begin();
	ll mn = -1;
	if (idx != n && idx != 0) {
		mn = min(v[idx + 1] - v[idx], v[idx] - v[idx - 1]);
	}
	else if (idx == 0) {
		mn = v[1] - v[0];
	}
	else {
		mn = v[idx] - v[idx - 1];
	}
	getDiv(mn);
	sort(all(v2));
	while (!v2.empty()) {
		if (check(v2.back())) {
			printf("%lld\n", v2.back());
			break;
		}
		v2.pop_back();
	}
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>

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

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

    vi a(n), cnt(n, 0);
    rep(i, 0, n)
    {
        cin >> a[i];
        cnt[a[i] - 1]++;
    }
    sort(cnt.begin(), cnt.end());
    reverse(cnt.begin(), cnt.end());
    rep(i, 0, k)
    {
        n -= cnt[i];
    }
    cout << n << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  unordered_map<ll, ll> mp;
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
    mp[A[i]]++;
  }
  ll sum = 0;
  for (auto &e : mp)
  {
    ll t = e.second;
    sum += t * (t - 1) / 2;
  }
  for (int i = 0; i < N; ++i)
  {
    cout << sum - mp[A[i]] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 9160
a=int(input())
l=[int(i) for i in input().split()]
mul=1
f=0
if 0 in l:
    print(0)
else:
    for i in l:
        mul*=i
        if mul>10**18:
            f=1
            print(-1)
            break
    if f==0:
        print(mul)
    

Measured memory_bytes: 21572
import collections

n = int(input())
v = list(map(int, input().split()))

ls1 = v[::2]
ls2 = v[1::2]

c1 = collections.Counter(ls1)
c2 = collections.Counter(ls2)

ch1, cnt1 = c1.most_common()[0][0], c1.most_common()[0][1]
ch2, cnt2 = c2.most_common()[0][0], c2.most_common()[0][1]

ret = 0
if ch1 != ch2:
    ret = n - cnt1 - cnt2
else:
    if cnt1 > cnt2:
        ret = n - cnt1 - c2.most_common()[1][1]
    elif cnt1 < cnt2:
        ret = n - cnt2 - c1.most_common()[1][1]
    else:
        if len(c1.most_common()) > 1 and len(c2.most_common()) > 1:
            cn1 = c1.most_common()[1][1]
            cn2 = c2.most_common()[1][1]
            ret = n - cnt1 - max(cn1, cn2)
        elif len(c1.most_common()) == 1 and len(c2.most_common()) > 1:
            ret = n - cnt1 - c2.most_common()[1][1]
        elif len(c1.most_common()) > 1 and len(c2.most_common()) == 1:
            ret = n - cnt2 - c1.most_common()[1][1]
        else:
            ret = n // 2

print(ret)


Measured memory_bytes: 19032
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
struct node{
	int y,next;
}a[800010];int len=0,last[400010];
int n,m,c[400010],dis[400010];
bool vis[400010];
char s[200010];
void ins(int x,int y)
{
	a[++len].y=y;
	a[len].next=last[x];last[x]=len;
}
void insert(int x,int y,int c)
{
	int X=x+n,Y=y+n;
	if(c==1) ins(x,Y),ins(y,X);
	else ins(X,y),ins(Y,x);
}
bool dfs(int x)
{
	if(vis[x]) return true;
	vis[x]=true;
	for(int i=last[x];i;i=a[i].next)
	{
		int y=a[i].y;
		if(dis[y]<dis[x]+1)
		{
			dis[y]=dis[x]+1;
			if(dfs(y)) return true;
		}
	}
	vis[x]=false;
	return false;
}
int main()
{
	scanf("%d %d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) c[i]=s[i]-'A';
	for(int i=1;i<=m;i++)
	{
		int x,y;scanf("%d %d",&x,&y);
		//ins(x,y);ins(y,x);
		if(c[x]==c[y]) insert(x,y,1);
		else insert(x,y,0);
	}
	memset(vis,false,sizeof(vis));
	for(int i=1;i<=n;i++)
		if(dfs(i)) {printf("Yes");return 0;}
	printf("No");
}

Measured memory_bytes: 15744
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, w int
	fmt.Scan(&n, &w)

	var ws, vs []int
	for i := 0; i < n; i++ {
		var ww, vv int
		fmt.Scan(&ww, &vv)
		ws = append(ws, ww)
		vs = append(vs, vv)
	}

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, w+1)
	}

	for j := 0; j < w+1; j++ {
		if j >= ws[0] {
			dp[0][j] = vs[0]
		} else {
			dp[0][j] = 0
		}
	}

	for i := 1; i < n; i++ {
		for j := 0; j < w+1; j++ {
			if j - ws[i] >= 0 {
				dp[i][j] = int(math.Max(float64(dp[i-1][j]), float64(vs[i] + dp[i-1][j-ws[i]])))
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}

	fmt.Println(dp[n-1][w])
}

Measured memory_bytes: 81536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll l,r,sum = 1000000,temp;
    cin>>l>>r;
    if(r-l>3000)
    {
        cout<<"0"<<endl;
        return 0;
    }
    for(ll i = l;i<r;i++)
    {
        for(ll j = i+1;j<=r;j++)
        {   temp = (i%2019*j%2019)%2019;
            if(temp<sum)
                sum = temp;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
[N,K]=[int(i) for i in input().split()]
h=[int(i) for i in input().split()]
DP=[1000000000 for i in range(N)]
DP[0]=0
for i in range(N):
	for j in range(max(i-K,0),i):
		DP[i]=min(DP[j]+abs(h[i]-h[j]),DP[i])


print(DP[N-1])

Measured memory_bytes: 56544
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 105;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

string s;
int main(int argc, char* argv[]) {
    cin >> s;
    int res = 0;
    for (int i = 0; i < s.length() / 2; ++i) {
        if (s[i] != s[s.length() - i - 1]) {
            res ++;
        }
    }
    printf("%d\n", res);
    return 0;
}

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

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

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

	for (int i = 64; i >= 1; i /= 2) {
		if (N >= i) {
			cout << i;
			return 0;
		}
	}

	return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int d, t, s; cin >> d >> t >> s;
    if (t*s>=d) {
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionH
    {
        /// <summary>
        /// B - Popular Vote
        /// https://atcoder.jp/contests/abc161/tasks/abc161_b
        /// </summary>
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var num_NM= Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            // 整数配列の入力
            var num_A = Console.ReadLine().Split(' ').Select(i => int.Parse(i));

            //総得票数
            double num_SumA = num_A.Sum();

            var num_M = num_NM[1];

            var num_Limit = num_SumA / (4 * num_M);

            var num_Count = num_A.Count(a => a >= num_Limit);

            if (num_Count >= num_M) Console.WriteLine("Yes");
            else Console.WriteLine("No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28296
// C++ program to find if a number is divisible by 
// 9 or not 
#include<bits/stdc++.h> 
using namespace std; 

// Function to find that number divisible by 9 or not 
int check(string str) 
{ 
	// Compute sum of digits 
	int n = str.length(); 
	int digitSum = 0; 
	for (int i=0; i<n; i++) 
		digitSum += (str[i]-'0'); 

	// Check if sum of digits is divisible by 9. 
	return (digitSum % 9 == 0); 
} 

// Driver code 
int main() 
{ 
	string str;
  cin>>str;
	check(str)? cout << "Yes" : cout << "No "; 
	return 0; 
} 


Measured memory_bytes: 3928
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;

vector<string> s;
ll ret = 0;
int n;

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string si;
		cin >> si;
		sort(si.begin(), si.end());
		s.push_back(si);
	}
	sort(s.begin(), s.end());
	int pos = 0;
	ll tmp = 0;
	for (int i = 1; i < n; i++) {
		if (s[pos] == s[i])
			tmp++;
		else {
			ret += tmp * (tmp + 1) / 2;
			pos = i;
			tmp = 0;
		}
	}
	ret += tmp * (tmp + 1) / 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 5748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication9
{
    //ONLINE JUDGE (ITP1_7_C)
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int r = int.Parse(s[0]);
            int c = int.Parse(s[1]);

            int[,] Array = new int[r, c];

            for (int i = 0; i < r; ++i)                 //??\??????????????????????¬?????????????????´?
            {
                string[] str = Console.ReadLine().Split(' ');

                for (int j = 0; j < c; ++j)
                {
                    Array[i, j] = int.Parse(str[j]);
                }
            }

            
            int[] rSum = new int[c + 1];                //??????????¨??????\????????????

            for (int i = 0; i < r; ++i)
            {
                int cSum = 0;                          //??????????¨??????\???????????°

                for (int j = 0; j < c; ++j)
                {
                    cSum += Array[i,j];
                    rSum[j] += Array[i,j];
                    Console.Write("{0} ", Array[i, j]);

                }
                Console.WriteLine(cSum);
                rSum[c] += cSum;
            }
            for (int i = 0; i < rSum.Length-1; ++i)
            {
                Console.Write("{0} ", rSum[i]);
            }
            Console.WriteLine(rSum[c]);
        }
    }
}

Measured memory_bytes: 5828
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include <bitset>
#include<math.h>
#include<queue>
using namespace std;
#define MAX 300000
#define INF 3000
typedef long long ll;
typedef pair<int,int> P;

int c[100][100],dis[100][100];
int H,W;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
queue<P> Q;


void bfs(){
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++) dis[i][j]=INF;
  }

  Q.push(P(1,1));
  P p=Q.front();
  dis[1][1]=1;

  while(Q.size()){
    P p=Q.front(); Q.pop();
    
    if(p.first==H && p.second==W) break;

    for(int i=0;i<4;i++){
      int ny=p.first+dy[i]; int nx=p.second+dx[i];

      if(0<ny && 0<nx && nx<=W && ny<=H && c[ny][nx]==1 && dis[ny][nx]==INF){
        Q.push(P(ny,nx));
        dis[ny][nx]=dis[p.first][p.second]+1;
      }
    }
  }

}

int main(){
  int count=0;
  char data;
  cin>>H>>W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>data;
      if(data=='.'){
        count++;
        c[i][j]++;
      }
    }
  }
  bfs();
  if(dis[H][W]==INF) cout<<-1<<endl;
  else cout<<count-dis[H][W]<<endl;






}


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

int main() {
  int n;
  cin >> n;
  vector<int> r(n);
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  int maxv = r[1] - r[0];
  int minv = r[0];
  for (int j = 1; j <= n - 1; j ++) {
    maxv = max(maxv, r[j] - minv);
    minv = min(minv, r[j]);
  }
  cout << maxv << endl;
}



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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    int i=1;
    while (true) {
        int tmp = K*i;
        if (tmp>=A && tmp<=B) {
            cout << "OK";
            return 0;
        }
        if (tmp>B) {
            cout << "NG";
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;


int main(void){
  ll h, w;
  cin >> h >> w;
  
  vector<string> s = vector<string>(h);
  for (int i = 0; i < h; i++){
    cin >> s[i];
  }
  vector<vector<ll>> edge(h*w, vector<ll>(h*w, INF));
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (s[i][j] == '#')
        continue;

      edge[i*w + j][i*w + j] = 0;
      if (i != h - 1 && s[i+1][j] == '.'){
        edge[i*w + j][(i+1)*w + j] = 1;
        edge[(i+1)*w + j][i*w + j] = 1;
      }
      if (j != w - 1 && s[i][j+1] == '.'){
        edge[i*w + j][i*w + j + 1] = 1;
        edge[i*w + j + 1][i*w + j] = 1;
      }
    }
  }

  for (int k = 0; k < h*w; k++){
    for (int i = 0; i < h*w; i++){
      for (int j = 0; j < h*w; j++){
        edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < h*w; i++){
    for (int j = 0; j < h*w; j++){
      if (edge[i][j] != INF){
        res = max(res, edge[i][j]);
      }
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1536
void main() {
  problem();
}

void problem() {
  auto D = scan!int;
  auto T = scan!int;
  auto S = scan!int;

  bool solve() {
    return T * S >= D;
  }

  writeln(solve() ? "Yes" : "No");
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 2740
#include<iostream>
using namespace std;
string s1,s2;
int ans=0;
int main()
{
	cin>>s1>>s2;
	if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0])
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
    int n,i,j;
    int taro=0,hana=0;
    char t[101],h[101];
 
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",&t,&h);
        j=strcmp(t,h);
        if (j>0) taro+=3;
        else if (j<0) hana+=3;
        else {taro++;hana++;}
    }
    printf("%d %d\n",taro,hana);
    return 0;
}

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

bool solve(char c)
{
	char s[]{"aiueo"};
	for (int i = 0; i < 5; i++)
		if (c == s[i]) return true;
	return false;
}

int main()
{
	char c;
	scanf("%c", &c);
	if (solve(c)) printf("vowel\n");
	else printf("consonant\n");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int m = (n * (n - 2) + (n & 1)) / 2;
	cout << m << endl;
	int sum = n / 2 * 2 + 1;
	for(int i = 1; i <= n; i ++)
	{
		for(int j = i + 1; j <= n; j ++)
			if(j != i && i + j != sum)
				cout << i << " " << j << endl;
	}
	return 0;
}

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

int mini(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  int N,i;
  cin >> N;
  int A[N],B[N-1];
  for(i=0;i<N;i++){
    cin >> B[i];
    A[i]=0;
  }
  A[N-1]=B[N-2];
  
  for(i=1;i<N-1;i++){
    A[N-1-i]=mini(B[N-1-i],B[N-2-i]);
  }
  A[0]=B[0];
  
  int ans=0;
  for(i=0;i<N;i++){
    ans+=A[i];
  }
  
  cout << ans << endl;
} 

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<long long, long long> ii;

const int N = 1e5 + 5;

ii a[N];

int n;

vector<pair<ii, int>> queries;

long long mn = LLONG_MAX, sum, sum1, sum2;

ii used[N];

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].fi >> a[i].se;
        sum1 += a[i].fi; sum2 += a[i].se;
        queries.pb({{a[i].fi, i}, 1});
        queries.pb({{a[i].se, i}, 2});
    }
    mn = min(mn, sum1); mn = min(mn, sum2);
    sort(queries.begin(), queries.end());
    for(int i = 0; i < queries.size(); i++) {
        if(i < n - 2)
            sum += queries[i].fi.fi;
        if(queries[i].se == 1)
            used[queries[i].fi.se].fi = i;
        else
            used[queries[i].fi.se].se = i;
    }
    for(int i = 1; i <= n; i++) {
        if(used[i].fi >= n - 2 && used[i].se >= n - 2)
            mn = min(mn, sum + a[i].fi + a[i].se);
        else if(used[i].fi < n - 2 && used[i].se >= n - 2) {
            int pos = n - 2;
            if(used[i].se == n - 2) pos++;
            mn = min(mn, sum + a[i].se + queries[pos].fi.fi);
        }
        else if(used[i].fi >= n - 2 && used[i].se < n - 2) {
            int pos = n - 2;
            if(used[i].fi == n - 2) pos++;
            mn = min(mn, sum + a[i].fi + queries[pos].fi.fi);
        }
        else {
            int pos = n - 2, pos1 = n - 1;
            mn = min(mn, sum + queries[pos].fi.fi + queries[pos1].fi.fi);
        }
    }
    cout << mn;
}


Measured memory_bytes: 9708
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
const int mod=998244353;
int n,ans=1;
int a[maxn];

int gcd(int a,int b){
	return !b?a:gcd(b,a%b);
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	sort(a,a+n);
	rep(i,n)ans=1LL*ans*gcd(a[i],i)%mod;
	printf("%d\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 640