akhauriyash/Code-Regression huggingface dataset:
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;

ll signCheck(ll A1, ll A2) {
  if (A2 - A1 > 0) {
    return 1;
  } else  if (A2 - A1 < 0) {
    return -1;
  } else {
    return 0;
  }
}


int main(void) {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  ll oldSign = 0;
  ll ans = 1;
  ll sign = 0;
  oldSign = signCheck(A[0], A[1]);

  for (int i = 2; i < N; ++i) {
    sign = signCheck(A[i - 1], A[i]);
    if (sign == 0) continue;
    if (oldSign == 0) {
      oldSign = sign;
      continue;
    }
    if (oldSign != sign) {
      ans++;
      oldSign = 0;
    }
  }

  cout << ans << endl;

  
  return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            if (n % 2 != 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                long ans = 0;
                for (long i = 10; i < 1000000000000000000; i *= 5) {
                    ans += n / i;
                        }
                Console.WriteLine(ans);
            }


            //ここまで
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;
public class Main{
 public static void main(String[] args)throws IOException{
 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     String input=br.readLine();
     for(int i=0;i<input.length();i++){
         char a=input.charAt(i);
         if(Character.isUpperCase(a)){
           System.out.print(Character.toLowerCase(a));
         }else{
               System.out.print(Character.toUpperCase(a));
         }
     }
     System.out.print("\n");
 }
}

Measured memory_bytes: 24972
n = gets.chomp.to_i
ww = [gets.chomp]
(n-1).times do |i|
    w = gets.chomp
    if ww.include?(w) || ww[-1].chars.last != w.chars.first
        puts "No"
        exit 0
    end
    ww << w
end
puts "Yes"

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
    ll n;
    cin>>n;
    ll ans=infll;
for(int i=1;i<=pow(10,6);i++){
    if(n%i==0){
        chmin(ans,i+n/i);
    }
}
cout<<ans-2<<endl;
}





Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String[] s = new String[3];
  for(int i = 0;i < 3;i++){
    s[i] = sc.next();
  }
  String[] t = new String[3];
for(int i = 0;i < 3;i++){
  t[i] = s[i].toUpperCase();
}
  char[] u = {t[0].charAt(0),t[1].charAt(0),t[2].charAt(0)};
  System.out.println(u);
}
}


Measured memory_bytes: 21972
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>

using namespace std;

map<char, long long> ch_count;

long long get_count(char a, char b, char c)
{
	return ch_count[a] * ch_count[b] * ch_count[c];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int N;
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		ch_count[s[0]]++;
	}

	long long result = 0;
	result += get_count('M', 'A', 'R');
	result += get_count('M', 'A', 'C');
	result += get_count('M', 'A', 'H');

	result += get_count('M', 'R', 'C');
	result += get_count('M', 'R', 'H');

	result += get_count('M', 'C', 'H');

	result += get_count('A', 'R', 'C');
	result += get_count('A', 'R', 'H');
	result += get_count('A', 'C', 'H');

	result += get_count('R', 'C', 'H');

	cout << result;

	return 0;
}


Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = sorted(list(map(int,input().split())))
    A_max = A[-1] + 1
    dp = [0] * A_max

    for i in A:
        dp[i] += 1
        if dp[i] == 1:
            for j in range(i*2,A_max,i):
                dp[j] = 2
    print(dp.count(1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 32364
import java.util.Scanner;

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

	scanner.close();

	// cab
	String result = boxC + " " + boxA + " " + boxB;

	System.out.println(result);
    }

}

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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(e-a > k){
    cout << ":(" << endl;
  }
  
  else{
    cout << "Yay!" << endl;
  }
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

vi es[100005];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n,m;
    cin >> n >> m;

    rep(i, m) {
        int a, b;
        cin>> a >> b;
        a--; b--;
        es[a].push_back(b);
        es[b].push_back(a);
    }

    deque<int> deq;
    deq.push_back(0);
    set<int> s;
    s.insert(0);

    while(true) {
        int u = deq.front();
        bool ok = true;
        for(auto v: es[u]) {
            if (s.find(v) == s.end()) {
                deq.push_front(v);
                ok = false;
                s.insert(v);
                break;
            }
        }

        if (ok) break;
    }

    while(true) {
        int u = deq.back();
        bool ok = true;
        for(auto v: es[u]) {
            if (s.find(v) == s.end()) {
                deq.push_back(v);
                s.insert(v);
                ok = false;
                break;
            }
        }

        if (ok) break;
    }

    cout << deq.size() << endl;
    for(auto u : deq) {
        cout << u + 1;
        if (u != deq.back()) {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


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

using namespace std;
const int N = 100010;
int n, k, a[N];

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

int main() {
    cin >> n >> k;
    int g = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        g = gcd(g, a[i]);
    }
    for (int i = 0; i < n; i++)
        if (a[i] >= k && (a[i] - k) % g == 0) {
            puts("POSSIBLE");
            exit(0);
        }
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long a, long long b, long long c){
	for(int i=0; i<=1000000; ++i) {
		if (a%2+b%2+c%2>0) {
			cout<<i<<endl;
			return;
		}
		LL ta=(b+c)/2,tb=(a+c)/2,tc=(a+b)/2;
		a=ta; b=tb; c=tc;
	}
	puts("-1");
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long A;
	long long B;
	long long C;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&C);
	solve(A, B, C);
	return 0;
}



Measured memory_bytes: 256
import itertools
from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  map_ = [[0]*(N+1) for _ in range(N+1)]
  for i in range(M):
    a, b = list(map(int, input().split()))
    map_[a][b] = 1
    map_[b][a] = 1

  def is_one_stroke(path):
    now = 1
    for i in range(len(path)):
      next_ = path[i]
      if not map_[now][next_]:
        return False
      now = next_
    return True

  perms = itertools.permutations(list(range(2, N+1)))
  num_path = 0
  for path in perms:
    if (is_one_stroke(path)):
      num_path += 1
  print(num_path)


if(__name__ == '__main__'):
  main()

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

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    int tmp;
    int ans = 0;
    rep(i,n){
        if(a[i] == tmp + 1) ans += c[tmp];
        ans += b[a[i]];
        tmp = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n;
    std::cin >> n;
    std::cout << (n + 1) / 2 << std::endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3) rep(j,3){
        cin >> a[i][j];
    }
    vector<vector<int>> c(3,vector<int>(3,0));
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3) rep(k,3){
            if(a[j][k]==b) c[j][k] = 1;
        }
    }
    int z = 0;
    int y = 0;
    rep(i,3) {
        if(c[i][i]){
            z++;
        }

        if(c[2-i][i]){
            y++;
        }
    }
    if(z==3 || y==3){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i,3){
        int e = 0;
        int x = 0;
        rep(j,3){
            if(c[i][j]) e++;
            if(c[j][i]) x++;
        }
        if(e==3 || x==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  if(a == 0){
    cout << 1 << endl;
  }
  else if(b == 0){
    cout << 2 << endl;
  }
  else if(c == 0){
    cout << 3 << endl;
  }
  else if(d == 0){
    cout << 4 << endl;
  }
  else if(e == 0){
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N;
    cin >> N;
    vector<int> vec(N), d(110, 0);
    REP(i, N) cin >> vec[i];
    
    // calculation
    REP(i, N) {
        d[vec[i]]++;
    }
    int res = 0;
    REPN(i, 100) {
        if (d[i] > 0) {
            res++;
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int constexpr D = 100000 + 10;
vector<int> d[D];

int main() {
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        d[a].push_back(b);
    }

    long long ans = 0;
    priority_queue<int> pq;
    for(int day = m, i = 1; day >= 1; --day, ++i) {
        for(int b : d[i]) pq.push(b);
        if(pq.empty()) continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5632
n=int(input())
a=list(map(int,input().split()))
color=[0 for _ in range(9)]
for i in range(n):
    if a[i]<400:
        color[0]+=1
    elif 400<=a[i]<800:
        color[1]+=1
    elif 800<=a[i]<1200:
        color[2]+=1
    elif 1200<=a[i]<1600:
        color[3]+=1
    elif 1600<=a[i]<2000:
        color[4]+=1
    elif 2000<=a[i]<2400:
        color[5]+=1
    elif 2400<=a[i]<2800:
        color[6]+=1
    elif 2800<=a[i]<3200:
        color[7]+=1
    else:
        color[8]+=1
c=color[:-1].count(0)
if c!=8:
    m=8-c
    M=8-c+color[8]
else:
    m=1
    M=color[8]

print(str(m)+' '+str(M))

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



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


    int num;
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n; ++i){
        cin >> num;
        arr[i] = num;
    }

    long int dp[n];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    dp[1] = arr[1] - arr[0];
    for(int i=1; i<n; ++i){
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]) );
    }
    cout << dp[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 4800
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  var(string, a, b, c);
  int s = stoi(a + b + c);
  if (s % 4 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;


}


Measured memory_bytes: 256
s=[0,0,0]
10.times do |i|
  x = gets.chomp.to_i
  
  if s[0] < x
    s[2] = s[1]
    s[1] = s[0]
    s[0] = x
    
    
  elsif s[1] < x
    s[2] = s[1]
    s[1] = x
    
  elsif s[2] < x
    s[2] = x
  end
end
puts s


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

const int N = 109;

int n, m, k, a[N][N]={};

int main(){
    scanf("%d %d %d", &n, &m, &k);
    int i = 1, j = 1;
    for(int c = 1; c <= k; c++){
        int cnt; scanf("%d", &cnt);
        int x = 0;
        while(cnt){
            if(i % 2 == 1){
                for(; j <= m && cnt; j++) a[i][j] = c, cnt--;
                if(cnt || j == m+1){ i++; j--; continue; }
            }
            if(i % 2 == 0){
                for(; j >= 1 && cnt; j--) a[i][j] = c, cnt--;
                if(cnt || j == 0){ i++; j++; continue; }
            }
        }
    }

    for(i = 1; i <= n; i++){
        for(j = 1; j <= m; j++){
            printf("%d%c", a[i][j], " \n"[j == m]);
        }
    }
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	X, Y, Z := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	fmt.Println((X - Z) / (Y + Z))
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
# 初期入力
A,B = (int(x) for x in input().split(" "))

#最小公倍数を求める
from functools import reduce
import fractions #(2020-0405  fractions→math)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

saisyou_koubaisu = lcm(A,B)

print(saisyou_koubaisu)

Measured memory_bytes: 5124
#include<cstring>
#include<iostream>
#include<math.h>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<string>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;
const int MAXN = 11000;
int dp[5];
void recalc(int n ,int m )
{
    int k = m / 2;
    int p = n / 2;
    dp[4] = p * k ;
    dp[2] = k * (n % 2) + p * (m % 2);
    dp[1] = (m % 2) * (n % 2);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int  n  , m;
    cin >> n >> m;
    vector<int> cnt(505);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            char c;
            cin >> c;
            cnt[(int)c]++;
        }
    }
    recalc( n , m);
    for (int i = 4; i > 0; i--)
    {
        {
          for (char c = 'a'; c < char((int)'z' + 1) &&  dp[i] >= 1; c+= 1)
          {
              while (cnt[(int)c] >= i && dp[i] > 0)
              {
                  cnt[(int)c] -= i;
                  dp[i]--;
              }
          }
          if (dp[i] > 0)
          {
              cout << "No" << "\n";
              return 0;
          }
       }
    }
    
    cout << "Yes" << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	
	int n;
	scanf("%d", &n);
	
	int inNum[n];
	char inDraw[n];
	char e[] = {'S','H','C','D'};
	
	for(int i = 0; i < n; i++){
		scanf(" %c", &inDraw[i]);
		scanf("%d", &inNum[i]);
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 1; j <= 13; j++){
			int flag = 0;
			
			for(int k = 0; k < n; k++){
				//printf("inDraw[k] = %c e[i] = %c inNum[k] = %d j = %d\n",inDraw[k],e[i],inNum[k],j);
				if(inDraw[k]==e[i] && inNum[k] == j){
					flag = 1;
				}
			}
			
			if(flag == 0)
				printf("%c %d\n", e[i], j);
		}
	}
	
  return 0;
}

Measured memory_bytes: 1024
n, q = [int(item) for item in input().split()]
s = input()
lr = [[int(item) for item in input().split()] for _ in range(q)]

is_ac = [0] * n
count = 0
for i in range(n-1):
  if s[i] == "A":
    if s[i+1] == "C":
      count += 1
  is_ac[i+1] = count
is_ac[-1] = count
for item in lr:
  ans = is_ac[item[1]-1] - is_ac[item[0]-1]
  print(ans)

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    ll h; cin >> h; ll sum = 0; ll mon = 1;
    while(h != 0){
        h = floor(h/2);
        sum += mon;
        mon *= 2;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(1000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// 降順ソート
bool koujyunCmp(QWORD a, QWORD b)
{
	return a > b;
}

// メイン
#define ValTypeNum		3
#define MultipleTypeNum	8
int main()
{
	// 入力値
	int N, M;
	cin >> N >> M;
	vector<vector<QWORD>> xyzOne(N, vector<QWORD>(ValTypeNum, 0));
	REP(i, N) {
		REP(j, ValTypeNum) {
			cin >> xyzOne[i][j];
		}
	}
	
	// あらかじめサム地敬さん、8つしかパターンない
	const int multipleVal[MultipleTypeNum][ValTypeNum] = {
		{ 1, 1, 1 },
		{ 1, 1, -1 },
		{ 1, -1, 1 },
		{ -1, 1, 1 },
		{ 1, -1, -1 },
		{ -1, -1, 1 },
		{ -1, 1, -1 },
		{ -1, -1, -1 },
	};
	vector<vector<QWORD>> xyzSum(8, vector<QWORD>(N, 0));
	REP(mutiCnt, MultipleTypeNum) {
		const int *pMutiOne = multipleVal[mutiCnt];
		REP(i, N) {
			REP(j, ValTypeNum) {
				xyzSum[mutiCnt][i] += xyzOne[i][j] * pMutiOne[j];
			}
		}
	}

	// 降順ソート
	REP(mutiCnt, MultipleTypeNum) {
		sort(xyzSum[mutiCnt].begin(), xyzSum[mutiCnt].end(), koujyunCmp);
	}

	// 8パターン分上から加算
	QWORD lingoMax = 0;
	REP(mutiCnt, MultipleTypeNum) {
		QWORD lingoOne = 0;
		REP(i, M) {
			lingoOne += xyzSum[mutiCnt][i];
		}
		lingoMax = MAX(lingoMax, lingoOne);
	}
	cout << lingoMax;
	cout << endl;
}


Measured memory_bytes: 384
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;

        set<string> st;
        while(n--) {
            string s;
            cin >> s;
            st.insert(s);
        }

        cout << st.size() << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 19300
//package beginner166.a;

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(long testNumber, InputReader in, PrintWriter out) {
            String lastType = in.next();
            if ("ABC".equals(lastType)) {
                out.println("ARC");
            } else {
                out.println("ABC");
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 25648
#include <iostream>

typedef long long ll;
using namespace std;

ll x[100001];
ll y[100001];

const ll MOD = 1000000007;

ll calc(ll *x, int n) {
    ll sum = 0;
    for (int i = 1; i <= n; i ++) {
        ll y = (((ll)i * (n - i)) % MOD) * (x[i] - x[i-1]) % MOD;
        sum = (sum + y) % MOD;
    }
    return sum;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i ++) {
        cin >> x[i];
    }
    for (int i = 0; i < m; i ++) {
        cin >> y[i];
    }
    cout << (calc(x, n) * calc(y, m)) % MOD << endl;
}

Measured memory_bytes: 1792
import static java.lang.System.out;
import java.util.Scanner;

public class Main{
    public static void main(String...args) {

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

        if (a > b) {
            out.println("a > b");
        }
        else if (a < b) {
            out.println("a < b");
        }
        else {
            out.println("a == b");
        }
    }

}

Measured memory_bytes: 26072
#include <bits/stdc++.h>
using namespace std;
#define int long long

vector<int> g[200007];
int counter[200007];

void dfs(int r, int curr, int p){
    counter[r]=counter[r]+curr;
    
    for(int i=0;i<g[r].size();i++){
        if(g[r][i]==p) continue;
        dfs(g[r][i], counter[r], r);
    }
}


int32_t main() {
	int n,q;
	cin>>n>>q;
	
	for(int i=0;i<n-1;i++){
	    int x, y;
	    cin>>x>>y;
	    g[x].push_back(y);
	    g[y].push_back(x);
	}
	
	for(int i=0;i<q;i++){
	    int x, y;
	    cin>>x>>y;
	    counter[x]+=y;
	}
	
	dfs(1,0,-1);
	for(int i=1;i<=n;i++) cout<<counter[i]<<" ";
	
	return 0;
	
}

Measured memory_bytes: 24320
N = int(input())
E ={i:[] for i in range(N+1)}
ab = []
for i in range(N-1):
  a,b = [int(x)  for x in input().split()]
  ab.append((a,b,i))
  E[a].append((b,i))
  E[b].append((a,i))
visited=[0]*(N+1)
stk = [[1,-1,0]]
ans = [0]*(N-1)
while stk:
  v,p,r = stk.pop()
  if visited[v]:
    continue
  visited[v]=1
  a = 1
  for i,j in E[v]:
    if i!=p:
      if a!=r:
        stk.append([i,v,a])
        ans[j]=a
        a=a+1
      else:
        a=a+1
        stk.append([i,v,a])
        ans[j]=a
        a = a+1
print(max(ans))
for i in range(N-1):
	print(ans[i])

Measured memory_bytes: 95972
#include<stdio.h>
int main()
{
	long long int s;
	scanf("%lld", &s);
	if (s <= 1000000000)
	{
		printf("0 0 1 0 0 %lld\n", s);
	}
	else
	{
		long long int p = 1000000000 * ((s + 999999999) / 1000000000);
		printf("0 0 1000000000 1 %lld %lld\n", p - s, p / 1000000000);
	}
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
broken_step = [0] * (N + 1)
for _ in range(M):
    n = int(input())
    broken_step[n] = 1

dp = [1] * (N + 1)
dp[1] = 0 if broken_step[1] == 1 else dp[0]

for i in range(2, N + 1):
    if broken_step[i] == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i -1] + dp[i - 2]

print(dp[-1] % 1000000007)


Measured memory_bytes: 470648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

int main() {
    int n, p;
    cin >> n >> p;
    int cnt;
    rep(i, 0, n){
        int a;
        cin >> a;
        if(a%2 == 1)cnt++;
    }
    if(cnt == 0){
        if(p == 0)cout << (1ll<<n) << endl;
        else cout << '0' << endl; 
    }
    else cout << (1ll<<(n-1)) << endl;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader rd = new Reader();    
        int r, D, x;
        {int[] a = rd.ii(); r = a[0]; D = a[1]; x = a[2];}
        for(int i = 0; i < 10; i++){
            x = r*x-D;
            println(x);            
        }
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21076
using System;
using System.Collections.Generic;
using System.Linq;

public class A {
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        string[] lines = Console.ReadLine().Split(' ');
        List<int> A = new List<int>();
        bool isApproved = true;
        for (int i=0;i<N;i++)
        {
            A.Add(int.Parse(lines[i]));
            if (A[i] % 2 == 0)
            {
                if (!(A[i] % 3 == 0 || A[i] % 5 == 0))
                {
                    isApproved = false;
                    break;
                }
            }
        }
        if (isApproved)
        {
            Console.WriteLine("APPROVED");
        }
        else
        {
            Console.WriteLine("DENIED");
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli h;
vll a;


void max_heapify(lli i){
    lli l = i*2;
    lli r = i*2+1;
    lli est = max({i,r,l},[](lli s,lli t){
        if(s > h) return true;
        if(t > h) return false;
        return a[s] < a[t];
    });
    swap(a[i],a[est]);
    if(i != est) max_heapify(est);
}

int main(){
    cin >> h;
    a = vll(h+1);
    for(lli i = 1;i <= h;i++) cin >> a[i];
    for(lli i = h;i > 0;i--) max_heapify(i);
    for(lli i = 1;i <= h;i++) cout << " " << a[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 6724
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/rope>

using namespace __gnu_pbds; 
using namespace __gnu_cxx;
using namespace std;
using ll = long long;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define precision(n) fixed<<setprecision(n)

#ifdef LOCAL
    #include "debug.h"
#else
    #define debug(...) 42
#endif

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}

template<typename T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update >;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T> >;
template<typename T> void done(T ans) {cout << ans << "\n"; exit(0);}


template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}
const int mod = 998244353;
const int N = 3e5 + 5;



int main() {
    io();
    ll n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int x = 0;
    vector<int> v;
    unordered_set<int> s;
    while(1) {
        v.push_back(x);
        if(s.insert(x).second == false) break;
        x = a[x];

    }
    int len = 0;
    for(int i = 0; i < v.size(); i++) {
        if(v[i] == v.back()) {
            len = i;
            break;
        }
    }
    int cycle_len = (v.size() - len - 1);
    



    if(k < v.size()) {
        cout << v[k] + 1;
    }
    else {
        k -= len;
        k++;
        k = k % cycle_len;
        if(k == 0)
            k = cycle_len;
        cout << v[len + k - 1] + 1;
    }
}


Measured memory_bytes: 12676
d, g = map(int, input().split())

k = [list(map(int, input().split())) for i in range(d)]
l = []
for i in range(1, d + 1):
    l.append(k[-i])
k = l
#k.sort(key=lambda x:(-x[1]))
#A = [0, 1, 2, 3]の部分集合を全て出力する
#A = [0, 1, 2, 3]
combined1 = []
for i in range(d):
    combined1.append([k[i][0] * (d - i) * 100 + k[i][1]])
ansli = []
for i in range(1 << d):
    output = []
    ot = []
    for j in range(d):
        if ((i >> j) & 1) == 1:
            output.append(k[j] + combined1[j])
            ot.append(j)
    #print(output)
    sum = 0
    anscnt = 0
    for m in output:
        sum += m[2]
        anscnt += m[0]
    if sum >= g:
        ansli.append(anscnt)
    else:
        for v in range(d):
            if v not in ot:
                diffyen = g - sum
                tmp = (diffyen + 100 * (d - v) - 1) // (100 * (d - v))
                if tmp < k[v][0]:
                    ansli.append(anscnt + tmp)
                break
print(min(ansli))

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	long long a,b;
	bool flag = true;
	scanf("%lld%lld",&a,&b);
	for(int i = 2; i <= 11; i++){
		if(a*i % b != 0){
			printf("%lld\n",a*i);
			flag = false;
			break;
		}
	}
	if(flag) printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = input.readLine().split(" ");
        long a = Long.parseLong(inputs[0]);
        long b = Long.parseLong(inputs[1]);
        long x = Long.parseLong(inputs[2]);

        long count = 0;
        count += b / x;
        count -= a / x;
        if (a % x == 0) {
            count += 1;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string n;
  cin >> n;
  if ((n[0] == n[1]) && (n[1] == n[2])){
    cout << "Yes" << endl;
  }
  else if ((n[1] == n[2]) && (n[2] == n[3])){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
D,G = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(D)]

ans = 10**9
for b in range(1<<D):
    score = 0
    ac = 0
    for k in range(D):
        if b&(1<<k):
            p,c = src[k]
            score += c + p*100*(k+1)
            ac += p
    if score >= G:
        ans = min(ans,ac)
        continue
    for k in range(D-1,-1,-1):
        if b&(1<<k)==0:
            p,c = src[k]
            if score + p*(k+1)*100 < G:
                score += p*(k+1)*100
                ac += p
            else:
                rem = score- G
                ac -= rem//((k+1)*100)
                ans = min(ans,ac)
print(ans)

Measured memory_bytes: 40688
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int a, b; cin >> a >> b;
	int res = -1;
	for (int i = 1; i <= 10000; ++i)
	{
		if (floor((double)i*0.08) == a && floor((double)i*0.1) == b)
		{
			res = i;
			break;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanLLInt(A); A *= 100;
    scanLLInt(B); B *= 100;
    scanLLInt(C);
    scanLLInt(D);
    scanLLInt(E);
    scanLLInt(F);
    ll water = A;
    ll sugar = 0;
    double rate = 0;
    for (ll a = 0; A * a <= F; ++a){
        for (ll b = 0; A * a + B * b <= F; ++b){
            if (a == 0 && b == 0) continue;
            const ll water_temp = A * a + B * b;
            for (ll c = 0; water_temp + C * c <= F && C * c <= (water_temp) * E / 100; ++c){
                for (ll d = 0; water_temp + C * c + D * d <= F && C * c + D * d <= water_temp * E / 100; ++d){
                    const ll sugar_temp = C * c + D * d;
                    if (rate < 1.0 * sugar_temp / water_temp){
                        water = water_temp;
                        sugar = sugar_temp;
                        rate = 1.0 * sugar / water;
                    }
                }
            }
        }
    }
    printf("%lld %lld\n", water + sugar, sugar);
}


Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
if H%3==0 or W%3==0:
    answer = 0
else:
    answer = min(H, W)
# さらに小さくするには縦と横で割る
h = H // 3
area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]
answer = min(answer, max(area)-min(area))
h += 1
area = [h * W, (H-h) * (W//2), (H-h) * ((W+1)//2)]
answer = min(answer, max(area)-min(area))
w = W // 3
area = [w * H, (W-w) * (H//2), (W-w) * ((H+1)//2)]
answer = min(answer, max(area)-min(area))
w += 1
area = [w * H, (W-w) * (H//2), (W-w) * ((H+1)//2)]
answer = min(answer, max(area)-min(area))
print(answer)

# 13

Measured memory_bytes: 3316