akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
 
int compare(const void *a, const void *b){
  return (*(int *)a)- (*(int *)b);
}
 
int main(){
  int a,b,m,sum,tmp,tmpa=100001,tmpb=100001;
  scanf("%d%d%d",&a,&b,&m);
  int A[a],B[b];
  int str[m+1];
  for(int i=0;i<a;i++){
    scanf("%d",&A[i]);
    if(A[i]<tmpa){
      tmpa=A[i];
    }
  }
  for(int i=0;i<b;i++){
    scanf("%d",&B[i]);
    if(B[i]<tmpb){
      tmpb=B[i];
    }
  }
  int x[m],y[m],C[m];
  for(int i=0;i<m;i++){
    scanf("%d%d%d",&x[i],&y[i],&C[i]);
  }
  
  for(int i=0;i<m;i++){
    sum = A[x[i]-1]+B[y[i]-1]-C[i];  
    str[i]=sum;
  }
  
  str[m]=tmpa+tmpb;
  
  qsort(str,m+1,sizeof(int),compare);
 
  printf("%d",str[0]);
  
  return 0;
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a,b;
    cin >> a >> b;
    if(a <= 5)cout << 0 << endl;
    else if(a <= 12)cout << b/2 << endl;
    else cout << b << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) (x).begin (), (x).end ()
#define sz(x) (int) (x).size ()
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit);

typedef long long ll;

typedef pair <int, int> pii;
#define f first
#define s second
#define mp(x) make_pair (x)

typedef vector <int> vi;
#define pb(x) push_back (x)

#define DEBUG 0
#define ddcout if (DEBUG) cout
#define ddprintf(fmt, ...) if (DEBUG) printf (fmt, ##__VA_ARGS__)

#define EXIT ddprintf ("\nT.E. %lf\n", 1.0 * clock () / CLOCKS_PER_SEC); exit (0)

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x3f3f3f3f3f3f3f3f;
const int  INFi  =  0x3f3f3f3f;
const ll   MAXN  =  1e+6+7;

int main ()
{
    FASTIO;
    int i, j;
    string S;
    cin >> S;
    if (S == "SUN") printf ("7\n");
    else if (S == "MON") printf ("6\n");
    else if (S == "TUE") printf ("5\n");
    else if (S == "WED") printf ("4\n");
    else if (S == "THU") printf ("3\n");
    else if (S == "FRI") printf ("2\n");
    else if (S == "SAT") printf ("1\n");

    EXIT;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,c;
int main()
{
	cin>>a;
	int b=a;
	while (b)
	{
		c+=b%10;
		b/=10;
	}
	if (a%c==0) printf("Yes");
	    else printf("No");
	return 0;
}

Measured memory_bytes: 256
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divUp(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	ll A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	if (A1 + A2 + A3 >= 22)
		cout << "bust";
	else
		cout << "win";
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(input())
tmp=[a[0]]
last = a[0][-1]
for word in a[1:]:
    if last != word[0] or word in tmp:
        print("No")
        exit()
    last = word[-1]
    tmp.append(word)
print("Yes")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	double arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		arr[i] = (arr[i] + 1) / 2.0;
	}


	double sums[n + 1] = { 0 };
	for (int i = 1; i <= n; i++)
		sums[i] = sums[i - 1] + arr[i - 1];

	double ans = 0.0;

	for (int i = k; i <= n; i++) {
		ans = max(ans, sums[i] - sums[i - k]);
	}
	cout << setprecision(9) << ans << endl;
}


Measured memory_bytes: 6988
#include<iostream>
using namespace std;
int main()
{
    int n, abef, aaft, ans = 0, count = 1;
    cin >> n >> abef;
    for(int i = 1; i < n; i++){
        cin >> aaft;
        if(aaft == abef) count += 1;
        else if(count != 1){
            ans += count / 2;
            count = 1;
        }
        abef = aaft;
    }
    if(count != 1){
        ans += count / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
S = input()
T = input()
match_list = []
for i in range(len(S)-len(T)+1):
    is_match = True
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            is_match = False
            break
    if is_match:
        match_list.append(i)
if not match_list:
    print("UNRESTORABLE")
    sys.exit()
ans = S[:max(match_list)] + T
if len(S) > len(ans):
    ans += S[len(ans):]
print(ans.replace('?', 'a'))

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

// knapsack[i][j] : 
// 0 ~ i-1 番目の荷物から,総重量j以下となるように荷物を選ぶときの
// 価値の総和の最大値

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

// initialization
vector<vector<long long>> knapsack(110, vector<long long>(101010, 0));

int main(){
    int n, W;
    cin >> n >> W;
    
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
    
    // テーブルを更新する
    // 答えはknapsack[n][W]である
    for (int i = 0; i < n; i++){
        
        for (int j = 0; j <= W; j++){
            
            
            // not chosen
            chmax(knapsack[i+1][j], knapsack[i][j]);
            
            
            // chosen
            if (j - w[i] >= 0) chmax(knapsack[i+1][j], knapsack[i][j-w[i]] + v[i]);
        }
    }
    
    cout << knapsack[n][W] << endl;
    
}

Measured memory_bytes: 88192
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int s = scanner.nextInt();
		int w = scanner.nextInt();
		
		scanner.close();
		
		if (s <= w) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}

}


Measured memory_bytes: 27036
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int a[];
		int index;

		a = new int[1000];
		index = 0;
		while (true) {
			String st[] = sc.nextLine().split(",");
			if (st.length != 2) {
				break;
			}
			if (map.get(Integer.valueOf(st[0])) == null) {
				map.put(Integer.valueOf(st[0]), 1);
			} else {
				map.put(Integer.valueOf(st[0]), map.get(Integer.valueOf(st[0])) + 1);
			}
		}
		while (sc.hasNext()) {
			String st[] = sc.nextLine().split(",");
			if (map.get(Integer.valueOf(st[0])) != null) {
				map.put(Integer.valueOf(st[0]), map.get(Integer.valueOf(st[0])) + 1);
				boolean flag = true;
				for (int j = 0; j < index && flag; j++) {
					if (a[j] == Integer.valueOf(st[0])) {
						flag = false;
					}
				}
				if (flag) {
					a[index++] = Integer.valueOf(st[0]);
				}
			}
		}
		quickSort(a, 0, index - 1);
		for (int i = 0; i < index; i++) {
			System.out.println(a[i] + " " + map.get(a[i]));
		}
	}

	public static void quickSort(int a[], int low, int high) {
		if (high <= low) {
			return ;
		}
		int i = low;
		int j = high;
		int x = a[(low + high) / 2];
		while (i <= j) {
			while (a[i] < x) {
				i++;
			}
			while (x < a[j]) {
				j--;
			}
			if (i <= j) {
				int swap = a[i];
				a[i] = a[j];
				a[j] = swap;
				i++;
				j--;
			}
		}
		quickSort(a, low, j);
		quickSort(a, i, high);
	}
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, X, M;
  cin >> N >> X >> M;

  unordered_map<i64, i64> Am;
  vi A;
  A.reserve(M * 2);  
  A.pb(X);
  Am[X] = 0;
  
  i64 next = (A.back() * A.back()) % M;

  while(Am.find(next) == Am.end()) {
    Am[next] = A.size();
    A.pb(next);
    next = (A.back() * A.back()) % M;
  }

  i64 loop_begin = Am[next];
  i64 loop_end = A.size();
  i64 loop_len = loop_end - loop_begin;

  i64 N1 = min(N, loop_begin);
  i64 N2 = N - N1;
  
  i64 LC = N2 / loop_len;
  i64 LL = N2 % loop_len;

  i64 S1 = accumulate(A.begin(), A.begin() + N1, 0LL);
  
  i64 S2 = accumulate(A.begin() + loop_begin, A.end(), 0LL);
  i64 S3 = accumulate(A.begin() + loop_begin, A.begin() + loop_begin + LL, 0LL);

  cout << S1 + S2 * LC + S3 << endl;

  return 0;
}


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B);
  if (A % 3 && B % 3 && (A + B) % 3) {
    print("Impossible");
  } else {
    print("Possible");
  }
}


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

typedef pair<double, int>DI;

int N;
double X[1010], Y[1010], R[1010];
double path[1010][1010];
double cost[1010];

int main(){

    cin >> X[0] >> Y[0]; R[0] = 0;
    cin >> X[1] >> Y[1]; R[1] = 0;
    cin >> N;
    N+=2;
    for(int i=2; i<N; i++)cin >> X[i] >> Y[i] >> R[i];
    rep(i, N)rep(j, N){
        if(i==j){
            path[i][j] = 0;
            continue;
        }
        double len = hypot(X[i]-X[j],Y[i]-Y[j]);
        path[i][j] = len - R[i] - R[j];
        if(path[i][j] < 0)path[i][j] = 0;
    }
    rep(i, N)cost[i] = -1;
    priority_queue<DI, vector<DI>, greater<DI> >Q;
    Q.push(DI(0, 0));
    while(cost[1] < 0){
        double cst = Q.top().first;
        int id = Q.top().second;
        Q.pop();
        if(!(cost[id]<0))continue;
        cost[id] = cst;
        rep(i, N){
            if(!(cost[i]<0))continue;
            Q.push(DI(cst+path[id][i],i));
        }
    }
    printf("%.12f\n", cost[1]);

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    ll ans = 0;
    if(x <= 6) ans = 1;
    else if(x <= 11) ans = 2;
    else {
        ans = (x / 11 * 2);
        if(x % 11 != 0) {
            if(x % 11 <= 6) ans += 1;
            else ans += 2;
        } 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, t = map(int, input().split())
dish = [list(map(int, input().split())) for _ in range(n)]
dish.sort(key=lambda x: x[0])
dp = [[0 for _ in range(3005)] for _ in range(3005)]

ans = 0
for i in range(n):
    for j in range(t):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
        nj = j + dish[i][0]
        if nj < t:
            dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + dish[i][1])
    now = dp[i][t- 1] + dish[i][1]
    ans = max(ans, now)

print(ans)

Measured memory_bytes: 125784
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextInt()

    val map = mutableMapOf<Int, Int>()

    (1..n).forEach { map.computeIfAbsent(it) { 0 } }
    (2..n).forEach { map.computeIfPresent(sc.nextInt()) { k, v -> v+1 } }

    map.values.forEach(::println)
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

multiset<string> s;

int main() {
	reg x = read(), y = read(), z = read();
	fo(i, 1, x) s.insert("a");
	fo(i, 1, y) s.insert("b");
	fo(i, 1, z) s.insert("c");
	while((int)s.size() > 1) {
		string u = (*s.begin()) + (*s.rbegin());
		s.erase(s.begin()), s.erase(--s.end());
		s.insert(u);
	} cout << *s.begin();
	return 0;
}



Measured memory_bytes: 256
n1,n2,n3 = map(int,input().split(" "))

list1 = [list(map(int,input().split(" "))) for _ in range(n1)]
list2 = [list(map(int,input().split(" "))) for _ in range(n2)]

mat = [[0 for _ in range(n3)] for _ in range(n1)]
for i in range(n1):
	for j in range(n3):
		for k in range(n2):
			mat[i][j] += list1[i][k] * list2[k][j]

for m in mat:
	print(*m)



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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, Q;
int S[220000], T[220000], X[220000], D[220000];
vector<pair<pint, int>> events;
signed main() {
    cin >> N >> Q;
    rep(i, N) {
        cin >> S[i] >> T[i] >> X[i];
        events.push_back({{S[i] - X[i], 0}, i});
        events.push_back({{T[i] - X[i], 1}, i});
    }
    rep(i, Q) {
        cin >> D[i];
        events.push_back({{D[i], 2}, i});
    }
    sort(all(events));
    vint ans(Q);

    multiset<int> ms;
    rep(i, events.size()) {
        int type = events[i].first.second, idx = events[i].second;
        if (type == 0) {
            ms.insert(X[idx]);
        } else if (type == 1) {
            ms.erase(ms.find(X[idx]));
        } else if (type == 2) {
            if (ms.empty()) { ans[idx] = -1; }
            else { ans[idx] = *ms.begin(); }
        }
    }
    rep(i, Q) { cout << ans[i] << endl; }
}


Measured memory_bytes: 33252
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    H = Number(input.split("\n")[0].split(" ")[0]);
    W = Number(input.split("\n")[0].split(" ")[1]);
    S = new Array;
    S2= new Array;
    answer="";
    for(i=0;i<H;i++){
        S[i]= input.split("\n")[i+1].split("");
        S2[i]= input.split("\n")[i+1].split("");
    }

    function isBomb(a,b){
        if(a < 0 || b < 0|| a >= H || b >= W) return false;
        if(S[a][b]=="#"){
            return true;
        }else{
            return false;
        }
    }

    function mining(a,b){
        //特定のマスの周囲8マスに"#"があることをチェックする関数
        cnt=0;
        if(S[a][b]=="#"){
            return "#";
        }else{
            if(isBomb(a-1,b-1)) cnt++;
            if(isBomb(a-1,b)) cnt++;
            if(isBomb(a-1,b+1)) cnt++;
            if(isBomb(a,b-1)) cnt++;
            if(isBomb(a,b+1)) cnt++;
            if(isBomb(a+1,b-1)) cnt++;
            if(isBomb(a+1,b)) cnt++;
            if(isBomb(a+1,b+1)) cnt++;

            return cnt;
        }
    }
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
        S2[i][j]=mining(i,j);
        answer += S2[i][j];
        }
        answer += "\n";
    }

    console.log(answer);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7772
#include <iostream>     // std::cout
#include <algorithm>    // std::sort
#include <vector>       // std::vector

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> lis;
    int answer = 0;
    while(n--){
        int p;
        cin >> p;
        lis.push_back(p);
        sort(lis.begin(), lis.end());
    }
    for(int i=0; i<k; i++){
        answer += lis[i];
    }
    cout << answer;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;


int main(){
    ll n,cnt=0,sum=0;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
      cin >> a[i];
      if(a[i]<0)    cnt++;
      sum+=abs(a[i]);
    }
    for(ll i=0;i<n;i++){
        a[i] = abs(a[i]);
    }
    sort(a.begin(),a.end());
    if(cnt%2==0)    cout << sum;
    else    cout << sum-(2*a[0]);
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    vector<int> c(n);
    int prev[200010];
    rep(i,200010)prev[i] = -1;
    rep(i,n)cin >> c[i];
    // rep(i,n){
    //     int in;
    //     cin >> in;
    //     if(i == 0 || c[i-1] != in)c.push_back(in);
    // }
    //debug_vec(c);
    int m = c.size();
    int cnt[200100] = {0};
    cnt[0] = 1;
    int d[200010] = {0};
    rep(i,n){
        d[i] = prev[c[i]];
        prev[c[i]] = i;
    }

    for(int i = 1;i < n;i++){
        cnt[i] = cnt[i-1];
        if(d[i] != -1 && d[i] != i-1)cnt[i] += cnt[d[i]];
        cnt[i] %= MOD;
    }
    cout << cnt[n-1]%MOD << endl;
    // rep(i,m)cerr << cnt[i] << " ";
    // cerr << endl;
    // rep(i,m)cerr << d[i] << " ";
    // cerr << endl;




    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://agc031.contest.atcoder.jp/tasks/agc031_a
// rm -r -f test;oj dl http://abc107.contest.atcoder.jp/tasks/abc107_b

Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;

set<string> st;

int main(void){
  int m;
  string train;
  cin >> m;
  for(int i = 0; i < m; i++){
    cin >> train;

    st.clear();
    for(int j = 1; j <= train.size(); j++){
      int a = j;
      string c1o, c2o, c1u, c2u;

      for(int i = 0; i < a; i++) c1u += train[i];
      c1o = c1u;
      reverse(c1u.begin(), c1u.end());
      for(int i = a; i < train.size(); i++) c2u += train[i];
      c2o = c2u;
      reverse(c2u.begin(), c2u.end());

      st.insert(c1o + c2o);
      st.insert(c1o + c2u);
      st.insert(c1u + c2o);
      st.insert(c1u + c2u);
      st.insert(c2o + c1o);
      st.insert(c2o + c1u);
      st.insert(c2u + c1o);
      st.insert(c2u + c1u);
    }

    cout << st.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long int ll;
int gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd(b, a % b);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }
    vector<int> dpl(n + 5);
    vector<int> dpr(n + 5);
    int tmp = a[0];
    rep(i, n - 1)
    {
        dpl[i] = gcd(tmp, a[i]);
        tmp = dpl[i];
    }
    tmp = a[n - 1];
    for (int i = n - 1; i >= 0; i--)
    {
        dpr[i] = gcd(tmp, a[i]);
        tmp = dpr[i];
    }
    int ans = max(dpr[1], dpl[n - 2]);
    for (int i = 1; i < n - 1; i++)
    {
        ans = max(ans, gcd(dpl[i - 1], dpr[i + 1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		String a=in.next();
		char b[]=a.toCharArray();
		if(b[0]==b[1] && b[1]==b[2])
		{
			System.out.println("Yes");
		}
		else if(b[1]==b[2] && b[2]==b[3])
		{
			System.out.println("Yes");
		}
		else System.out.println("No");
		
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	int HW[10000][2], i = 0, j, l, k;
	while (1){
		cin >> HW[i][0] >> HW[i][1];
		if (HW[i][0] == 0 && HW[i][1] == 0)break;
		i++;
	}
	for (j = 0; j < i; j++){
		for (l = 0; l < HW[j][0]; l++){
			for (k = 0; k < HW[j][1]; k++){
				if ((l == 0 || l == HW[j][0] - 1) || (k == 0 || k == HW[j][1] - 1))	printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1124
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void){
    char W[11];//char E[30];
    string T="0";
    int i=0; int n=0;int r=0;int j=0;
    cin >> W;
   // cout << int(W[1])<<endl; 
    while(1){
        cin >> T;
        if(T=="END_OF_TEXT")break;
       
while(T[j]!=0){
   
//    E[j]=T[j];
    j=j+1;
   // if(E[j]=="0")break;
    
}
//printf("%d",j);
       
        while(n<strlen(W)){
            if(T[n]==W[n]||T[n]==W[n]-32){
            r=r+1;
            }
            n=n+1;  //printf("%c ",T[n]);  printf("%c\n",W[n]);
            
            }
    if(r>=strlen(W)&&r==j){
        i=i+1;
    }   
    n=0;r=0;  j=0;
        
    }
      
    printf("%d\n",i);
    

}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
const ll inf = 1e10 + 2 ;
const int nmax = 1e5 + 1 ;
void solve(){
    int n , m ;
    cin >> n >> m ;
    if(n<=9 && m<=9){
        cout << n*m ;
    }
    else{
        cout << -1 ;
    }

}
int main(){
//      #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
    int t = 1  ;
    //cin >> t ;
    while(t--)
        solve();
}
// logc (ai*aj) = k logc (x)
// logc ( ai*aj - x ) =  k  

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, u, v;
vector<int> Graph[101010];
bool vis_u[101010], vis_v[101010];
int d_u[101010], d_v[101010];
bool cond(int x){
    REP(i, 101010){
        vis_u[i] = vis_v[i] = false;
        d_u[i] = d_v[i] = HINF<int>();
    }
    d_u[u] = d_v[v] = 0;
    queue<int> q;
    q.push(u);
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto to : Graph[p]){
            if(d_u[to] !=HINF<int>())continue;
            d_u[to] = d_u[p] + 1;
            q.push(to);
        }
    }
    q.push(v);
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(auto to : Graph[p]){
            if(d_v[to] !=HINF<int>())continue;
            d_v[to] = d_v[p] + 1;
            q.push(to);
        }
    }
    REP(i, n){
        if(d_u[i] <= x && d_v[i] > x)return true;
    }
    return false;
}

int main(){
    cin >> n >> u >> v;
    u--, v--;
    REP(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        Graph[a].emplace_back(b);
        Graph[b].emplace_back(a);
    }
    int l = 0, r = n;
    while(r - l > 1){
        int mid = (l + r)/2;
        if(cond(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << l << endl;
}

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

const int N = (int) 2e6 + 5 ;
const int M = 55555 ;
const int inf = (int) 2e9 ;

int primes[M + 10] , P[M + 10] , tot = 0 ;

void sieve() {
    for( int i = 1 ; i <= M ; i++ ) P[i] = 1 ;
    for( int i = 2 ; i <= M ; i++ ) {
        if( P[i] == 1 ) {
            for( int j = i + i ; j <= M ; j += i ) {
                P[j] = 0 ;
            }
        }
    }
    primes[ ++tot ] = 2 ;
    for( int i = 3 ; i <= M ; i += 2 ) {
        if( P[i] == 1 ) primes[++tot] = i ;
    }
}

int n ;

void solve() {
    scanf("%d" , &n ) ;
    for( int i = 1 ; i <= tot ; i++ ) {
        if( n == 0 ) break ;
        if( primes[i] % 5 == 1 ) {
            printf("%d " , primes[i] ) ;
            n -= 1 ;
        }
    }
    printf("\n") ;
}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    sieve() ;
    solve() ;
    return 0 ;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  int a,z;
  for(int i=0;i<n;i++){
    if(s.at(i)=='A'){a=i;break;}
  }
  for(int i=n-1;i>=0;i--){
    if(s.at(i)=='Z'){z=i;break;}
  }
  int ans=z-a+1;
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>

#define MAX 100005
#define NIL -1

typedef struct{
  int p, l, r;
}Node;

Node g_node[MAX];
int g_n, g_m[MAX];

void print(int);
void rec(int, int);

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&g_n);

  for(i = 0; i < g_n; i++){
    g_node[i].p = g_node[i].l = g_node[i].r = NIL;
  }

  for(i = 0; i < g_n; i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if(j == 0) g_node[v].l = c;
      else g_node[l].r = c;
      l = c;
      g_node[c].p = v;
    }
  }
  for(i = 0; i < g_n; i++){
    if(g_node[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0; i < g_n; i++) print(i);

  return 0;
}

void print(int u){
  int i, c;

  printf("node %d: ",u);
  printf("parent = %d, ", g_node[u].p);
  printf("depth = %d, ",g_m[u]);

  if(g_node[u].p == NIL) printf("root, ");
  else if(g_node[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  c = g_node[u].l;
  for(i = 0; c != NIL; i++, c = g_node[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void rec(int u, int p){
  g_m[u] = p;
  if(g_node[u].r != NIL) rec(g_node[u].r, p);
  if(g_node[u].l != NIL) rec(g_node[u].l, p + 1);
}



Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	double a,b,c; cin >> a >> b >> c;
	cout << a*b/2 << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import kotlin.math.min

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    for (c in 1..jin.readLine().toInt()) {
        val n = jin.readLine().toInt()
        val masks = jin.readLine().split(" ").map { it.toLong() }
        val turns = jin.readLine()
        val reduced = mutableListOf<Long>()
        var answer = 0
        for (j in n - 1 downTo 0) {
            var mask = masks[j]
            for (v in reduced) {
                mask = min(mask, mask xor v)
            }
            if (mask != 0L) {
                if (turns[j] == '0') {
                    reduced.add(mask)
                } else if (turns[j] == '1') {
                    answer = 1
                    break
                }
            }
        }
        println(answer)
    }
}

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

int main() {
    ll A, V; cin >> A >> V;
    ll B, W; cin >> B >> W;
    ll T; cin >> T;
    if (V <= W) {
        cout << "NO" << endl;
    } else {
        if (abs(A - B) <= (V - W) * T) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

int main(void){
    int N;
    cin >> N;
    
    for(int i = 0 ; i < N ; i++){
        int tmp;
        cin >> tmp;
        
        if(tmp % 2 == 0){
            if(tmp % 3 == 0 || tmp % 5 == 0) continue;
            
            cout << "DENIED" << endl;
            return 0;
        }
    }
    
    cout << "APPROVED" << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    if(a[0]!=0){
        cout<<-1<<endl;
    }
    else{
        rep(i,n-1){
            if(a[i+1]-a[i]>1){
                cout<<-1<<endl;
                return 0;
            }
        }
        ll ans=0;
        for(int i=1;i<n;++i){
            if(a[i]-a[i-1]==1)ans++;
            else{
                ans+=a[i];
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1792
#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 <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

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

    int n;
    cin>>n;
    VI a(n);
    REP(i,n)cin>>a[i];
    LL ans = 0;
    REP(i,n)ans += a[i] - 1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int sumOfSum = 0;
		for (int i = 0; i <= n; i++) {
			String s = String.valueOf(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				sum += Character.getNumericValue(s.charAt(j));
			}

			if (a <= sum && sum <= b) {
				sumOfSum += i;
			}
		}
		System.out.println(sumOfSum);

		scanner.close();
	}
}

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

int read_line(char* out, size_t limit) {
	char* lf;
	if (fgets(out, limit, stdin) == NULL) return 0;
	if ((lf = strchr(out, '\n')) != NULL) *lf = '\0';
	return 1;
}

int main(void) {
	char str[1024];
	char command[4096];
	int q, query_count;
	if (!read_line(str, sizeof(str))) return 1;
	if (!read_line(command, sizeof(command)) || sscanf(command, "%d", &q) != 1) return 1;
	for (query_count = 0; query_count < q; query_count++) {
		int a, b;
		char *command_kind, *p;
		int i;
		if (!read_line(command, sizeof(command))) return 1;
		if ((command_kind = strtok(command, " ")) == NULL) return 1;
		if ((p = strtok(NULL, " ")) == NULL || sscanf(p, "%d", &a) != 1) return 1;
		if ((p = strtok(NULL, " ")) == NULL || sscanf(p, "%d", &b) != 1) return 1;
		if (strcmp(command_kind, "replace") == 0) {
			/* there doesn't seem a grantee that p consists of lowercase letters */
			if ((p = strtok(NULL, "")) == NULL) return 1;
			if (b < a || (size_t)(b - a + 1) != strlen(p)) return 1;
			memcpy(&str[a], p, b - a + 1);
		} else if (strcmp(command_kind, "reverse") == 0) {
			for (i = 0; a + i < b - i; i++) {
				char temp = str[a + i];
				str[a + i] = str[b - i];
				str[b - i] = temp;
			}
		} else if (strcmp(command_kind, "print") == 0) {
			for (i = a; i <= b; i++) putchar((unsigned char)str[i]);
			putchar('\n');
		} else return 1;
	}
	return 0;
}


Measured memory_bytes: 2100
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
ll dp[200009],c[200009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	vi v;
	int lst = -1;
	rep(i,n){
		int x;cin>>x;
		if(x!=lst) v.pb(x);
		lst = x;
	}
	dp[0] = 1;
	const ll mod = 1e9+7;
	repA(i,1,sz(v)){
		dp[i] = dp[i-1];
		dp[i]+=c[v[i-1]];
		dp[i]%=mod;
		c[v[i-1]]+=dp[i-1];
		c[v[i]-1]%=mod;
	}
	cout<<dp[sz(v)];
	
	
	return 0;
}



Measured memory_bytes: 4340
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c);	
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

template <typename T>
auto make_vector (T && x, size_t n)
{
  return vector <T> (n, forward <T> (x));
}

template <typename T, typename ... Us>
auto make_vector (T && x, size_t n, Us ... ns)
{
  auto elem = make_vector (forward <T> (x), ns ...);
  using Elem = decay_t <decltype (elem)>;
  return vector <Elem> (n, elem);
}

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

  size_t h, w;
  cin >> h >> w;

  auto a = make_vector (ll{}, h, w);
  auto b = make_vector (ll{}, h, w);
  rep (y, h) rep (x, w) cin >> a[y][x];
  rep (y, h) rep (x, w) cin >> b[y][x];

  auto ab = make_vector (ll{}, h, w);
  rep (y, h) rep (x, w)
  {
    ab [y][x] = a [y][x] - b [y][x];
  }

  constexpr size_t katayori_max = 80 * (80 + 80);
  auto dp = make_vector (0, h, w, katayori_max * 2);

  dp [0][0][katayori_max + ab[0][0]] = 1;
  dp [0][0][katayori_max - ab[0][0]] = 1;

  rep (y, h) rep (x, w) rep (c, katayori_max * 2)
  {
    if (dp [y][x][c])
    {
#ifdef LOCAL
      cout << "(" << x << ", " << y << ") = " << ll(c) - ll(katayori_max) << endl;
#endif
      if (x + 1 < w)
      {
        dp[y][x + 1][c + ab[y][x + 1]] = true;
        dp[y][x + 1][c - ab[y][x + 1]] = true;
      }
      if (y + 1 < h)
      {
        dp[y + 1][x][c + ab[y + 1][x]] = true;
        dp[y + 1][x][c - ab[y + 1][x]] = true;
      }
    }
  }

  ll ans = katayori_max * 2;
  rep (c, katayori_max * 2)
  {
    if (dp [h - 1][w - 1][c] == 1)
    {
      auto t = abs (static_cast <ll> (c) - static_cast <ll> (katayori_max));
#ifdef LOCAL
      cout << "t=" << t << endl;
#endif
      ans = min (ans, t);
    }
  }
  cout << ans << endl;
}


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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[4];
	for(int i=3;i>=0;i--)
	{
		a[i]=n%10;
		n=n/10;
	} 
	if(a[0]+a[1]+a[2]+a[3]==7)printf("%d+%d+%d+%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]+a[1]+a[2]-a[3]==7)printf("%d+%d+%d-%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]+a[1]-a[2]+a[3]==7)printf("%d+%d-%d+%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]-a[1]+a[2]+a[3]==7)printf("%d-%d+%d+%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]+a[1]-a[2]-a[3]==7)printf("%d+%d-%d-%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]-a[1]+a[2]-a[3]==7)printf("%d-%d+%d-%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]-a[1]-a[2]+a[3]==7)printf("%d-%d-%d+%d=7",a[0],a[1],a[2],a[3]);
	else if(a[0]-a[1]-a[2]-a[3]==7)printf("%d-%d-%d-%d=7",a[0],a[1],a[2],a[3]);
	return 0;
} 

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

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

    int a;
    set<int> tmp;
    for(int i = 0;i < n;i++){
        cin >> a;
        tmp.insert(a);
    }

    cout << tmp.size() << endl;
    return 0;
}




Measured memory_bytes: 256
void main(){
	string s = readln().chomp();
	if( s[2] == s[3] && s[4] == s[5])writeln("Yes");
	else writeln("No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2648