akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
    int x;cin >> x;
    Sieve sieve(1e6);
    for(int i=x;;i++){
        if(sieve.isPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {
            ll n;
            cin>>n;
            vi  a(n),b(n),c(n);
            fo(i,n)
                cin>>a[i];
            fo(i,n)
                cin>>b[i];
                fo(i,n)
                cin>>c[i];
        sort(a.begin(),a.end());
        sort(c.begin(),c.end());
        ll ans=0;
        fo(i,n)
        {
            ll x=b[i];
            auto it=lower_bound(a.begin(),a.end(),x);
            ll fst=it-a.begin();
            it=upper_bound(c.begin(),c.end(),x);
            ll sec=c.end()-it;
            ans+=(fst*sec);

        }
        cout<<ans;
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not






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

const int NIL = -1;

void reconstruct(vector<int>& preorder, vector<int>& inorder, int l, int r, int& pre, vector<int>& postorder)
{
    if (r - l <= 0) {
        return;
    }
    int m = distance(inorder.begin(), find(inorder.begin(), inorder.end(), preorder[pre++]));
    reconstruct(preorder, inorder, l, m, pre, postorder);
    reconstruct(preorder, inorder, m + 1, r, pre, postorder);
    postorder.push_back(inorder[m]);
}

int main()
{
    int n;
    cin >> n;
    vector<int> preorder(n);
    vector<int> inorder(n);
    for (int i = 0; i < n; i++) {
        cin >> preorder[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> inorder[i];
    }
    vector<int> postorder;
    int pre = 0;
    reconstruct(preorder, inorder, 0, inorder.size(), pre, postorder);

    for (int i = 0; i < postorder.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << postorder[i];
    }
    cout << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define psi std::pair<string,int>
#define pli std::pair<ll,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%I64d",&x)
#define prll(x) printf("%I64d ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vli std::vector<std::list<int>>
#define vlpi vector<list<pii>>
#define li std::list<int>
#define Endl printf("\n")
#define ma 1000000
#define mod 786433
#define FOR(i,a) for(int i=0; i<a; i++)
#define FORL(i,a) for(ll i=0 ;i<a ; i++)
#define MAXN 1000
#define paire(a,b)  make_pair(a,b)

using namespace std;




int main()
{
    int n ; cin >> n ;
    cout << pow(n,3) ;
}


Measured memory_bytes: 384
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    int sum = 0;
    FOR(i,0,SZ(s)-1) sum = (sum * 10 + s[i] - '0') % 9;
    cout << (sum == 0 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    map<string,int> cnt;
    vector<string> v;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        cnt[s]++;
        v.push_back(s);
    }
    vector<string> rev = v;
    for(string &s : rev)    reverse(s.begin(),s.end());

    sort(v.begin(), v.end());
    sort(rev.begin(), rev.end());

    auto f = [](string s, vector<string> &v)->int{
        vector<string>::iterator l = lower_bound(v.begin(),v.end(),s);
        s.back() = s.back()+1;
        vector<string>::iterator r = lower_bound(v.begin(),v.end(),s);
        return r-l;
    };

    for(int i = 0; i < m; i++){
        string s;
        cin >> s;
        int flag = 0;
        if(s[0]=='*')           flag = 2, s = s.substr(1), reverse(s.begin(),s.end());
        else if(s.back()=='*')  flag = 1, s = s.substr(0,s.length()-1);
        int ind = -1;
        for(int j = 0; j < s.length(); j++) if(s[j] == '?') ind = j;
        int ans = 0;
        if(flag == 0){
            if(ind == -1)   ans = cnt[s];
            else            for(char c = 'a'; c <= 'z'; c++)    s[ind]=c, ans += cnt[s];
        }else if(flag == 1){
            if(ind == -1)   ans = f(s, v);
            else            for(char c = 'a'; c <= 'z'; c++)    s[ind]=c, ans += f(s, v);
        }else if(flag == 2){
            if(ind == -1)   ans = f(s, rev);
            else            for(char c = 'a'; c <= 'z'; c++)    s[ind]=c, ans += f(s, rev);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 82612
s = input()
 
ans = 'YES'
 
while len(s) > 0:
    if s.endswith('dreamer'):
        s = s[:-7]
    elif s.endswith('dream'):
        s = s[:-5]
    elif s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('erase'):
        s = s[:-5]
    else:
        ans = 'NO'
        break
 
print(ans)

Measured memory_bytes: 3188
// https://atcoder.jp/contests/abc101/tasks/abc101_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  string s;
  int r = 0;

  cin >> s;

  for (size_t i = 0; i < 4; i++)
  {
    r += s[i] == '+' ? 1 : -1;
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int m,d;
	int d10, d1;
	int count = 0;

	scanf("%d %d", &m, &d);

	for(int i = 1;i <= m;i++){
		for(int j = 1;j <= d;j++){
			if(j >= 10){
				d10 = j / 10;
				d1 = j - d10 * 10;
				if(d1 >= 2 && d10 >= 2){
					if(i == d10 * d1){
						count++;
					}
				}

			}

		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int a,b,x;
  
  cin >> x >> a >> b;
  
  cout << (x-a) % b << endl;


 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <utility>
#include <queue>
#define INF 1000000007

using namespace std;
typedef long long int ll;

int main(){
    vector<int> dp(31,0);
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for (int i=3; i<31; i++) {
        dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
    }
    for (;;) {
        int n;
        cin >> n;
        if(n==0) break;
        int ans = dp[n]/(10*365)+1;
        cout << ans <<endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    REP(i, b) {
        if (a * (i+1) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl; 
}

Measured memory_bytes: 256
# Atcoder problem Solving

# Code Festival Team Relay
import math

N, K = map(int, input().split())
que = [tuple(map(int, input().split())) for _ in range(N)]


def count(X):
    cnt = 0
    for i in range(N):
        w, d = que[i]
        if X >= w:
            cnt+=(X-w)//d+1
    return cnt


# case_impossible
l = -1

# case_possible

r = 10**19

while r-l > 1:
    m = (l+r)//2
    if count(m) < K:
        l = m
    else:
        r = m

print(r)

Measured memory_bytes: 60760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String todayWeather = scanner.next();
        System.out.println(todayWeather.equals("Sunny") ? "Cloudy" : todayWeather.equals("Cloudy") ? "Rainy" : "Sunny");
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

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


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

int main(void) 
{
    int n;
    cin >> n;
    vector<char> s(n);
    rep(i,n) cin >> s[i];

    ll ans = 0;
    if(n <= 3) {
        cout << 0 << endl;
        return 0;
    }

    ll R = 0;
    ll G = 0;
    ll B = 0;

    rep(i,n){
       if(s[i] == 'R') R++;
       else if(s[i] == 'G') G++;
       else B++;
    }
    ans = R * G * B;
    if(ans <= 0) {
        cout << 0 << endl;
        return 0;
    }

    rep(i,n -2){
        for(int j = i + 1; j < n -1 ; ++j){
            if(s[i] == s[j]) continue;
            int k = j - i + j;
            if(k >= n) break;
            if(s[j] != s[k] && s[k] != s[i])
            {
                ans--;
                //printf("i:%d j:%d k:%d\n",i,j,k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#define N 250 

int main(){
  int arr[N+1],n,data,i,node=1;

  scanf("%d",&n);
  if(n>N) exit(2);
  for(i=1;i<=n;i++){
    scanf("%d",&arr[i]);
  }
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,arr[i]);
    if(i!=1)printf("parent key = %d, ",arr[i/2]);
    if(i*2 <= n)printf("left key = %d, ",arr[2*i]);
    if(i*2+1 <= n)printf("right key = %d, ",arr[2*i+1]);
    printf("\n");
  }
  return 0;
}



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

int main() {
  char c;
  cin >> c;

  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }

return 0;  
}

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

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

  string text;
  int cnt = 0;
  for (;;) {
    cin >> text;
    
    if (text == "END_OF_TEXT") break;
    
    for (int i = 0; i < text.size(); i++) {
      text[i] = tolower(text[i]);
    }

    if (text == w) cnt++;
    
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3168
import sys
import math
sys.setrecursionlimit(10**9)

n = int(input())
a = list(map(int, input().split()))
ma = max(a)
p = [0]*(ma + 1)

for i in a:
  p[i] += 1

pairwise = True
for i in range(2, ma+1):
  cnt = 0
  for j in range(i, ma+1, i):
    cnt += p[j]
  if cnt > 1:
    pairwise = False
    break
    
if pairwise:
  print("pairwise coprime")
else:
  temp = a[0]
  for i in a:
    temp = math.gcd(temp, i)
  if temp == 1:
    print("setwise coprime")
  else:
    print("not coprime")

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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

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

struct hoge {
  vector<mint> fact, ifact;
  hoge(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }

  mint nCk(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }

  mint nPk(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[n - k];
  }
};

const int N = 1100000;

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

  hoge h(N);
  mint ans = 0;
  rep(k, n + 1) {
    mint a = h.nCk(n, k);
    mint b = h.nPk(m, k);
    mint c = h.nPk(m - k, n - k);
    mint tmp = a * b * c * c;
    if (k % 2 == 0)
      ans += tmp;
    else
      ans -= tmp;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20400
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::string;


int main()
{
  int N, M, C;
  cin >> N >> M >> C;
  std::vector<long long> B(M);
  std::vector<std::vector<long long>> A(N);
  for (int i = 0; i < M; ++i)
  {
    cin >> B[i];
  }

  for (int i = 0; i < N; ++i)
  {
    A[i].resize(M);
    for (int j = 0; j < M;++j)
    {
      cin >> A[i][j];
    }
  }

  int count = 0;
  for (size_t i = 0; i < N;++i)
  {
    int num = C;
    for(size_t j = 0; j < M;++j)
    {
      num += A[i][j]* B[j];
    }

    if ( num > 0) { count++;}
  }

  cout << count << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int  n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		int maxCount = 0;
		int max =0;


		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			list.add(a);
			max = Math.max(max, a);
		}

		for (int i = 0; i < n; i++) {
			int a = list.get(i);
			if(a ==max){
				maxCount++;
			}
		}

		int secondMax = 0;
		if(maxCount == 1){
			for (int i = 0; i < n; i++) {
				int a = list.get(i);
				if(a == max){
					continue;
				}
				secondMax = Math.max(a, secondMax);
			}
		}

		for (int i = 0; i < n; i++) {
			int a = list.get(i);
			if(a == max && maxCount > 1){
				System.out.println(max);
			} else if(a == max && maxCount == 1){
				System.out.println(secondMax);
			} else{
				System.out.println(max);
			}
		}


	}

}


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

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

	int ans = 0;
	int count = 0;
	for (string::iterator it = S.begin(); it != S.end(); it++)
	{
		if (*it == 'A' || *it == 'C' || *it == 'G' || *it == 'T')
		{
			count++;
			ans = max(ans, count);
		}
		else
		{
			ans = max(ans, count);
			count = 0;
		}
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX_N 100001

using namespace std;

vector<bool> IsPrime(MAX_N, true);

// 愚直な素数列挙
void get_primes() {
    IsPrime[0] = false; IsPrime[1] = false;

    for (int i = 2; i < MAX_N; i++) {
        for (int j = 2; j*j <= i; j++) {
            if (i % j == 0) { IsPrime[i] = false; }
        }
    }
}

int main() {
    int Q, l, r;
    vector<int> cnt(MAX_N, 0);

    get_primes();

    for (int i = 3; i <= MAX_N; i += 2) {
        if (IsPrime[i] && IsPrime[(i+1)/2]) { cnt[i]++; }
    }
    // 2017 に似てる数の累積和をとっている
    for (int i = 1; i <= MAX_N; i++) {
        cnt[i] += cnt[i-1];
    }

    cin >> Q;

    while (Q--) {
        cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
public class Main {
  private static void solve() {
    String s = next();
    if (s.contains("9")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 21972
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0 0 2 0 1 1 1 -1
0 0 1 1 0 1 1 0
0 0 1 1 1 0 0 1

output:
1.0000000000 0.0000000000
0.5000000000 0.5000000000
0.5000000000 0.5000000000
"""

import sys
from collections import namedtuple


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def get_cross_point(s1, s2):
    base_vector = s2.target - s2.source
    d1 = abs(cross(base_vector, s1.source - s2.source))
    d2 = abs(cross(base_vector, s1.target - s2.source))
    t = d1 / (d1 + d2)
    cross_point = s1.source + (s1.target - s1.source) * t
    print('{real:.10f} {imag:.10f}'.format(real=cross_point.real, imag=cross_point.imag))

    return None


def solve(_segments):
    for segment in _segments:
        segment = tuple(map(int, segment))
        p0, p1, p2, p3 = (x + y * 1j for x, y in zip(segment[::2], segment[1::2]))
        s1, s2 = Segment(p0, p1), Segment(p2, p3)
        get_cross_point(s1, s2)

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    l_num = int(_input[0])
    segments = map(lambda x: x.split(), _input[1:])
    Segment = namedtuple('Segment', ('source', 'target'))
    solve(segments)

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

struct node {
	int s, a, b;
	node(int a = 0, int b = 0) : a(a), b(b) {
		s = a + b;
	}
	bool operator < (const node& rhs) const { return s < rhs.s; }
} a[100050];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int val = k * 2 + 2 * n - 1;
	int m = n / 2;
	for(int i = 0; i < m; i++) a[i] = node(k + i, k + n + i + n - m);
	for(int i = m; i < n; i++) a[i] = node(k + i, k + n + i - m);
	sort(a, a + n);
	bool ans = true;
	for(int i = 0; i < n; i++)
		if(a[i].s > k + 2 * n + i) ans = false;
	if(!ans) {
		puts("-1"); return 0;
	}
	for(int i = 0; i < n; i++) printf("%d %d %d\n", a[i].a, a[i].b, k + 2 * n + i);
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	if(str[0] == 'a'||str[0] == 'e'||str[0] == 'i'||str[0] == 'o'||str[0] == 'u')cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,m,s,i,j;
int main()
{
	cin>>n>>m>>s;
	if(s==1000000000){
		fz1(i,m){
			printf("%d ",s);
		}
		fz1(i,n-m){
			printf("%d ",1);
		}
	}
	else{
		fz1(i,m){
			printf("%d ",s);
		}
		fz1(i,n-m){
			printf("%d ",1000000000);
		}
	} 
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int n,x,c;
    for (;;) {
        cin >> n >> x;
        c = 0;
        if (!n && !x) break;
        for (int i=1; i<=n; i++){
            for (int j=i+1; j<=n; j++){
                for (int k=j+1; k<=n; k++){
                    if (i+j+k == x) c += 1;
                }
            }
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>

int main()
{
  int a, b, c, k;
  scanf("%d %d %d %d", &a, &b, &c, &k);
  
  // k <= a + b + c
  // k - (a + b) <= c
  int minC = 0;
  if (a + b < k) {
    minC = k - (a + b);
  }
  
  int maxA = a;
  if (a > k) {
    maxA = k;
  }
  
  printf("%d\n", maxA - minC);
  
  return 0;
}

Measured memory_bytes: 1704
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int D, N;
  cin >> D >> N;
  int div = pow(100, D);

  if (N == 100){
    cout << div*N + div << endl;
  } else {
    cout << div*N << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>

using namespace std;

map<pair<int,string>,int> mp;
int wans=0;
int acans =0;

int main(){
    int t;
    string s;
    int n ,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> t >> s;
        //cout << s << endl;
        if(mp[pair<int,string>(t,"AC")] != 0 ) continue;
        else mp[pair<int,string>(t,s)]++;
    }
    for(int i=1;i<=n;i++){
        if(mp[pair<int,string>(i,"AC")] == 1){
            wans += mp[pair<int,string>(i,"WA")];
            acans += mp[pair<int,string>(i,"AC")];    
        }
        
    }
    cout << acans << " " << wans << endl;

    return 0;
}

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

mt19937 mt(2007111352);
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r - 1);
	return p(mt);
}
double randouble() {
	uniform_real_distribution<double> p(0.0, 1.0);
	return p(mt);
}
long long calc(int N, vector<int> X, vector<int> Y, vector<int> P, vector<int> xrail, vector<int> yrail) {
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		int mindist = (1 << 30);
		for (int j : xrail) {
			mindist = min(mindist, abs(X[i] - j));
		}
		for (int j : yrail) {
			mindist = min(mindist, abs(Y[i] - j));
		}
		ans += 1LL * mindist * P[i];
	}
	return ans;
}

int main(){
    int N;
	cin >> N;
	vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i] >> P[i];
	}
	vector<int> xinc, yinc;
	for (int i = 0; i < N; ++i) {
		if (X[i] != 0) xinc.push_back(X[i]);
		if (Y[i] != 0) yinc.push_back(Y[i]);
	}
	sort(xinc.begin(), xinc.end()); xinc.erase(unique(xinc.begin(), xinc.end()), xinc.end());
	sort(yinc.begin(), yinc.end()); yinc.erase(unique(yinc.begin(), yinc.end()), yinc.end());
	int candx = xinc.size();
	int candy = yinc.size();
	vector<long long> ans(N + 1);
	int limit = min(candx, candy);
	vector<bool> flag(candx + candy, false);
	function<long long()> get_score = [&]() {
		vector<int> xrail = { 0 }, yrail = { 0 };
		for (int i = 0; i < candx + candy; ++i) {
			if (flag[i]) {
				if (i < candx) xrail.push_back(xinc[i]);
				else yrail.push_back(yinc[i - candx]);
			}
		}
		return calc(N, X, Y, P, xrail, yrail);
	};
	ans[0] = get_score();
	for (int i = 1; i < limit; ++i) {
		int u = -1;
		do {
			u = rand_rng(0, candx + candy);
		} while (flag[u]);
		flag[u] = true;
		// --- hill climbing! --- //
		long long current_score = get_score();
		long long best_score = current_score;
		int repeat = 100000;
		for (int j = 1; j <= repeat; ++j) {
			int u1 = -1, u2 = -1;
			do {
				u1 = rand_rng(0, candx + candy);
				u2 = rand_rng(0, candx + candy);
			} while (!flag[u1] || flag[u2]);
			flag[u1] = false; // true -> false
			flag[u2] = true; // false -> true
			double temperature = double(max(repeat - (j % (repeat / 4)) * 5, 1)) / repeat * ans[i - 1] * 2.0;
			long long new_score = get_score();
			if (randouble() < exp((current_score - new_score) / temperature)) {
				if (best_score > new_score) {
					cerr << "Repeat #" << j << ": Score " << best_score << " -> " << new_score << endl;
					best_score = new_score;
				}
				current_score = new_score;
			}
			else {
				// revert
				flag[u1] = true;
				flag[u2] = false;
			}
		}
		ans[i] = best_score;
	}
	for (int i = 0; i <= N; ++i) {
		cout << ans[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <stack>

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

    for (int i = 0; i < n; ++i) {
        int a[10];
        for (int j = 0; j < 10; ++j) std::cin >> a[j];

        std::stack<int> s1, s2;
        for (int j = 0; j < 10; ++j) {
            if (s1.empty()) s1.push(a[j]);
            else if (s1.top() < a[j]) s1.push(a[j]);
            else if (s2.empty()) s2.push(a[j]);
            else if (s2.top() < a[j]) s2.push(a[j]);
        }

        if (s1.size() + s2.size() == 10) std::cout << "YES" << std::endl;
        else std::cout << "NO" << std::endl;
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	ll S=0,D=0;
	rep(i,N){
		ll d,c; cin >> d>>c;
		S += d * c;
		D += c;
	}
	cout << (S-1)/9 + D-1 << endl;
}


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

using namespace std;

int main(void) {
	int num, m, i = 0, ans = 0;
	cin >> num >> m;
	vector<int> dis(m - 1), pos(m);
	for (; i < m; i++)
		scanf("%d", &pos[i]);
	sort(pos.begin(), pos.end());
	for (i = 0; i < m - 1; i++)
		dis[i] = pos[i + 1] - pos[i];
	sort(dis.begin(), dis.end());
	for (i = 0; i < m - num; i++)
		ans += dis[i];
	cout << ans << "\n";
	return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    vector<int> h( N );
    REP( i, N ) cin >> h[i];

    int t = 0;
    REP( i, N ){
        chmax( t, h[i] );
        if( t - h[i] >= 2 ){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#define ll long long
const int N=1e6+5,mo=1e9+7;
int n,i,s,f[N];
int main(){
	scanf("%d",&n);int v=(ll)(n-1)*(n-1)%mo;
	f[0]=1;f[1]=n;f[2]=(ll)n*n%mo;
	for (i=3;i<=n;i++) s=(s+f[i-3])%mo,
		f[i]=((ll)f[i-1]+s+v+(n-i+1))%mo;
	printf("%d",f[n]);
}

Measured memory_bytes: 4096
import numpy as np

S = input()
ss = set(S) 
mx = len(S)
for s in ss:
    m = [i for i, si in enumerate(S) if si == s ]
    m.insert(0, -1)
    m.append(len(S))
    mx = min(mx, max(np.diff(m)-1))

print(mx)

Measured memory_bytes: 12484
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <sstream>
#include <iostream>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using namespace std;
typedef long long ll;

struct V {
  ll a, b;
  V(ll a, ll b) : a(a), b(b) {}
  V() {}
};

V vs[100000+10];

struct P {
  ll v;
  int i;
  bool isA;
};
bool operator<(const P& p1, const P& p2) {
  if(p1.v != p2.v) return p1.v < p2.v;
  return p1.i < p2.i;
}

bool st[100000+10][2];

int main(void) {
  int n;
  scanf("%d", &n);
  vector<P> ps;
  REP(i, n) {
    scanf("%lld%lld", &vs[i].a, &vs[i].b);
    ps.push_back((P){vs[i].a, i, true});
    ps.push_back((P){vs[i].b, i, false});
  }
  sort(ps.begin(), ps.end());
  ll res = 0;
  REP(i, n) {
    P p = ps[i];
    res += ps[i].v;
    st[p.i][p.isA ? 0 : 1] = true;
  }
  int nA = 0;
  int nB = 0;
  REP(i, n) {
    if(st[i][0] && !st[i][1]) {
      ++nA;
    } else if(!st[i][0] && st[i][1]) {
      ++nB;
    }
  }

  // cerr << ">" << res << endl;
  if(nA == 0 || nB == 0 || nA + nB < n) {
    // do nothing
  } else {
    // 今使ってる中で一番でかいやつのindexを取る
    int idx = -1;
    int idx2 = -1;
    int maxi = -1;
    REP(i, n) {
      REP(j, 2) {
        if(st[i][j]) {
          int v = j==0 ? vs[i].a : vs[i].b;
          if(maxi < v) {
            maxi = v;
            idx = i;
            idx2 = j;
          }
        }
      }
    }
    // idxの箇所を捨てて他の使ってない最小を採用
    ll res1 = res;
    {
      res1 -= idx2==0 ? vs[idx].a : vs[idx].b;
      int mini = 2e9;
      REP(i, n) {
        if(i != idx) {
          REP(j, 2) {
            if(!st[i][j]) {
              int v = j==0 ? vs[i].a : vs[i].b;
              if(mini > v) {
                mini = v;
              }
            }
          }
        }
      }
      res1 += mini;
    }
    // cerr << ">> " << res1 << endl;
    // idxの箇所を両取りして他の箇所でmaxを捨てる
    ll res2 = res;
    {
      res2 += idx2==0 ? vs[idx].b : vs[idx].a;
      int maxi = -1;
      REP(i, n) {
        if(i != idx) {
          REP(j, 2) {
            if(st[i][j]) {
              int v = j==0 ? vs[i].a : vs[i].b;
              if(maxi < v) {
                maxi = v;
              }
            }
          }
        }
      }
      res2 -= maxi;
    }
    res = min(res1, res2);
    {
      // AまたはBに統一する
      ll sumA = 0;
      ll sumB = 0;
      REP(i, n) {
        sumA += vs[i].a;
        sumB += vs[i].b;
      }
      res = min(min(res, sumA), sumB);
    }
  }
  
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> red,green,colo;
int res;
 main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i =0; i<a; i++){
            int xx;
        cin>>xx;
        red.push_back(xx);
    }
     for(int i =0; i<b; i++){
            int xx;
        cin>>xx;
        green.push_back(xx);
    }
     for(int i =0; i<c; i++){
            int xx;
        cin>>xx;
        colo.push_back(xx);
    }
    sort(red.begin(),red.end());
    reverse(red.begin(),red.end());
    sort(green.begin(),green.end());
    reverse(green.begin(),green.end());
    int i =0;
    int first = colo.size() + x;
    while(colo.size() < first && i < red.size())colo.push_back(red[i++]);
    first = colo.size() + y;
    i = 0;
    while(colo.size() < first && i < green.size())colo.push_back(green[i++]);
    sort(colo.begin(),colo.end());
    reverse(colo.begin(),colo.end());

    int tot = x + y;

    for(int i =0; i<tot; i++)
    res+=colo[i];

    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 8048
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long c = 0;
		c = b / x - a / x;
		if(a % x == 0){
				c++;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main(){long k,t=1,m=-1;cin>>k;
           if(k%7==0)k/=7;
       for(long i=0;i<1000000;i++){t%=k;if(t==0){m=i+1;break;}
t*=10;t++;}
cout<<m<<endl;}

Measured memory_bytes: 3616
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
        int M = sc.nextInt();
        String s[] = new String[H];
        for(int i = 0; i < H; i++){
        	s[i] = sc.next();
        }
      
        int[][] hm = new int[H][M];
        for(int i = 0; i < H; i++){
          for(int j = 0; j < M ; j++){
            if(s[i].charAt(j) == '.'){
              hm[i][j] = 0;
            }else{
              hm[i][j] = -1;
            }
           
          }
        }
      
        for(int i = 0; i < H; i++){
        	for(int j = 0; j < M; j++){
            	if(hm[i][j] != -1){
                	if(i != 0 && j != 0 && hm[i-1][j-1] == -1){
                    	hm[i][j]++;
                    }
                    if(i != 0 && hm[i-1][j] == -1){
                    	hm[i][j]++;
                    
                    }
                    if(i != 0 && j != M-1 && hm[i-1][j+1] == -1){
                    	hm[i][j]++;
                    }
                  
                    if(j != 0 && hm[i][j-1] == -1){
                    	hm[i][j]++;
                    }
                    
                    if(j != M-1 && hm[i][j+1] == -1){
                    	hm[i][j]++;
                    }
                    
                    if(i != H-1 && j != 0 && hm[i+1][j-1] == -1){
                    	hm[i][j]++;
                    }
                    
                    if(i != H-1 && hm[i+1][j] == -1){
                    	hm[i][j]++;
                    }
                    
                    if(i != H-1 && j !=M-1 && hm[i+1][j+1] == -1){
                    	hm[i][j]++;
                    }
                }
            }
        }
        for(int i = 0; i < H; i++){
        	for(int j = 0; j < M; j++){
            	if(hm[i][j] == -1){
                	System.out.print("#");
                }else{
                	System.out.print(hm[i][j]);
                }
            }
            System.out.println();
        }
    }
} 

Measured memory_bytes: 36524
fun main(args: Array<String>) {
    abc062a()
}

fun abc062a() {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    val grouping = mapOf(
        1 to listOf(1, 3, 5, 7, 8, 10, 12),
        2 to listOf(4, 6, 9, 11), 3 to listOf(2)
    )

    val xGroup = grouping.entries.filter { it.value.contains(x) }.first().key
    val yGroup = grouping.entries.filter { it.value.contains(y) }.first().key

    if (xGroup == yGroup) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 36244
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y);
 
int main()
{
  int n;
  double p1[2], p2[2];
 
  p1[0] = 0;
  p1[1] = 0;
  p2[0] = 100;
  p2[1] = 0;
 
  scanf("%d", &n);
 
  printf("%f %f\n", p1[0], p1[1]);

  koch(n, p1[0], p1[1], p2[0], p2[1]);
 
  return 0;
}
 
void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y)
{
  double s[2], t[2], u[2];
  double r3 = sqrt(3.0);
 
  if (n == 0){
    printf("%f %f\n", p2_x, p2_y);
    return;
  }
 
  else {
    s[0] = p1_x + (p2_x - p1_x)/3.0;

    s[1] = p1_y + (p2_y - p1_y)/3.0;

    t[0] = p1_x + 2*(p2_x - p1_x)/3.0;

    t[1] = p1_y + 2*(p2_y - p1_y)/3.0;

    u[0] = s[0] + (-s[0] + r3*s[1] + t[0] - r3*t[1])/2.0;

    u[1] = s[1] + (-r3*s[0] - s[1] + r3*t[0] + t[1])/2.0;
     
    koch(n - 1, p1_x, p1_y, s[0], s[1]);

    koch(n - 1, s[0], s[1], u[0], u[1]);

    koch(n - 1, u[0], u[1], t[0], t[1]);

    koch(n - 1, t[0], t[1], p2_x, p2_y);
  }
}

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

int main() {
  int N;
  int i,l = 0;
  string S;
  cin >> N;
  
  while(i < N){
    cin >> S;
    if(S == "Y"){
        l = 1;
      }
    i++;
  }
  
  if(l == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" <<endl;
  }
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
#define md 1000000007
#define itc(n) char(n+48)
#define cti(ch) (ch-48)
#define pb push_back
template<class T>void ExEuclid(T n, T m, T &a, T &b, T &gcd){if(m==0){gcd=n;a=1;b=0;return;}ExEuclid(m,n%m,a,b,gcd);T x=a;a=b;b=x-(n/m)*a;}
template<class T>T gcd(T n, T m){if(m==0){return n;}gcd(m,n%m);}
template<class T>T lcm(T n, T m){return (n*m)/gcd(n,m);}
template<class T>string to_string(T n){ostringstream convert;convert<<n;return convert.str();}
template<class T>ll to_int(T s){ll num=0,power=0;for(int i=s.size()-1; i>=0; i--)num+=(pow(10.0,power++)*(s[i]-'0'));return num;}
template<class T>bool is_mod(T n, T m){if(n%m==0)return true;return false;}
template<class T>bool is_upper(T s){for(int i=0; i<s.size(); i++)if(s[i]>90 || s[i]<65)return false;return true;}
template<class T>bool is_lower(T s){for(int i=0; i<s.size(); i++)if(s[i]>122 || s[i]<97)return false;return true;}
template<class T>bool is_palindrome(T s){T s1=s;reverse(s1.begin(),s1.end());if(s==s1)return true;return false;}
template<class T>int digit_sum(T s){int sum=0; for(int i=0; i<s.size(); i++)sum+=cti(s[i]);return sum;}
template<class T>T mod(T n, T m){return ((n%m)+m)%m;}
template<class T>T Big_mod(T base, T power, T MOD){
    if(power==1)return base;
    if(power & 1)return ((base%MOD)*(Big_mod(base,power-1,MOD))%MOD)%MOD;
    else {T temp=(Big_mod(base,power>>1,MOD));return ((temp%MOD)*(temp%MOD))%MOD;}
}
template<class T>T doStringSum(T s1, T s2){int len1=s1.length(), len2=s2.length();
    if(len1<len2)return doStringSum(s2, s1);
    T ans="";int carry=0, i, s;
    for(i=1;i<=len1;i++){s = carry+cti(s1[len1-i]);if(i<=len2)s += cti(s2[len2-i]);
    ans = itc(s%10)+ans;carry = s/10;}if(carry!=0)ans = itc(carry)+ans;
    return ans;
}
template<class T>T dostringmultiply(T s1, T s2){int len1=s1.length(), len2=s2.length();
    if(len1<len2)return dostringmultiply(s2,s1);
    int i,j,p, carry=0;T result, net="", c;
    for(i=len2-1;i>=0;i--){carry=0;result="";c="";
    for(j=len1-1;j>=0;j--){p=cti(s1[j])*cti(s2[i]);result = itc((p+carry)%10)+result;carry=(p+carry)/10;}
    if(carry!=0){c=to_string(carry);result=c+result;}
    for(j=i;j<len2-1;j++)result+="0";net=doStringSum(net,result);}
    return net;
}
template<class T>T nCr(T n, T r)
    {if(r > n - r) r = n - r;T ans = 1;T i;
    for(i = 1; i <= r; i++){ans *=(n-r+i);ans%=md;ans /= i;}
    return ans%md;
}

int main()
{
    fast;
    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  
  sort(h.begin(), h.end());
  
  int ans = 1001001001;
  rep(i, n) {
    if(i + k-1 > n-1) break;
    ans = min(h[k-1+i] - h[i], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664