akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    static final int LIMIT = 40;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextLong();
        }

        System.out.println(solve(A, K));

        sc.close();
    }

    static long solve(long[] A, long K) {
        int[] count0s = new int[LIMIT + 1];
        int[] count1s = new int[LIMIT + 1];
        for (long Ai : A) {
            for (int i = 0; i <= LIMIT; ++i) {
                if ((Ai & (1L << i)) == 0) {
                    ++count0s[i];
                } else {
                    ++count1s[i];
                }
            }
        }

        long result = -1;
        long sum = 0;
        for (int i = LIMIT; i >= 0; --i) {
            long power = 1L << i;

            if (K >= power) {
                long nextSum = count1s[i] * power;
                for (int j = 0; j < i; ++j) {
                    nextSum += Math.max(count0s[j], count1s[j]) * (1L << j);
                }
                result = Math.max(result, sum + nextSum);

                sum += count0s[i] * power;
                K -= power;
            } else {
                sum += count1s[i] * power;
            }
        }
        result = Math.max(result, sum);

        return result;
    }
}

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

void chmax(int &a, int b) {
    if(a < b) a = b;
}

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

    vector<int> a(n), b(n), c(n);
    vector<vector<int>> x(n, vector<int>(3));
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        
        x[i][0] = a[i];
        x[i][1] = b[i];
        x[i][2] = c[i];
    }
    
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + x[i][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        chmax(ans, dp[n][i]);
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define debug(a) cout << #a << ": " << a << endl;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }

  vector<int> left(N + 2, 0);
  vector<int> right(N + 2, 0);

  for (int i = 1; i <= N; i++) {
    left[i] = max(A[i], left[i - 1]);
  }
  for (int i = N; i >= 0; i--) {
    right[i] = max(A[i], right[i + 1]);
  }

  for (int i = 1; i <= N; i++) {
    cout << max(left[i - 1], right[i + 1]) << endl;
  }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,a[200010],ans[200010],sum,k;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(ll i=1; i<=n; i++) cin >> a[i];

    for(ll i=n; i>=1; i--){
        sum=0;
        for(ll j=i+i; j<=n; j+=i) sum+=ans[j];
        sum%=2;
        ans[i]=sum^a[i];
        if(ans[i]) k++;
    }

    cout << k << endl;
    for(ll i=1; i<=n; i++) if(ans[i]) cout << i << " ";

    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int N;
        cin >> N;
        int order[N];
        for(int i = 0; i < N; i++) cin >> order[i];

        int k = 1, count = 0;
        while(true){
            k = order[k-1];
            ++count;
            if(k==2) break;
            else if(count>1e6) break;
            }
        if(count > 1e6) cout << -1;
        else cout << count;
    }

Measured memory_bytes: 640
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w = map(int,input().split()) #n:頂点数　w:辺の数
edge=[]
d = [[float("inf")]*n for i in range(n)]
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(w):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    edge.append([x,y,z])
    d[x][y] = z
    d[y][x] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(d)
#print(edge)
count=0
for x,y,z in edge:
    flag=True
    for i in range(n):
        for j in range(n):
            if d[i][j]==d[i][x]+z+d[y][j]:
                #print(i,x,y,j)
                flag=False
    if flag==True:
        count+=1
print(count)

#インデックスで与えられていることに注意
#ソース　https://juppy.hatenablog.com/entry/2018/11/01/蟻本_python_全点対最短経路法（ワーシャルフロイド法


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

using namespace std;

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

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i,M) cin >> B[i];
  int ans = 0;
  rep(i,N){
    int point = 0;
    rep(j,M){
      int A;
      cin >> A;
      point += A*B[j];
    }
    if (point + C > 0) ++ans;
  }
  cout << ans << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1);
	rep(i,n) {
		cin >> a[i+1];
	}
	// floor(n)+1,…nまでは一意に定まる
	for (int i=n/2+1;i<=n;i++) {
		b[i] = a[i];
	}

	for (int i=n/2;i>=1;i--) {
		int sum_b = 0;
		for(int j=2*i;j<=n;j+=i) {
			sum_b += b[j];
		}
		sum_b %= 2;
		b[i] = (2 + a[i] - sum_b) % 2;
	}
	int m = 0;
	rep(i,n) {
		m += b[i+1];
	}
	cout << m << endl;
	rep(i,n) {
		if (b[i+1] == 1) cout << i+1 << " ";
	}
	return 0;
}


Measured memory_bytes: 2432
local n = io.read("*n")
if n % 4 == 0 then
  print("Yes")
elseif n % 4 == 1 then
  print(21 <= n and "Yes" or "No")
elseif n % 4 == 2 then
  print(14 <= n and "Yes" or "No")
else
  print(7 <= n and "Yes" or "No")
end


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, p;
  cin >> a >> b;
  p = a * b;

  if (!(p % 2 == 0)) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
vector<vector<int>> G;
vector<int> deep;
vector<int> parent;
void dfs(int v,int d){//vは今見てる頂点,dは深さ
    deep[v] = max(deep[v],d);//一番深いところを深さとする
    for(auto nv:G[v]){//nvは次の頂点
        dfs(nv,d+1);//次の頂点を今見てる頂点にする。深さを1プラスする
        parent[nv] = v;//次の頂点の親は今見てる頂点だよね？
    }
}

signed main(){
    cin >> N;
    vector<int> use(N,0);
    G.resize(N);
    deep.resize(N);
    parent.assign(N,-1);
    for(int i=0;i<N;i++){
        int id,k;cin >> id >> k;
        G[id].resize(k);
        for(int j=0;j<k;j++){
            cin >> G[id][j];
            use[G[id][j]] = 1;
        }
    }
    for(int i=0;i<N;i++){
         if(!use[i]) dfs(i,0);
    }
    for(int i=0;i<N;i++){
        cout << "node " << i << ": parent = " << parent[i];
        cout << ", depth = " << deep[i] << ", ";
        if(parent[i]==-1){
            cout << "root, [";
            if(G[i].size()<=0) cout << "]" << endl;
            for(int j=0;j<G[i].size();j++){
                if(j!=G[i].size()-1) cout << G[i][j] << ", ";
                else cout << G[i][j] << "]" << endl;
            }
        }
        else if(G[i].size()>0){
            cout << "internal node, [";
            for(int j=0;j<G[i].size();j++){
                if(j!=G[i].size()-1) cout << G[i][j] << ", ";
                else cout << G[i][j] << "]" << endl;
            }
        }

        else cout << "leaf, []" << endl;

    }

}


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

int max(int a, int b) {
  return (a > b) ? a : b;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a;
  a.resize(2);
  for(int i = 0; i < 2; i++) {
    a[i].resize(n);
  }
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < n; j++) {
      int x = 0;
      if (j > 0) {
	x = max(x, a[i][j - 1]);
      }
      if (i > 0) {
	x = max(x, a[i - 1][j]);
      }
      a[i][j] += x;
    }
  }
  cout << a[1][n - 1];
  return 0;
}

Measured memory_bytes: 256
N = int(input())
dp = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
    a,b,c = map(int,input().split())
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[N]))


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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;

int N, D;
char s[10005];
int dp[10005][105];

int brut()
{
    freopen("1.in", "r", stdin);

    int N, D;
    cin >> N >> D;

    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        int aux = i;
        int sum = 0;
        while(aux)
        {
            sum += aux % 10;
            aux /= 10;
        }
        if(sum % D == 0)    ans++;
    }
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    scanf("%s\n", s + 1);
    scanf("%d", &D);
    N = strlen(s + 1);

    if(D == 1)
    {
        int ans = 0;
        for(int i = 1; i <= N; i++)
            ans = (1LL * ans * 10 + s[i] - '0') % mod;
        printf("%d\n", ans);
        exit(0);
    }

    auto addto = [](int &x, int y) { x += y; if(x >= mod) x -= mod; } ;

    dp[0][0] = 1;
    for(int i = 0; i < N; i++)
        for(int c = 0; c < 10; c++)
            for(int j = 0; j < D; j++)
                addto(dp[i + 1][(j + c) % D], dp[i][j]);

    int sum = 0;
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        int cif = s[i] - '0';
        for(int c = 0; c < cif; c++)
        {
            int nowsum = (sum + c) % D;
            addto(ans, dp[N - i][(D - nowsum) % D]);
        }
        sum += cif;
    }
    if(sum % D == 0)    addto(ans, 1);

    ans = (ans - 1 + mod) % mod;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4352
a, b, c = map(int,input().split(' '))
k = int(input())

while k > 0:
    if c <= b:
        c *= 2
    elif b <= a:
        b *= 2
    k -= 1
    
    if a < b and b < c:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 9136
n, m = map(int, input().split())
cnt = [0 for i in range(34)]
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(x[0]):
		cnt[x[j+1]] += 1
ans = 0
for i in range(m):
	if cnt[i+1] == n:
		ans += 1
print(ans)

Measured memory_bytes: 3060
N = int(input())
X = list(map(int, input().split()))
a = 0
for i in range(N):
    a += X[i]
a /= N
a += 0.5
a = int(a)
ans = 0
for j in range(N):
    ans += (X[j]-a)**2
print(ans)
    
    


Measured memory_bytes: 38384
# -*- coding:utf-8 -*-
""" 解説 Union-Find (Disjoint Set)
グラフにおいて、「つなぐ処理」はOK。「きりはなす処理」は難しい

1 2 3 4 5 の島を考える

・3と5をつなげる
1 2 3 4
    |
    5

・3と1をつなげる（要素の多いものにつなげる）
2 3 4
    +--
    | |
    5 1

・2と4をつなげる
3    2
+--  |
| |  |
5 1  4

・1と4をつなげる（1のグループの3と、4のグループの2をつなぐ）
    3
--+--
| | |
5 1 2
    |
    4

・ただし、あとで4の親を付け替える
    3
--+----
| | | |
5 1 2 4


"""

class UnionFind():
    def __init__(self, N):
        # 親の番号を格納する。親だった場合は、-(その集合のサイズ)
        # 初期状態は-1で、すべてバラバラの状態
        self.parent = [-1] * N

    def root(self, A):
        # Aがどのグループに属しているか調べる（親の番号を返す）
        if self.parent[A] < 0:
            return A
        self.parent[A] = self.root(self.parent[A])
        return self.parent[A]

    def size(self, A):
        """ 自分のいるグループの頂点数を調べる """
        return -self.parent[self.root(A)]  # 親を取ってきたい
    
    def connect(self, A, B):
        """ AとBをくっつける
        AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける 
        """
        A = self.root(A)
        B = self.root(B)
        if A == B:
            # 既にくっついてるからくっつけない
            return False
        
        # 大きいほう（A）に小さいほう（B）をくっつけたい
        # 大小が逆だったらひっくり返しちゃう
        if self.size(A) < self.size(B):
            A, B = B, A
        
        # Aのサイズを更新する
        self.parent[A] += self.parent[B]
        # Bの親をAに変更する
        self.parent[B] = A

        return True


def solve():
    N, M = list(map(int, input().split(" ")))
    A = []
    B = []

    for i in range(M):
        a, b = list(map(int, input().split()))
        A.append(a-1)
        B.append(b-1)
    
    ans = [0]*M
    ans[M-1] = N*(N-1)/2  # すべて崩落した状態の不便さ
    ufind = UnionFind(N)

    for i in range(M-1, 0, -1):
        if ufind.root(A[i]) != ufind.root(B[i]):
            # 繋がっていなかったのがつながった時
            ans[i-1] = ans[i] - ufind.size(A[i]) * ufind.size(B[i])
            ufind.connect(A[i], B[i])
        else:
            ans[i-1] = ans[i]
    
    for i in range(0, M):
        print(int(ans[i]))



if __name__ == "__main__":
    solve()

Measured memory_bytes: 16252
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] strArray = sc.next().split("");
        String[] akibaArray = "AKIHABARA".split("");
        boolean flag = true;
        int count = 0;
        int i = 0;

        for (; i < akibaArray.length; i++) {
            if (count >= strArray.length) {
                break;
            }
            if (strArray[count].equals(akibaArray[i])) {
                count++;
            } else if (!akibaArray[i].equals("A")) {
                break;
            }
        }

        if (i <= akibaArray.length - 2 || count < strArray.length) {
            flag = false;
        }

        System.out.println(flag ? "YES" : "NO");
    }
}

Measured memory_bytes: 23252
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int s = sc.nextInt();
        int w = sc.nextInt();
        if( s <= w){
            System.out.println("unsafe");
        }else{
            System.out.println("safe");
        }

    }

    private static 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: 32472
n = int(input())
P = list(map(int, input().split()))
for i in range(n):
    for j in range(n):
        P_copy = P.copy()
        P_copy[j], P_copy[i] = P_copy[i], P_copy[j]
        ascending = True
        for k in range(n-1):
            if P_copy[k] > P_copy[k+1]:
                ascending = False
        if ascending:
            print('YES')
            exit()
print('NO')


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n],b[n+1];
    forn(i,n-1) cin>>b[i];
    a[n-1]=b[n-2];
    for(i=n-2;i>0;i--) a[i]=min(b[i],b[i-1]);
    a[0]=b[0];
    forn(i,n) ans+=a[i];
    cout<<ans el;

}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int K; cin >> K;
    int A, B; cin >> A >> B;
    repp(i,A,B+1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i=0; i<n; i++) cin >> v[i];
    for(int i=0; i<n; i++) cin >> c[i];
    int ans = 0;
    for(int i=0; i<n; i++) ans += max(0, v[i] - c[i]);
    cout << ans << endl;
    return 0;
}

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

priority_queue<double,vector<double>,greater<double> >pq;

double v[100];
int n;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i];pq.push(v[i]);
	}
	for(int i=1;i<n;i++)
	{
		double x1=pq.top();pq.pop();double x2=pq.top();pq.pop();
		pq.push((x1+x2)/2.0);
	}
	cout<<fixed<<setprecision(10);
	cout<<pq.top();
	
	return 0;
}

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

int main(void){

    int N;

    scanf("%d", &N);

    int A[N];
    int d = 0;

    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    d = abs(A[0]) + abs(A[N-1]);

    for(int i = 1; i < N; i++){
        d += abs(A[i] - A[i-1]);
    }

    if((0 <= A[0] && A[0] <= A[1]) || (A[1] <= A[0] && A[0] <= 0)){
        printf("%d\n", d);
    }else{
        printf("%d\n", d - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]));
    }

    for(int i = 1; i < N-1; i++){
        if((A[i-1] <= A[i] && A[i] <= A[i+1]) || (A[i+1] <= A[i] && A[i] <= A[i-1])){
            printf("%d\n", d);
        }else{
            printf("%d\n", d - abs(A[i]-A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]));
        }
    }

    if((0 <= A[N-1] && A[N-1] <= A[N-2]) || (A[N-2] <= A[N-1] && A[N-1] <= 0)){
        printf("%d\n", d);
    }else{
        printf("%d\n", d - abs(A[N-1]) - abs(A[N-1] - A[N-2]) + abs(A[N-2]));
    }

    return 0;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=100005;
const int logn=18;

int n,q,l,sec,st[maxn],ed[maxn];
int up[maxn][logn];
vector<int>G[maxn];

void dfs(int u,int p) {
	st[u]=sec++;
	up[u][0]=p;
	for (int i=1;i<=l;i++)
		up[u][i]=up[up[u][i-1]][i-1];
	for (int v:G[u])
		if (v!=p) dfs(v,u);
	ed[u]=sec;
}

bool upper(int u,int v) {
	return st[u]<st[v] && ed[u]>=ed[v];
}

int lca(int u,int v) {
	if (u==v) return u;
	if (upper(u,v)) return u;
	if (upper(v,u)) return v;
	for (int i=l;i>=0;i--) 
		if (!upper(up[u][i],v))
			u=up[u][i];
	return up[u][0];
}

int main() {
	cin>>n;
	for (int i=0;i<n;i++) {
		int m; cin>>m;
		for (int j=0;j<m;j++) {
			int v; cin>>v;
			G[i].pb(v);
		}
	}
	while ((1<<l)<=n) l++;
	dfs(0,0);
	cin>>q;
	for (int i=0;i<q;i++) {
		int u,v; cin>>u>>v;
		cout<<lca(u,v)<<'\n';
	}
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a; string s; cin>>a>>s;
	cout<<(a>=3200?s:"red")<<"\n";
	return 0;
}

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

using namespace std;

int main()
{
    int m,d;
    scanf("%d%d",&m,&d);
    int res=0;
    for(int o=1;o<=m;o++)
    {
        for(int i=1;i<=d;i++)
        {
            int ones=i%10;
            int tens=i/10;
            if(ones>=2&&tens>=2&&ones*tens==o) res++;
        }
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
import math
EPS = 10**-7


class P2():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.norm2 = (self.x**2 + self.y**2)**0.5

    def __add__(self, other):
        return P2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return P2(self.x - other.x, self.y - other.y)

    def __mul__(self, other: float):
        return P2(self.x * other, self.y * other)

    def __truediv__(self, other: float):
        return P2(self.x / other, self.y / other)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def det(self, other):
        return self.x * other.y - self.y * other.x


n, k = map(int, input().split())
p = []
c = []
for _ in range(n):
    x, y, cc = map(float, input().split())
    p.append(P2(x, y))
    c.append(cc)

dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]


def check(r):
    r_c = tuple(r / c[i] for i in range(n))
    # 半径rの円２つの交点の列挙
    cand = [pi for pi in p]
    for i in range(n - 1):
        for j in range(i + 1, n):
            d_ij = p[i] - p[j]

            if dist[i][j] < r_c[i] + r_c[j] - EPS:
                # 点iと点jを中心とする円が交点を持つ時
                x = ((r_c[j])**2 -
                     (r_c[i])**2 + d_ij.norm2**2) / (2 * d_ij.norm2)
                h = math.sqrt(max((r_c[j])**2 - x**2, 0.0))
                v = P2(-d_ij.y, d_ij.x) * (h / d_ij.norm2)
                dx = p[j] + d_ij * (x / d_ij.norm2)
                cand.append(dx + v)
                cand.append(dx - v)

    for cand_p in cand:
        cnt = 0
        for i in range(n):
            if (p[i] - cand_p).norm2 < r_c[i] + EPS:
                cnt += 1
                if cnt >= k:
                    return True

    return False


lb = 0.0  # False
ub = 3000 * 100  # True
while ub - lb > EPS:
    mid = (ub + lb) / 2
    if check(mid):
        ub = mid
    else:
        lb = mid

print(ub)


Measured memory_bytes: 81624
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin >> n;
  vl p(n), o(n);
  rep(i, n) {
    cin >> p[i];
    o[i] = p[i];
  }
  sort(ALL(p));
  ll diff = 0;
  rep(i, n) {
    if (o[i] != p[i]) diff++;
  }
  if (diff <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b;
  cin >> a;
  fin(a < 1200 ? "ABC" : "ARC")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) 

solver (a11:a12:a13:a21:a22:a23:a31:a32:a33:n:bs) = 
  if elem a11 bs && elem a12 bs && elem a13 bs 
  || elem a21 bs && elem a22 bs && elem a23 bs
  || elem a31 bs && elem a32 bs && elem a33 bs
  || elem a11 bs && elem a21 bs && elem a31 bs
  || elem a12 bs && elem a22 bs && elem a32 bs
  || elem a13 bs && elem a23 bs && elem a33 bs
  || elem a11 bs && elem a22 bs && elem a33 bs
  || elem a13 bs && elem a22 bs && elem a31 bs
  then "Yes"
  else "No"




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

int n, k;
int a[200005];

bool test(int m) {
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        cnt += a[i] / m + (a[i] % m > 0) - 1;
    }
    return cnt <= k;
}

void solve()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int l = 1, r = 1000000000;
    while (r > l) {
        int m = (l + r) / 2;
        if (test(m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    cout << r << endl;
}

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

    /* int T; */
    /* cin >> T; */
    /* for (int t = 0; t < T; ++t) { */
        solve();
    /* } */
    return 0;
}


Measured memory_bytes: 4428
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  char b;
  cin>>b;
  switch(b){
  case 'A':
    cout<<'T';
    break;
  case 'T':
    cout<<'A';
    break;
  case 'G':
    cout<<'C';
    break;
  case'C':
    cout<<'G';
    break;
  }
  
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	int m=s.size()/2;
	int co=m;
	rep(i,s.size()-m){
		if(s[m-i-(s.size()%2==0?1:0)]==s[m]&&s[m]==s[m+i])co++;
		else break;
	}
	cout<<co<<endl;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define space ' '
typedef long long ll;
typedef long double ld;
const long double PI = 3.14159265358979323846;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll minCost = 1e9;
    for (int i = -100; i <= 100; ++i) {
        ll cost = 0;
        for (int j = 0; j < n; ++j) {
            if (a[j] != i) {
                ll tmp = a[j] - i;
                cost += (tmp * tmp);
            }
        }
        minCost = min(minCost, cost);
    }
    cout << minCost << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
	int i,n;
	double sum = 0;
	double ave,a,point[1000];
	
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%lf",&point[i]);
			sum += point[i];
		}
		ave = sum/n;
		sum = 0;
		for(i=0;i<n;i++){
			sum += (point[i]-ave)*(point[i]-ave);
		}
		sum = sum / n;
		a = sqrt(sum);
		printf("%lf\n",a);
		sum = 0;
	}
	return 0;
}

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

int main(){
    int t,x;
    cin >> t >> x;
    printf("%.3f\n",(double)t/x); 
    return 0;
}


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

using namespace std;

int main()
{
    string S,T,U;
    int A,B;
    cin>>S>>T;
    cin>>A>>B;
    cin>>U;
    
  if(S.length()>=1&&S.length()<=10&&T.length()>=1&&T.length()<=10&&S!=T&&(U==T||U==S)&&A<=10&&A>=1&&B<=10&&B>=1){
    if(U==S){
        A--;
    }
    if(U==T){
        B--;
    }
    cout<<A<<" "<<B;
}
   return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k; cin >> n >> k;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i = 0; i < k; i++)
    {
        ans += l[n-i-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

W = [input() for i in range(N)]

ans = 'Yes'

if len(W) > len(set(W)):
    ans = 'No'
else:
    W = [list(i) for i in W]
    for i in range(len(W)-1):
        if W[i][-1] != W[i+1][0]:
            ans = 'No'
            break
    
print(ans)

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

	typedef long long ll;
	using namespace std;

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

		vector <ll> f;
		ll c = 0;
		f.push_back(0);
		for(int i=1; i< s.size(); i++){
			if(s[i-1] == 'A' && s[i] == 'C'){
				c++;
			}
			f.push_back(c);
		}
		// for(int i =0; i < s.size(); i++){
		// 	cout << f[i];
		// }

//ACACTACG
//01122233
		while(q--){
			ll l,r;
			cin >> l >> r;
			cout << f[r-1]-f[l-1] << endl;
		}

		return 0;
	}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  string s,t;
  cin>>s>>t;
  int a=s.size(),b=t.size();
  vvi dp(a+1,vi(b+1,0));
  REP(i,1,a+1)REP(j,1,b+1){
    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
    if(s[i-1]==t[j-1]) chmax(dp[i][j],dp[i-1][j-1]+1);
  }
  //out(dp[a][b]);
  string ans="";
  int i=a,j=b;
  while(i>0&&j>0){
    if(dp[i][j]==dp[i][j-1]) j--;
    else if(dp[i][j]==dp[i-1][j]) i--;
    else{
      ans=s[i-1]+ans;
      i--; j--;
    }
  }
  out(ans);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 74060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	vector<int> c(n);
	rep(i, n) cin >> c[i];
	int ans = 0;
	rep(i, n) {
		if (v[i] > c[i]) ans += v[i] - c[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#ここまでテンプレ
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)
n,m = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
mi = 0
ma = 10**10
for i in li:
    mi = max(mi,i[0])
    ma = min(ma,i[1])
if mi > ma:
    print(0)
else:
    print(ma-mi+1)

Measured memory_bytes: 27332
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)
#define myforInv(i,N) for(i=N;i>=0;i--)
#define myforFLInv(i,f,l) for(i=f;i>l;i--)
#define ifMeetBoundaryCondition(x,xMax,xMin,y,yMax,yMin) if(x < xMax && x >= xMin &&y < yMax && y >= yMin)
#define INF pow(10,9)
using namespace std;

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

int main(){
	int H,W,N,i,j,y,x,sh=0,sw=0,black_cell_count =0,ans;
	cin >> H >> W;
	vector<string> s(H);
	myfor(i,H){
		cin >> s[i];
	}
	myfor(i,H)myfor(j,W){
		if(s[i][j] == '#')black_cell_count++;
	}

	queue<pair<int, int> >q;
	q.push(pair<int,int>(sh,sw));
	vector<vector<bool> >done(H,vector<bool>(W,false));
	vector<vector<int> >count(H,vector<int>(W,INF));
	count[sh][sw] = 1;
	while(!q.empty()){
		y = q.front().first;
		x = q.front().second;
		q.pop();
		if(done[y][x])continue;
		done[y][x] = true;
		
		myfor(i,4){
			ifMeetBoundaryCondition(x+dx[i],W,0,y+dy[i],H,0){
				if(s[y+dy[i]][x+dx[i]] != '#' && !done[y+dy[i]][x+dx[i]]){
					q.push(pair<int,int>(y+dy[i],x+dx[i]));
					count[y+dy[i]][x+dx[i]] = count[y][x] + 1;
				}
			}
		}
	}
	ans = H*W - count[H-1][W-1] - black_cell_count;
	if(ans < 0)ans = -1; 
	cout << ans  << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,a,p,ct;
    cin>>n>>k;;
    ct=0;
    long long arr[n+2]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(arr[a]==0){ct++;}
        arr[a]++;
    }
    p=0;
    if(ct>k){sort(arr,arr+n+1);
    for(int i=1;i<=n;i++)
        {
            if(arr[i]>0)
            {
                p+=arr[i];
                --ct;
                if(ct==k) break;
            }
        }
    }
    cout<<p<<endl;;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

typedef	pair<int,int> P;

bool passed[101][101];
int cnt;
P mt[101][101];
int n;
set<int> s;
bool ok=false;

void dfs(int x,int y){
	if(passed[y][x])
		return;
	if(s.find(y*n+x)!=s.end()){
		ok=true;
		return;
	}
	s.insert(y*n+x);
	passed[y][x]=true;
	dfs(mt[y][x].second,mt[y][x].first);
}

int main(){

	while(cin>>n&&n!=0){
		cnt=0;
		s.clear();
		ok=false;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				P to;
				cin>>to.second>>to.first;
				mt[i][j]=to;
			}
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(s.find(i*n+j)!=s.end()){
					continue;
				}
				else{
					for(int k= 0; k < 101; k++)
						fill(passed[k],passed[k]+101,false);
					cnt++;
					ok=false;
					dfs(j,i);
					if(ok==true)
						cnt--;
				}
			}
		}
		cout<<cnt<<endl;
	}


	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const ll mod = 1000000007;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    map<char, ll> mp;
    rep(i, n) mp[s[i]]++;
    ll ans = mp['R'] * mp['G'] * mp['B'];
    rep(i, n) {
        for(int j = i + 1; j < n; j++) {
            int k = 2 * j - i;
            if (k >= n)break;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans <<endl;
    return;
}

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


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

int main(){
  
  int n, d, x, a[100], ans = 0;
  
  cin >> n >> d >> x;
  for(int i = 0;i < n;i++) cin >> a[i];
  
  for(int i = 0;i < n;i++){
    for(int j = 0;j * a[i] + 1 <= d;j++){
      ans++;
    }
  }
  ans += x;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin >> a>>b;

  	if(a<b){
		cout << "0" << endl;
    }else{
		cout << a-b << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(register ll i=(a);i<(b);i++)
typedef long long ll;
inline ll read(){ll sign=1; ll x=0; char ch; while(!isdigit(ch=getchar())) if(ch=='-') sign=-1; while(isdigit(ch)) x=x*10+ch-'0',ch=getchar(); return x*sign;}
inline void write(ll k){ if(k<0) putchar('-'),k*=-1; char ch[20]; int num=0; while(k)ch[++num]=k%10,k/=10; if(num==0) ch[++num]=0; while(num)putchar(ch[num--]+'0');}
int n,k,x,y,ans;
int main() {
	n=read(); k=read(); x=read(); y=read();
	ans=x*min(k,n);
	ans+=y*max(0,n-k);
	write(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int euclid(long long int a,long long int b){
      /* 自然数 a > b を確認・入替 */
  if(a<b){
    long long int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  long long int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
    return b;
}

int main(void){
    int N;
    scanf("%d",&N);
    long long int a[N];
    long long int ans=1;
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
        if(ans%a[i]!=0)ans*=a[i]/euclid(ans,a[i]);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int i=0;

int main(void)
{
    int A,B,C,K,s=0,t[100000];
    scanf("%d\t%d\n%d\n%d",&A,&B,&C,&K);
    while(K>0&&A>0)
    {
        s++;
        A--;
        K--;
    }
    while(K>0&&B>0)
    {
        K--;
        B--;
    }
    while(K>0&&C>0)
    {
        s--;
        K--;
        C--;
    }
    printf("%d",s);
    
    return 0;
    
}

Measured memory_bytes: 1732
#include<iostream>

using namespace std;

int main(){
	int a,b,c,d;
	d=0;
	cin>>a>>b>>c;
	for(int x=a;x<=b;x++){
		if(c==c/x*x){
			d=++d;
		}
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    // 入力
    int N;cin >> N;
    vector<string> S(N);
    rep(i,N)cin >> S[i];

    // 頭文字の人数カウント
    vector<LL> ct(5);
    rep(i,N){string X = S[i];if(X[0] == 'M')ct[0]++;}
    rep(i,N){string X = S[i];if(X[0] == 'A')ct[1]++;}
    rep(i,N){string X = S[i];if(X[0] == 'R')ct[2]++;}
    rep(i,N){string X = S[i];if(X[0] == 'C')ct[3]++;}
    rep(i,N){string X = S[i];if(X[0] == 'H')ct[4]++;}

    // 答えの取得
    LL ans;
    rep(i,3) for(LL j = i+1;j < 4;j++) for(LL k = j+1;k < 5;k++) ans+= ct[i]*ct[j]*ct[k];

    // 出力
    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),days=s.nextInt();

		HashMap<Integer,ArrayList<Integer>> m=new HashMap<>();

		PriorityQueue<Integer> tasks=new PriorityQueue<>(Comparator.reverseOrder());

		for(int i=0;i<n;++i){
			int time=s.nextInt(),pay=s.nextInt();
			m.computeIfAbsent(time,o->new ArrayList<>()).add(pay);
		}


		long r=0;

		for(int i=1;i<=days;++i){
			ArrayList<Integer> l=m.get(i);
			if(l!=null)
				l.forEach(tasks::add);

			Integer task=tasks.poll();

			if(task!=null)
				r+=task;
		}

		System.out.println(r);
	}
}


Measured memory_bytes: 107776