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

int main(){
  string str1, str2;
  cin >> str1 >> str2;
  for(int i=0; i<str1.size(); i++){
    string t1=str1.substr(1, str1.size()-1);
    char t2=str1[0];
    str1=t1+t2;
    if(str1==str2){
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vi32 ans;
  int now = n;
  while (now > 0) {
    bool f = false;
    rreps(i, m) {
      if (now - i < 0) continue;
      if (s[now - i] == '1') continue;
      f = true;
      ans.push_back(i);
      now -= i;
      break;
    }
    if (!f) {
      cout << -1 << endl;
      return;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}


Measured memory_bytes: 1096
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int c(int a,int b)
{
	return a>b;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int pp=0;
	sort(a+1,a+n+1,c);
	for(int i=1;i<=k;i++)
	{
		pp+=a[i];
	}
	cout<<pp<<endl;
	return 0;
}

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

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    vector<unsigned long long> a(n);
    map<long long, size_t> dict;
    for (unsigned long long i = 0; i < n; ++i) {
        cin >> a[i];
        if (dict.count(a[i] - 1) == 0) {
            dict[a[i] - 1] = 0;
        }
        if (dict.count(a[i]) == 0) {
            dict[a[i]] = 0;
        }
        if (dict.count(a[i] + 1) == 0) {
            dict[a[i] + 1] = 0;
        }
    }
    for (unsigned long long i = 0; i < n; ++i) {
        if (dict.count(a[i] - 1) != 0) {
            ++dict[a[i] - 1];
        }
        if (dict.count(a[i]) != 0) {
            ++dict[a[i]];
        }
        if (dict.count(a[i] + 1) != 0) {
            ++dict[a[i] + 1];
        }
    }
    size_t max_num = 0;
    for (const auto& item : dict) {
        if (item.second > max_num) max_num = item.second;
    }
    cout << max_num << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 6912
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

桁の数字の和 digit sum

----------------------------------------

「1 以上 j99999... (9がi個) 以下の整数のうち、桁の数字の和を D でわったあまりが r であるものの個数」を
xs[i][j][r] とする。

xs[0][j][r] = (j == r? 1: 0)

xs[i][0] = xs[i - 1][9] である

xs[i][j] は、xs[i][j - 1] に、「xs[i - 1][9] を j だけずらしたもの」を項ごとにたしたもの
具体的には
xs[i][j][r] = xs[i][j - 1][r] + xs[i - 1][9][(r + d - j) % d]


K = 47185, D = 50 の場合

・39999 以下 …… xs[4][3][0]
・46999 以下 …… xs[3][6][46]
・47099 以下 …… xs[2][0][39]
・47179 以下 …… xs[1][7][38]
・47184 以下 …… xs[0][4][30]
・47185

に分けて求める

----------------------------------------

*/

const mod = 1_000_000_007;

void main(){
	string kstr = readln.chomp;
	long d = read.to!long;
	
	long[][][] xs;
	xs ~= [[]];
	foreach(j; 0 .. 10){
		xs[0] ~= [[]];
		foreach(r; 0 .. d){
			if(j == 0){
				if(r == 0) xs[0][j] ~= 1;
				else xs[0][j] ~= 0;
			}
			else if(j % d == r) xs[0][j] ~= xs[0][j - 1][r] + 1;
			else xs[0][j] ~= xs[0][j - 1][r];
		}
	}
	
	foreach(i; 1 .. kstr.length + 1){
		xs ~= [[]];
		foreach(j; 0 .. 10){
			xs[i] ~= [[]];
			foreach(r; 0 .. d){
				debug writeln("i:", i, " j:", j, " r:", r, " xs:", xs);
				if(j == 0) xs[i][j] ~= xs[i - 1][9][r];
				else xs[i][j] ~= (xs[i][j - 1][r] + xs[i - 1][9][(r + d * j - j) % d]) % mod;
			}
		}
	}
	
	long ans;
	long offset = 0;
	foreach(iv, c; kstr){
		long i = kstr.length - 1 - iv;
		debug writeln("iv:", iv, " c:", c, " i:", i, " offset:", offset);
		if(c >= '1') ans += xs[i][c - '1'][offset], ans %= mod;
		offset += d - (c - '0'), offset %= d;
		debug writeln("ans:", ans);
	}
	if(offset == 0) ans += 1, ans %= mod;
	
	ans += mod - 1, ans %= mod; //「0」が含まれてしまうので
	
	ans.writeln;
}


Measured memory_bytes: 151676
#include <bits/stdc++.h>
#include <cstdio>
#include <chrono>
#include <random>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#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
#define PI 3.14159265
const long long int MAXN = 2e5+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e18+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;

int n,k,a[105],dp[MAXN];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    cin>>n>>k;
    repA(i,1,n) cin>>a[i];
    repA(i,0,k) repA(j,1,n) if(!dp[i]) dp[i+a[j]]=1;
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}



Measured memory_bytes: 1024
X = int(input())
def is_prime(n):
    if n <= 1:
        return False
    
    for i in range(2,int(n**0.5)+1):
        if n % i ==0:
            return False
    return True

for i in range(X,(X*2)+100,):
    if is_prime(i):
        print(i)
        break
            

Measured memory_bytes: 3060
#include<stdio.h>
int max(int a, int b){return a<b?b:a;}
char S[3001], T[3001], c;
short dp[3001][3001];
int s, t, i, j, k;
int main(void){
	while((c=getchar())!=10){S[s++]=c;}
	while((c=getchar())!=10){T[t++]=c;}
	for(i=s-1; i>=0; i--){
		for(j=t-1; j>=0; j--){
			dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
			if(S[i]==T[j]){dp[i][j] = max(dp[i][j], dp[i+1][j+1]+1);}
		}
	}
	i=0; j=0, k=dp[0][0];
	while(k){
		if(dp[i+1][j]==k){i++;}
		else if(dp[i][j+1]==k){j++;}
		else{putchar(S[i]); i++; j++; k--;}
	}
	putchar(10);
}


Measured memory_bytes: 17792
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        String end = "END_OF_TEXT";
        int ans = 0;
        
        
        while(sc.hasNext()) {
            String s = sc.next();
            if (s.equals(end)) {
                break;
            }
            s = s.toLowerCase();
            if (s.equals(w)) {
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 26228
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll a = N;
  ll ans = 0;
  while(a>0){
    ans += a%10;
    a/=10;
  }
  if(N%ans==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll K[10005];
ll dp[1005][5000];

int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        ll a, b;
        cin >> K[i].first >> b;
        K[i].second = 0;
        REP(j, b)
        {
            ll c;
            cin >> c;
            K[i].second |= (1LL << (c - 1));
        }
    }

    ll P = pow(2, N);
    REP(i, M + 1)
    {
        REP(j, P)
        {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    REP(i, M)
    {
        REP(j, P)
        {
            dp[i + 1][j] = std::min(dp[i][j], dp[i + 1][j]);
            ll s = j | K[i].second;
            dp[i + 1][s] = std::min(dp[i + 1][s], dp[i][j] + K[i].first);
        }
    }

    if (dp[M][P - 1] == INF)
        cout << -1 << endl;
    else
        cout << dp[M][P - 1] << endl;
    return 0;
}

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

int main() {
  int K, sum = 0;
  cin >> K;
  if (K % 2 == 0 || K % 5 == 0) {
    sum = -1;
  }
  else {
    K *= 9;
    if (K % 7 == 0) {
      K /= 7;
    }
    int s = 0, i = 10;
    while (s == 0) {
      sum++;
      i %= K;
      if (i == 1) {
        s = 1;
      }
      i *= 10;
    }
  }
  cout << sum << endl;
}

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

int main() {
    vector<int> x(5);
    for (int i = 0; i < 5; i++) cin >> x.at(i);

    for (int i = 0; i < 5; i++) {
        if (x.at(i) == 0) cout << i + 1 << endl;
    }
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A, B;
    cin >> A >> B;
    cout << A * B;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		sc.close();
		if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
			System.out.println(0);
		}else {
			System.out.println(Math.min(A * B, Math.min(B * C, C * A)));
		}
	}
}

Measured memory_bytes: 21972
K = int(input())
N = 50
a = [0] * 50

if K <= 50:
    for i in range(K):
        a[i] = 50
else:
    m = (K - 1) // 50
    base = 100 + m
    r = K % 50
    big = base - r
    small = big - 50 - r

    for i in range(r):
        a[i] = big
    for i in range(r, N, 1):
        a[i] = small

print(N)
print(" ".join(map(str, a)))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;

int main () {
    int n; cin >> n;
    char s[n], t[n];
    cin >> s >> t;
    char ans[n * 2];
    int a = 0, b = 0;
    for (int i = 0; i < 2 * n; i++) {
        if (i % 2 == 0) {
            ans[i] = s[a];
            a++;
        }
        else {
            ans[i] = t[b];
            b++;
        }
    }
    ans[n * 2] = '\0';
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, L int
	fmt.Scanf("%d", &N)
	var max, sum int

	// 3 8 4 1
	//
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &L)

		if L > max {
			sum += max
			max = L
		} else {
			sum += L
		}
	}

	if sum > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(void) {
    int n,m;
    long a;
    cin >> n;
    m = 1000;
    REP(i,n){
        cin >> a;
        REP(i,1000){
            if (a%2==0) {
                a/=2;
            } else {
                if (m > i) m = i;
            }
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
logs = list(map(int, input().split()))
maxL = max(logs)

def binsearch(minz, maxz):
    if minz >= maxz:
        return minz

    mid = (maxz + minz)//2
    ncut = 0
    for i in range(N):
        thiscut = int((logs[i] + mid - 1)/mid) - 1
        ncut += thiscut
        if ncut > K:
            return binsearch(mid+1, maxz)

    if ncut < K:
        return binsearch(minz, mid)
    #else ncut == K
    maxx = 0
    for i in range(N):
        thiscut = int((logs[i] + mid - 1)/mid) - 1
        thislen = int((logs[i] + thiscut)/(thiscut+1))
        if maxx < thislen: maxx = thislen
    return maxx

if K > 0:
    ans = binsearch(1, maxL+1)
else:
    ans = maxL
print(ans)


Measured memory_bytes: 30716
#include <iostream>
#include <time.h>
#include <string>
#include <iomanip>
#include <algorithm>
#include <map>


using namespace std;

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
  	if(s[i]=='1') s[i]='9';
  	else s[i]='1';
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define pi (acos(-1))
// https://atcoder.jp/contests/abc172/tasks/abc172_d
int main()
{
int n;
std::cin>>n;





if(n%1000==0){
        std::cout<<0<<std::endl; return 0;
}
ll ans =1000-(n%1000);
std::cout<<ans<<std::endl;




    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, x;
    cin >> k >> x;
    for (int i = x-k+1; i <= x + (k-1); ++i) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())

price = 0
ok = 0

for i in range(n+1):
    for j in range(n+1-i):
            k = n - i - j
            if k < 0:
                k = 0

            price = 10000 * i + 5000 * j + 1000 * k   
            
            if price == y and i+j+k == n and ok == 0:
                print(i, j, k)
                ok = 1
                break

    else:
        continue
    break

if ok == 0:
    print(-1, -1, -1 )

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        ll a;
        cin >> a;
        A[i] = a;
    }
    ll p_idx = 0;
    ll idx = 0;
    vector<ll> visited(N, false);
    vector<ll> dist(N, INF);
    dist[0] = 0;
    visited[0] = true;
    K --;
    while (true) {
        ll a = A[idx];
        if (K <= 0) {
            cout << a << '\n';
            return;
        }
        if (visited[a - 1]) {
            ll d = abs(dist[a - 1] - dist[idx]) + 1;
            ll remain = K;
            if (remain >= d) {
                remain %= d;
            }
            ll ans = a;
            idx = a - 1;
            rep(i, remain) {
                ll next = A[idx];
                ans = next;
                idx = next - 1;
            }
            cout << ans << '\n';
            return;
        } else {
            visited[a - 1] = true;
            dist[a - 1] = dist[idx] + 1;
            p_idx = idx;
            idx = a - 1;
            K--;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 7948
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    for (int k = a; k <= b; k++) {
        if (c % k == 0)
            count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) {
        cin >> h[i];
        if (i >= 1) {
            if (h[i] > h[i - 1]) --h[i];
            else if (h[i] < h[i - 1]) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


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

void solve(){

	string s ;
	cin>>s ;
	int n=s.length() ;

	rep(i,n){
		if(s[i]=='1'){
			s[i]='9' ;
		}
		else{
			s[i]='1' ;
		}
	}
	
	cout<<s ;
}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#include<unordered_map>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2000 + 47;

int U[MAX];
vector<int> g[MAX];
int n, k;
int cnt = 0;

void fill(int A[], int val)
{
	FOR(i, 0, MAX) A[i] = val;
}

void dfs(int v, int d)
{
	if (d > k / 2) return;
	//cout << "*" << v + 1 << ": " << d << endl;
	cnt++;
	U[v] = 1;

	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i];
		if (!U[to]) dfs(to, d + 1);
	}
}

int calc(int i)
{
	fill(U, 0);
	cnt = 0;
	dfs(i, 0);
	int ind = -1;

	return cnt;
}

int D[MAX];

void dfs1(int v, int p, int d)
{
	D[v] = d;
	FOR(i, 0, SZ(g[v]))
	{
		int to = g[v][i];
		if (U[to] && D[to] == -1) dfs1(to, v, d + 1);
	}
}

bool check(int v)
{
	fill(D, -1);
	dfs1(v, -1, 0);
	int maxx = v;
	FOR(i, 0, n)
	{
		if (D[i] > D[maxx]) maxx = i;
	}

	fill(D, -1);
	dfs1(maxx, -1, 0);
	FOR(i, 0, n)
	{
		if (D[i] > D[maxx]) maxx = i;
	}

	if (D[maxx] <= k) return true;
	return false;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	FOR(i, 0, n - 1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	if (k == 1)
	{
		cout << n - 2 << endl;
		return 0;
	}

	int ans = INF;
	int ind = -1;
	if (k % 2)
	{
		FOR(v, 0, n)
		{
			FOR(j, 0, SZ(g[v]))
			{
				int to = g[v][j];
				fill(U, 0);
				U[v] = U[to] = 1;
				cnt = 0;
				dfs(v, 0);
				dfs(to, 0);
				//cout << "!!" << cnt << endl;
				ans = min(ans, n - cnt);
			}
		}

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

	FOR(i, 0, n)
	{
		int cnt = calc(i);
		if (ans > n - cnt)
		{
			ans = n - cnt;
			ind = i;
		}
	}

	//calc(ind);
	//if (!check(ind))
	//{
	//	//cout << "-------------" << endl;
	//	throw - 1;
	//}

	cout << ans << endl;
}


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

int main(){

  int a[6],t,s;
  for(t=0;t<6;t++)
  {
    cin >> a[t];
  }
  
  for(t=0;t<4;t++){
  	for(s=t+1;s<5;s++)
    {
      if((a[t]-a[s]>a[5])||(a[s]-a[t] > a[5]))
      {
        cout << ":(" << endl;
        goto OUT;
      }
    }
  }
  cout << "Yay!" << endl; 
  OUT: 
  return 0;
  
}


Measured memory_bytes: 256
nom=Array.new(9)
nom[0],nom[1],nom[2]=gets.split.map!(&:to_i)
nom[3],nom[4],nom[5]=gets.split.map!(&:to_i)
nom[6],nom[7],nom[8]=gets.split.map!(&:to_i)
n=gets.to_i
ans=0
s=Array.new(n)
for i in 0..n-1
  s[i]=gets.to_i
  for j in 0..8
    if s[i]==nom[j]
      nom[j]="x"
    end
  end
end
if nom[0]=="x" && nom[0]==nom[1] && nom[1]==nom[2]
  ans=1
elsif nom[3]=="x" && nom[3]==nom[4] && nom[4]==nom[5]
  ans=1
elsif nom[6]=="x" && nom[6]==nom[7] && nom[7]==nom[8]
  ans=1
elsif nom[0]=="x" && nom[0]==nom[3] && nom[3]==nom[6]
  ans=1
elsif nom[1]=="x" && nom[1]==nom[4] && nom[4]==nom[7]
  ans=1
elsif nom[2]=="x" && nom[2]==nom[5] && nom[8]==nom[5]
  ans=1
elsif nom[0]=="x" && nom[0]==nom[4] && nom[4]==nom[8]
  ans=1
elsif nom[2]=="x" && nom[2]==nom[4] && nom[4]==nom[6]
  ans=1
else
  ans=0
end
if ans==1
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14408
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int w = sc.nextInt();
        char[] s = S.toCharArray();
        for (int i = 0; i < S.length(); i++) {
            if (i % w == 0) {
                System.out.print(s[i]);
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 20948
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  return i;
}

void solve(){
  ll n; cin >> n;
  map<int, ll> m;
  for(int i = 1;i < n+1;i++){
    m.insert(make_pair(i,0));
  }
  for(int i = 0;i < n-1;i++){
    int t; cin >> t;
    m[t]++;
  }

  for(int i = 1;i < n+1;i++){
    cout << m[i] << endl;
  }

}


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


Measured memory_bytes: 16168
n = int(input())
s = input()

mozi_list = [chr(i) for i in range(65, 65+26)]

ans = ''


for i in range(len(s)):
    xxx = s[i]
    index = mozi_list.index(xxx)
    new_index = index + n
    if new_index >= 26:
        new_index -= 26
    
    ans += mozi_list[new_index]

print(ans)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main() {
  ll n,x,y;
  cin >> n >> x >> y;
  ll k[n]={};
  for(ll i=1;i<n;i++){
    for(ll j=i+1;j<=n;j++){
      if(i==j)continue;
      ll now=min(abs(i-j),abs(x-i)+1+abs(y-j));
      k[now]++;
    }
  }
  for(int i=1;i<n;i++){cout << k[i] << endl;}
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int x , p;

int main(){
  scanf("%d%d",&x,&p);
  db ans = 0.;
  if(x & 1) ans = 1 + ((x - 1) / 2 + (100. - p) / p * (x + 1) / 2);
  else ans = 100. / p * x / 2;
  printf("%.12f\n",ans);
  return 0;
}


Measured memory_bytes: 256
N = input()
keta = len(N)
if keta == 1:
    print(int(N))
elif keta == 2:
    print(9)
elif keta == 3:
    print(int(N)-99+9)
elif keta == 4:
    print(909)
elif keta == 5:
    print(int(N)-9999+999-99+9)
else:
    print(90909)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int MN = 100005;

int N;
std::vector<std::pair<int, int>> G[MN];

LL Ans; int WTF;
int siz[MN], rt, rts;
void DFS(int u, int p, int x) {
	siz[u] = 1;
	int mxs = 0;
	for (auto e : G[u]) if (e.first != p) {
		int v = e.first;
		DFS(v, u, e.second), siz[u] += siz[v];
		mxs = std::max(mxs, siz[v]);
	}
	if (2 * siz[u] == N) WTF = x;
	Ans += std::min(siz[u], N - siz[u]) * (LL)x;
	mxs = std::max(mxs, N - siz[u]);
	if (rts > mxs) rt = u, rts = mxs;
}

int main() {
	scanf("%d", &N);
	for (int i = 1, x, y, z; i < N; ++i) {
		scanf("%d%d%d", &x, &y, &z);
		G[x].push_back({y, z});
		G[y].push_back({x, z});
	}
	rts = N, DFS(1, 0, 0);
	if (!WTF) {
		WTF = 0x3f3f3f3f;
		for (auto e : G[rt]) WTF = std::min(WTF, e.second);
	}
	printf("%lld\n", Ans * 2 - WTF);
	return 0;
}

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

#define QSIZE 100000
struct Task {
    string name;
    int time;
    Task(string n, int t) : name(n), time(t) {}
    Task() {}
}; 

Task queue[QSIZE+1];
int head, tail;


void enqueue(Task data)
{
    queue[tail] = data;
    tail = (tail + 1) % QSIZE;
}

Task dequeue()
{
    Task res = queue[head];
    head = (head + 1) % QSIZE;
    return res;
}

bool isEmpty()
{
    return head == tail;
}


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

    for (int i=0; i<N; i++) {
        string name;
        int time;
        cin >> name >> time;
        enqueue(Task(name, time));
    }

    int time = 0;
    while (!isEmpty()) {
        Task t = dequeue();
        if (t.time > Q) {
            enqueue(Task(t.name, t.time - Q));
            time += Q;
        } else {
            time += t.time;
            cout << t.name << " " << time << endl;
        }
    }
}

Measured memory_bytes: 7056
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    s = S()
    if len(s)<6:
        print('No')
        exit()
    if s[2]==s[3] and s[4]==s[5]:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 26928
defmodule Main do
  def main do
    ss = input(:strs) 
    ts = input(:strs)
    
    diffs = 
      for {s, t} <- Enum.zip(ss, ts) do
        unless s === t do
          1
        else
          0
        end
      end
    
    diffs
    |> Enum.sum 
    |> IO.puts
  end
  
  defp input(type \\ :str) do
    s = IO.gets("") |> String.trim()
    
    case {type, s} do
      {:int, s}  -> s |> String.to_integer()
      {:ints, s} -> s |> String.split("") |> Enum.map(&String.to_integer(&1))
      {:str, s}  -> s
      {:strs, s} -> s |> String.split("")
      _ -> raise "TypeError"
    end
  end
end

Measured memory_bytes: 115128
def main():
  M=10**9+7
  r=tuple(tuple((j-k)*9%13for j in range(10))for k in range(13))
  d=[1]+[0]*12
  for c in input():
    d = [sum(d[j]for j in k)%M for k in r] if c>'9' else [d[(int(c)-k)*9%13]for k in range(13)]
  print(d[5])
main()

Measured memory_bytes: 3244
int main()
{
     int a,b,x,y,z;
     while(~scanf("%d%d",&a,&b))
     {

       x=a+b;
       y=a*b;
       z=a-b;
       if(x>=y&&x>=z)
        printf("%d\n",x);
       if(y>x&&y>z)
        printf("%d\n",y);
       if(z>x&&z>y)
        printf("%d\n",z);


     }
    return 0;
}

Measured memory_bytes: 128
a=input()
b=input()
c=input()
d=input()
e=input()
L=[int(a[-1]),int(b[-1]),int(c[-1]),int(d[-1]),int(e[-1])]
M=[int(a),int(b),int(c),int(d),int(e)]
for i in range(5):
  if L[i] != 0:
    M[i] = M[i] + 10 - L[i]
  else:
    L[i] = 10
print(sum(M)+min(L)-10)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	char c; cin >> c;
	
	cout << (char)(c + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 998244353;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

const int MAX = 5100000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    COMinit();
    int n,m,k;
    cin >> n >> m >> k;
    ll ans = 0;
    // ブロックはN個
    // ブロックの隙間はN-1個
    // 0~K組のそれぞれについて
    // どの隙間を同じ色の組にするかの選び方は
    // COM(N-1,i);
    // 全体のブロックの数はN-i個
    // 塗り方はM * (M-1)^(N-i-1);
    // 全体は COM(N-1,i) * M * (M-1)^(N-i-1);
    // i = K,K-1,K-2,K-3, ... 0 ;
    ll x = 1;
    for(ll i=1;i<=n-k-1;i++){
        x *= (m-1);
        x %= mod;
    }
    for(ll i = k ;i >= 0; i--){
        // となり合うブロックが同じ色の組について
        // i組存在すると考える
        ll t = COM(n-1,i); // n-1個の中からi個選ぶ
        t *= m%mod * x%mod;
        t %= mod;
        ans += t;
        ans %= mod;
        x *= (m-1);
        x %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 123172
S = input()
S = [c for c in S]

S_even = [S[i] for i in range(len(S)) if i % 2 == 0]
S_odd = [S[i] for i in range(len(S)) if i % 2 == 1]

if "L" in set(S_even) or "R" in set(S_odd):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int H;
	static int W;
	static char[][] grid;
	static long[][] memo;

	static long dp(int x, int y) {
		for (int i = 0; i < W; i++) {
			if (grid[0][i] == '#')
				break;
			memo[0][i] = 1;
		}
		for (int i = 0; i < H; i++) {
			if (grid[i][0] == '#')
				break;
			memo[i][0] = 1;
		}

		for (int i = 1; i < H; i++) {
			for (int k = 1; k < W; k++) {
				if (grid[i][k] == '#')
					continue;
				memo[i][k] = (memo[i - 1][k] + memo[i][k - 1])% ((long) 1e9 + 7);
			}
		}
		return (memo[H - 1][W - 1] % ((long) 1e9 + 7));

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		grid = new char[H][W];
		memo = new long[H][W];
		for (int i = 0; i < H; i++)
			grid[i] = sc.next().toCharArray();
		for (long[] i : memo)
			Arrays.fill(i, 0);
		System.out.println(dp(0, 0));

	}

}


Measured memory_bytes: 63768
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, k; cin >> a >> b >> k;

    int cnt = 0;
    int ans = 0;

    for(int i= 100; i>=1; i--){

        if(a %i == 0 && b %i == 0){
            cnt++;
        }

        if(cnt == k){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}



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

int main(void)
{
	int n, m;
	int sumLoad[100001];
	int now;
	int ans;
	
	scanf("%d%d", &n, &m);
	
	sumLoad[0] = 0;
	for (int i = 0; i < n - 1; i++){
		scanf("%d", &sumLoad[i + 1]);
		sumLoad[i + 1] += sumLoad[i];
	}
	
	now = 0;
	ans = 0;
	for (int i = 0; i < m; i++){
		int a;
		scanf("%d", &a);
		
		ans = (ans + abs(sumLoad[now + a] - sumLoad[now])) % 100000;
		now += a;
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string.h>
#include <string>
using namespace std;

#define SIZE  10000000
#define LEN  14

long long dic[SIZE] = {};

long long getIndex(char* str) {
    long long index = 0;
    long long p = 1;
    int key;
    for(int i = 0; i < strlen(str); ++i) {
        switch(str[i]) {
            case 'A' : key = 1;   break;
            case 'C' : key = 2;   break;
            case 'G' : key = 3;   break;
            case 'T' : key = 4;   break;
        }
        index += p * key;
        p *= 5;
    }
    return index;
}

int main(void) {
    int n;
    string order;
    char str[14];
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> order >> str;
        if(order.find("insert") == 0) {
            dic[getIndex(str)] = 1;
        } else if(order.find("find") == 0) {
            if(dic[getIndex(str)] == 1) {
                cout<< "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        }
    }
}



Measured memory_bytes: 33404
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);

  int k = 0;
  int x = 0;
  while(x < n){
    x += 1000;
    k += 1;
  }
  printf("%d\n", 1000 * k - n);
  return 0;
}

Measured memory_bytes: 1704
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>

using namespace std;

enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif

signed main() {
#ifndef CrafterKolyan
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    int ans = abs(a - b) + abs(b - c);
    ans = min(ans, abs(a - c) + abs(b - c));
    ans = min(ans, abs(b - a) + abs(a - c));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include <assert.h>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge { int to, cost; };
#define VMAX 100000

int K;
ll N, ans = 0;
ll X[100010], Y[100010];
ll W_[3010][3010], B_[3010][3010];
auto W = W_ + 3;
std::string C[100010];
//yxyx

ll imos(int a, int b, int c, int d, int mode) {
	int res = 0;
	if (a>c || b>d)return 0;
	if (mode == 0) {
		if ((0 <= c && c<2 * K) || (0 <= d && d<2 * K))res += W[c][d];
		if ((0 <= c && c<2 * K) || (0 <= b - 1 && b - 1<2 * K))res -= W[c][b - 1];
		if ((0 <= a - 1 && a - 1<2 * K) || (0 <= d && d<2 * K))res -= W[a - 1][d];
		if ((0 <= a - 1 && a - 1<2 * K) || (0 <= b - 1 && b - 1<2 * K))res += W[a - 1][b - 1];
	}
	return res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin >> N >> K;
	REP(i, N) {
		cin >> X[i] >> Y[i] >> C[i];
		X[i] %= 2 * K, Y[i] %= 2 * K;
		if (C[i] == "W")W[Y[i]][X[i]] += 1;
		else W[Y[i]][(X[i] + K) % (2 * K)] += 1;
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i][j + 1] += W[i][j];
		//B[i][j + 1] += B[i][j];
	}
	REP(i, 2 * K)REP(j, 2 * K) {
		W[i + 1][j] += W[i][j];
		//B[i + 1][j] += B[i][j];
	}

	//for (size_t i = 0; i < 2 * K; i++)
	//{
	//	for (size_t j = 0; j < 2 * K; j++)
	//	{
	//		cout << W[i][j] << ' ';
	//	}
	//	cout << endl;
	//}

	REP(i, K)REP(j, K)REP(k, 2) {
		ll tans = 0;
		tans += imos(0    ,     0,     i - 1,     j - 1, 0);
		tans += imos(0    , j + K,     i - 1, 2 * K - 1, 0);
		tans += imos(i    ,     j, i + K - 1, j + K - 1, 0);
		tans += imos(K + i,     0, 2 * K - 1,     j - 1, 0);
		tans += imos(K + i, j + K, 2 * K - 1, 2 * K - 1, 0);
		ans = max(tans, ans);
		ans = max(W[2*K-1][2*K-1] - tans, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 53376
#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 ll INF = ll(1e18)+1;

int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll l = -INF, r = INF;
    while (l+1 < r) {
        ll x = (l+r)/2;
        bool ok = [&]{
            ll tot = 0;
            rep(i,n) {
                if(a[i] < 0 ){
                    int l = -1, r=n;
                    while (l+1 <r ){
                        int c =(l+r)/2;
                        if(a[c]*a[i]<x) r=c;else l=c;
                    }
                    tot += n-r;
                }else {
                    int l = -1, r=n;
                    while(l+1 <r){
                        int c = (l+r)/2;
                        if (a[c]*a[i]<x)l=c; else r=c;
                    }
                    tot +=r;
                }
                if (a[i]*a[i]<x ) tot--;
            }
            tot /=2;
            return tot < k;
        }();
        if (ok) l = x; else r = x;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))

changed = False
result = "Yes"
for i in range(N):
    if i == 0:
        continue
    diff = H[N-i] - H[N-i-1]
    if changed:
        diff -= 1

    if diff >= 0:
        changed = False
        continue
    if diff == -1:
        changed = True
        continue
    if diff <= -2:
        result = "No"
        break

print(result)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#include <math.h>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;

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

    int n;
    cin >> n;
    n %= 10;

    if (n == 3) {
        cout << "bon" << "\n";
    } else if (n == 0 || n == 1 || n == 6 || n ==8) {
        cout << "pon" << "\n";
    } else {
        cout << "hon" << "\n";
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int n;
int a[510][510];

void dfs(int l, int r, int level) {
    if(l >= r - 1) {
        return;
    }
    int mid = (l + r) / 2;
    for(int i = l; i < mid; i++) {
        for(int j = mid; j < r; j++) {
            a[i][j] = a[j][i] = level;
        }
    }
    dfs(l, mid, level + 1);
    dfs(mid, r, level + 1);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    dfs(0, n, 1);
    for(int i = 0; i < n - 1; i++) {
        for(int j = i + 1; j < n; j++) {
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String[] data = input.split(" ");
		int a = Integer.parseInt(data[0]);
		int b = Integer.parseInt(data[1]);

		if (a >= 1 && b <= 1 * Math.pow(10, 9)) {
			int d = (a / b);
			int r = a % b;
			double f = (float) r;
			double decimal = ((double) a / (double) b);

			System.out.printf("%d %d %.5f", d, r, decimal);
		}

	}
}



Measured memory_bytes: 26500
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

#define maxn 200100
int n;
string s;

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> s;
	n = s.length();
	LL tot = 0, Ans = 0;
	enum(i, 1, n)
	{
		if(s[i - 1] == 'W')
		{
			tot ++;
			Ans += i;
		}
	}
	Ans -= tot * (tot + 1) / 2;
	cout << Ans << endl;
	return 0;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a = -1, z = 0, len = 0;

	for (auto i = 0; i < s.size(); i++) {
		if (a == -1 && s[i] == 'A')
			a = i;
		if (s[i] == 'Z')
			z = i;
	}
	cout << z - a + 1 << endl;

}

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

const int DIM = 1e5 + 5;

int arr[DIM];

inline long long gcd(long long a, long long b) {
    long long c;
    
    while (b)
        c = a % b, a = b, b = c;
    
    return a;
}

int main(void) {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    long long ans = 1, val, aux, aux2;
    for (int i = 1; i <= n; ++i) {
        cin >> val;
        aux = gcd(val, ans);
        
        aux2 = gcd(aux, val);
        aux /= aux2; val /= aux2; ans = ans / aux * val;
    }
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 256