akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
  boolean flag=false;
  Scanner scan=new Scanner(System.in);
  String s;

  s=scan.next();
  long a=Long.parseLong(s);
  s=scan.next();
  long n=Long.parseLong(s);

  long ans=1;
  while(a/n>0){
   ans++;
   a/=n;
  }
  System.out.println(ans);
 }

 ///////////////////////////////////////////////
 public static boolean prime(long a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
   if(a%i==0)return false;
  }
  return true;
 }
 public static long llpow(long x,long n){
  long ans=1;
  for(int i=0;i<n;i++)ans*=x;
  return ans;
 }
 public static long max(long a,long b){
  if(a<b)return b;
  else return a;
 }
 public static long min(long a,long b){
  if(a>b)return b;
  else return a;
 }
 public static long cei(long x,long y){
  long ans=x/y;
  if(x%y!=0)ans++;
  return ans;
 }
 public static long gcd(long x,long y){
  return (y==1)?gcd(y,x%y):x;
 }
 public static long lcm(long x,long y){
  return x/gcd(x,y)*y;
 }
 public static long fact(long x){
  long ans=1;
  for(int i=0;i<x;i++)ans*=(x-i);
  return ans;
 }
 public static long ncr(long n,long r){
  long ans=1,l=2;
  for(int i=0;i<min(n-r,r);i++){
   ans*=(n-i);
   while(ans%l==0&&l<=min(r,n-r)){
    ans/=l;l++;
   }
  }
  return ans;
 }
 public static long npr(long n,long r){
  long ans=1;
  for(int i=0;i<r;i++)ans*=(n-i);
  return ans; 
 }
 public static long fib(int x){
  long fibo[]=new long[x+10];
  fibo[0]=1;fibo[1]=1;
  for(int i=2;i<x+1;i++)fibo[i]=fibo[i-1]+fibo[i-2];
  return fibo[x];
 }
 public static long dig(long n){
  long d=1,tmp=n;
  while(tmp/10>0){
   tmp/=10;d++;
  }
  return d;}
}



Measured memory_bytes: 35152
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 28 21:09:30 2016

@author: you
"""

n = int(input())

b = int(input())
maxv = b
minv = b

price = -1000000000

for i in range(n-1):
    x = int(input())
    flag = (x-b > 0)
    if flag:
        price = max(price, x-minv)
    else:
        if x < minv:
            minv = x
            maxv = x
        if price < x-b:
            price = x-b
    b = x

print(price)

Measured memory_bytes: 5628
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(T: Long, X: Long){
    pw.println(T.toDouble() / X.toDouble())
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val T = sc.next().toLong()
    val X = sc.next().toLong()
    solve(T, X)
}



Measured memory_bytes: 31276
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(f); }
	itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(l - 1); }
	itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }

template <class T> T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}


#include <algorithm>
#include <iostream>
#include <utility>

int main() {
	usize n;
	::std::cin >> n;
	::std::vector<u32> a(n);
	u32 sum = 0;
	for (auto &e : a) {
		::std::cin >> e;
		sum += e;
	}
	usize ans;
	u32 dist = 1000000;
	for (const auto i : rep<>(0, n)) {
		const u32 dif = difference(sum, u32(a[i] * n));
		if (smini(dist, dif)) ans = i;
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
typedef tree<
        pair<int, int>, // change type
        null_type,
        less<pair<int, int> >, // change type
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define per(i, start, end) for(int i = (int)start-1; i >= end; --i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);

int n, m;
string g[405];
bool visit[405][405];
ll black, white;

int di[] = {-1, 1, 0 ,0};
int dj[] = {0, 0, -1, 1};

bool valid(int i, int j)
{
    if (i < 0 || j < 0 || i >= n || j >= m)
        return 0;
    return 1;
}

void dfs(int i, int j)
{
    visit[i][j] = 1;
    if (g[i][j] == '#')
        black++;
    else
        white++;
    rep(mv, 0, 4)
    {
        int ii = i + di[mv], jj = j + dj[mv];
        if (valid(ii, jj) && g[ii][jj] != g[i][j] && !visit[ii][jj])
        {
            dfs(ii, jj);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
////    freopen("facebook.txt", "w", stdout);
//#endif
    cin >> n >> m;
    rep(i,0,n)
        cin >> g[i];
    ll ans = 0;
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if (!visit[i][j])
            {
                black = white = 0;
                dfs(i, j);
                ans += black * white;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 18048
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>

using namespace std;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORR(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
//Make sure no overflow problems
//#define int long long
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair

#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1e9 + 7;

const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

using namespace std;

int frog(vector<int>& heights, int N, int currentIteration)
{
    if (currentIteration + 2 == N)
    {
        return abs(heights[currentIteration] - heights[currentIteration + 1]);
    }
    else if (currentIteration + 2 >= N)
    {
        return 0;
    }

    return min(
        frog(heights, N, currentIteration + 1) + abs(heights[currentIteration] - heights[currentIteration + 1]),
        frog(heights, N, currentIteration + 2) + abs(heights[currentIteration] - heights[currentIteration + 2]));
}


int main(void)
{
    int N;
    cin >> N;

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

    /*dp[1] = abs(heights[0] - heights[1]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i - 1] + abs(heights[i - 1] - heights[i]), abs(dp[i - 2] + abs(heights[i] - heights[i - 2])));
    }*/

    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j : {i + 1, i + 2})
        {
            if (j < N)
            {
                dp[j] = min(dp[j], dp[i] + abs(heights[i] - heights[j]));
            }
        }
    }
    
    cout << dp[N - 1] << endl;
    //cout << frog(heights, N, 0);
    return 0;
}

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

int compare_int(const void *a,const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int w[10];
	int k[10];
	int sum_w,sum_k;
	int i;
	for(i = 0;i < 10;i++){
		scanf("%d",&w[i]);
	}
	for(i = 0;i < 10;i++){
		scanf("%d",&k[i]);
	}
	qsort(w,10,sizeof(int),compare_int);
	qsort(k,10,sizeof(int),compare_int);
	sum_w = w[9] + w[8] + w[7];
	sum_k = k[9] + k[8] + k[7];
	printf("%d %d\n",sum_w,sum_k);
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class D
{
	public static void Main()
	{
		string[] args;

		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int M = Int32.Parse(args[1]);

		int[] A = new int[M];
		int[] B = new int[M];
		for(int i = 0; i < M; i++)
		{
			args = Console.ReadLine().Split(' ');
			A[i] = Int32.Parse(args[0]) - 1;  // 0-index
			B[i] = Int32.Parse(args[1]) - 1;  // 0-index
		}

		long[] numConnected = new long[M+1];
		numConnected[M] = 0;

		UnionFind uf = new UnionFind(N);
		int[] w = new int[N];
		for(int i = 0; i < N; i++)
			w[i] = 1;
		for(int i = M-1; i >= 0; i--)
		{
			numConnected[i] = numConnected[i+1];
			if(!uf.same(A[i],B[i]))
			{
				numConnected[i] +=  (w[uf.find(A[i])] * w[uf.find(B[i])]);
				int tmp = w[uf.find(A[i])] + w[uf.find(B[i])];
				uf.unite(A[i],B[i]);				
				w[uf.find(A[i])] = tmp;
			}
		}

		for(int i = 0; i < M; i++)
			Console.WriteLine(numConnected[0] - numConnected[i+1]);
	}	
}


public class UnionFind
{
	public int N { get; private set; } = 0;
	private int[] par = null;
	private int[] rank = null;
	
	public UnionFind(int n)
	{
		if(n <= 0)
			throw new Exception();
		N = n;
		par = new int[N];
		rank = new int[N];
		for(int i = 0; i < N; i++)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}
	
	public int find(int x)
	{
		if(par[x] == x)
		{
			return x;			
		}
		else{
			return (par[x] = find(par[x]));
		}
	}
	
	public void unite(int x, int y)
	{
		x = find(x);
		y = find(y);
		if(x == y)
			return;
		
		if(rank[x] < rank[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if(rank[x] == rank[y])
				rank[x]++;			
		}
	}
	
	public bool same(int x, int y)
	{
		return (find(x) == find(y));
	}	
}





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

using namespace std;

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

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

//container util
//------------------------------------------
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

typedef pair<int, int> Pii;
typedef struct{ int x, y; } Point;
const int INF = 1001001001;

string s;
int cnt;

int calc()
{
    cnt = 0;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == s[i+1]);
        else{
            cnt++;
        }
    }
    
    return cnt;
}

int main(void)
{
    cin >> s;
    printf("%d\n", calc());
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int a,d,i;
	scanf("%d",&a);
  int b[a],c[a];
  for(i=0;i<a;i++){
  	scanf("%d",&b[i]);
  }
  for(i=0;i<a;i++){
  	scanf("%d",&c[i]);
    if(b[i]-c[i]>0){
    d+=b[i]-c[i];
    }
  }
  printf("%d",d);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	multimap<string, ll> a;
	for (int i = 0; i < n; i++)
	{
		int q;
		cin >> q;

		string s;


		switch (q)
		{
			case 0:
				cin >> s;

				ll x;
				cin >> x;
				a.emplace(s, x);
				break;

			case 1:
				cin >> s;

				if (a.count(s) > 0)
				{
					auto p = a.equal_range(s);
					for (auto it = p.first; it != p.second; it++)
					{
						println(it->second);
					}
				}
				else
				{
					//println(0);
				}
				break;

			case 2:
				cin >> s;

				if (a.count(s))
				{
					a.erase(s);
				}
				break;

			case 3:
				string l, r;
				cin >> l >> r;

				auto p = a.equal_range(l);
				auto q = a.equal_range(r);
				for (auto it = p.first; it != q.second; it++)
				{
					println(it->first << " " << it->second);
				}
				break;
		}
	}
}





Measured memory_bytes: 24940
#include<bits/stdc++.h>
using namespace std;
int p = 1e9+7;
const int N = 2e6;
vector<int >fact(N);
vector<int >invf(N);

int mul(int a,int b){
    return (1LL*a*b)%p;
}
int po(int a,int deg){
    
    if(deg==0)return 1;
    int temp = po(a,deg/2);
    temp = mul(temp,temp);
    if(deg%2!=0)temp=mul(temp,a);
    return temp;
    
}
int inv(int n){
    return po(n,p-2);
}
int main(){
    fact[0]=1;
    for(int i=1;i<N;i++)fact[i] = mul(fact[i-1],i);
    invf[N-1]=inv(fact[N-1]);
    for(int i=N-2;i>=0;i--)invf[i] = mul(invf[i+1],i+1);
	long long x,y;cin>>x>>y;
  if((2*x-y)%3==0 && (2*y-x)%3==0){
    long long a,b;
  	b = (2*x-y)/3;
    a = (2*y-x)/3;
    if(a<0 || b<0){cout<<0;return 0;}
    cout<<mul(fact[a+b],mul(invf[a],invf[b]));
  }
  else cout<<0;
}

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

int main(){
   int N;
   cin>>N;
   int count;
   int max=100;
   for(int i=0;i<N;i++){
       int a;
       cin>>a;
       count=0;
   	 while(a%2==0){
        a/=2;
        count++;
  	  }
      if(max>count){
        max=count;
      }
   }
   cout<<max<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
int mod=1e9+7;
ll C(ll a,ll b)
{
    ll re=1;
    while(b)
    {
        if(b&1)
        re=re*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return re;
}
int main()
{

string s;
cin>>s;
int len=s.length();
ll a=2;
ll b=1;
for(int i=1;i<len;i++)
{

     b=b*3%mod;
     s[i]=='0'? :(b=(b+a)%mod,a=a*2%mod);
}
cout<<(a+b)%mod<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n, m;
	cin >> n >> m;
	if(m%n==0){
		cout << m/n << endl;
		return 0;
	}
	ll ans=1;
	for(ll i=2; i*i<=m; i++){
		if(m%i==0){
			if(i>=n) ans=max(ans, m/i);
			if(m/i>=n) ans=max(ans, i);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using namespace std;

signed main(){
    int n;
    cin>>n;
    int a[]={1,0,0,0,1,0,0,1,1,0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,};
    cout<<(a[n%28]?"Yes":"No")<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

const int mod = 998244353;

void add (int &x, int y)
{
    x += y;
    if (x >= mod)
        x -= mod;
}
void sub (int &x, int y)
{
    x -= y;
    if (x < 0)
        x += mod;
}
int mult (int x, int y)
{
    return x * 1LL * y % mod;
}
int mult (int a, int b, int c)
{
    return mult(mult(a, b), c);
}
int mult (int a, int b, int c, int d)
{
    return mult(mult(a, b), mult(c, d));
}

int first_bigger (int bound, int mod, int rem)
{
    rem %= mod;

    if (rem >= bound)
        return rem;

    const int x = (bound - rem + mod - 1) / mod;
    return rem + mod * x;
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
    auto solve_test = [&] ()
    {
        int n;
        if (!(cin >> n))
            return false;

        vector<int> a(n), b(n);
        for (int &x : a)
            cin >> x;
        for (int &x : b)
            cin >> x;

        for (int i = 0; i < n; i++)
        if (a[i] > b[i])
        {
            cout << -1 << endl;
            return true;
        }

        queue<int> q;
        vector<char> used(n);

        auto try_add = [&] (int pos)
        {
            const int prev = (pos == 0 ? n - 1 : pos - 1);
            const int next = (pos == n - 1 ? 0 : pos + 1);

            if (b[pos] >= b[prev] && b[pos] >= b[next] && b[pos] > a[pos] && !used[pos])
            {
                used[pos] = 1;
                q.push(pos);
            }
        };

        long long ans = 0;
        for (int i = 0; i < n; i++)
            try_add(i);

        while (!q.empty())
        {
            const int pos = q.front(); q.pop(); used[pos] = 0;

            const int prev = (pos == 0 ? n - 1 : pos - 1);
            const int next = (pos == n - 1 ? 0 : pos + 1);

            const int step = b[prev] + b[next];
            const int guard1 = first_bigger(a[pos], step, b[pos]);
            const int guard2 = first_bigger(max(b[prev], b[next]), step, b[pos]);
            const int guard  = min(b[pos], max(guard1, guard2));

            assert((b[pos] - guard) % step == 0);
            ans += (b[pos] - guard) / step;
            b[pos] = guard;

            while (b[pos] >= max(b[prev], b[next]) && b[pos] > a[pos])
                b[pos] -= step, ans++;

            if (b[pos] < a[pos])
            {
                cout << -1 << endl;
                return true;
            }

            try_add(prev);
            try_add(next);
        }

        cout << ans << endl;
        return true;
    };

    while (solve_test());
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("input.txt");

	solve(fin);

	cout << "clock: " << setprecision(4) << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
namespace Contest
{
    class Program
    {

        static void Main()
        {
            var n = long.Parse(Console.ReadLine());
            var result = 0L;
            for (long i = 1; i < n; i++)
            {
                result += i;
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	/** 構築時に使う定数 */
	private static final int K = 50;
	/** 白いコマを表す文字 */
	private static final char WHITE = '.';
	/** 黒いコマを表す文字 */
	private static final char BLACK = '#';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			// 2K × 2K のグリッドを用意する。
			char[][] s = new char[2 * K][2 * K];
			// 上から K 行以内にあるマスを全て黒く塗り、残りのマスをすべて白く塗る。
			IntStream.range(0, K).forEach(i -> Arrays.fill(s[i], BLACK));
			IntStream.range(K, 2 * K).forEach(i -> Arrays.fill(s[i], WHITE));
			// 上から K − 1 行以内のマスのうち A − 1 個のマスを上下左右斜めに隣り合わないように選び、それらの色を白に変える。
			fill(s, 1, a - 1, WHITE);
			fill(s, K + 1, b - 1, BLACK);
			System.out.println(2 * K + " " + 2 * K);
			IntStream.range(0, 2 * K).forEach(i -> System.out.println(s[i]));
		}
	}

	/**
	 * コマの配列にコマをcount個入れる
	 * 
	 * @param s     コマの配列
	 * @param i     入れる開始行数
	 * @param count 入れる個数
	 * @param koma  入れるコマ
	 */
	private static void fill(final char[][] s, int i, int count, final char koma) {
		int j = 1;
		while (count > 0) {
			s[i][j] = koma;
			j += 2;
			count--;
			if (j >= 2 * K - 1) {
				i += 2;
				j = 1;
			}
		}
	}
}


Measured memory_bytes: 28884
N, M = map(int, input().split())
H = [int(x) for x in input().split()]
T = [1] * N
for _ in range(M):
  a, b = map(int, input().split())
  if H[a - 1] <= H[b - 1]:
    T[a - 1] = 0
  if H[b - 1] <= H[a - 1]:
    T[b - 1] = 0
print(sum(T))

Measured memory_bytes: 20132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    int ans = 0;
    while (true) {
        if (a&1 || b&1 || c&1) break;
        ans++;
        int tmp_a = (b+c)/2;
        int tmp_b = (a+c)/2;
        int tmp_c = (a+b)/2;
        swap(a,tmp_a); swap(b,tmp_b); swap(c,tmp_c);
        if (ans > 1e5) {cout << -1 << endl; return 0;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50f\n", a)//少数出力
#define printdbd(a) printf("%.16f\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", (a <= 9 && b <= 9 ? a * b : -1));
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

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

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
mod=998244353

dp1=[[0]*(d+1) for _ in range(c+1)]
dp2=[[0]*(d+1) for _ in range(c+1)]

for i in range(b+1,d+1):
  if a==1:
    dp1[a][i]=1 if i==b+1 else 0
    dp2[a][i]=0 if i==b+1 else 1
  else:
    dp1[a][i]=(pow(a-1,i-b-1,mod)*(i-b))%mod
    dp2[a][i]=(pow(a,i-b,mod)-dp1[a][i])%mod
for i in range(a+1,c+1):
  dp1[i][b]=pow(b,i-a,mod)
  dp2[i][b]=0
dp2[a][b]=1
for i in range(a+1,c+1):
  for j in range(b+1,d+1):
    dp1[i][j]=(j*(dp1[i-1][j]+dp2[i-1][j]))%mod
    dp2[i][j]=(dp1[i][j-1]+dp2[i][j-1]*i)%mod
print((dp1[c][d]+dp2[c][d])%mod)

"""
print('dp1')
for x in dp1:
  print(x)
print('dp2')
for x in dp2:
  print(x)
"""

Measured memory_bytes: 209084
up = list(map(int, input().split()))
mid = list(map(int, input().split()))
down = list(map(int, input().split()))

flag1 = 0
flag2 = 0
check = [0, 0, 0]

for i in range(-100, 101, 1):
    for j in range(3):
        check[j] = up[j] + i
    if check == mid:
        flag1 = 1
    if check == down:
        flag2 = 1

if flag1 == 1 & flag2 == 1:
    print("Yes")
else:
    print("No")




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


int main(){
	int H;
	int N;
	int i;
	
	cin >> H >> N;
	int A[N];

	for(i=0;i<N;i++){
		cin >> A[i];
	}
	int s=0;
	for(i=0;i<N;i++){
		s += A[i];
	}

	if(s>=H){
		cout << "Yes";
	}else{
		cout << "No";
	}
}

Measured memory_bytes: 640
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main() {
	string s;
	cin >> s;
	int cnt = 0;
	if (s[0] != 'A') {cout << "WA" << endl;return 0; }
	for (int i = 1;i < s.size();i++) {
		if (isupper(s[i])) {
			if (i == 1 || i == s.size() - 1 || s[i] != 'C') {cout << "WA" << endl;return 0; }
			cnt++;
		}
		
	}
	if (cnt != 1) {cout << "WA" << endl;return 0; }
	else cout << "AC" << endl;
}

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

int
main(int argc, char *argv[])
{
    const int INPUT_LEN_MAX = 20 + 1; /* +1 for \n */
    char buf[INPUT_LEN_MAX+1];
    int n, i;

    fgets(buf, INPUT_LEN_MAX, stdin);
    buf[INPUT_LEN_MAX] = '\0';

    n = strlen(buf);
    if (feof(stdin)) return 0;
    for (i = n-1; 0 <= i; i--) {
        int c = buf[i];
        if ('\n' == c) continue;
        putchar(c);
    }
    putchar('\n');
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010, mod = 1e9 + 7;

int n, m;

int fac(int n)
{
    int res = 1;
    for(int i = 1; i <= n; i++)
        res = (LL)res * i % mod;
    return res;
}

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

    if(abs(n - m) > 1)
    {
        puts("0");
        return 0;
    }

    int res = 1;
    int a = fac(n), b = fac(m);

    res = (LL)a * b % mod;

    if(n == m) res = res * 2 % mod;

    cout << res << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pii pair<int,int>
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
ll x,y,z,n,m,k,s=0,l=0,r=0,ans=0,cnt=0,a[10000],b[10000];
vector<ll> vec;
vector<pll> vecp;
set<ll> st;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m>>x>>y;
forr(i,0,n)cin>>a[i];
forr(i,0,m)cin>>b[i];
sort(a,a+n);sort(b,b+m);
forr(i,x+1,y+1)
{
    if(i>a[n-1] && i<=b[0])ans=1;}
    if(ans)cout<<"No War"<<endl;
else cout<<"War"<<endl;


return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
void swap_int(int* x, int* y) {
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}
void swap_char(char* x, char* y) {
    char temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

void asc_sort(int* array, int n) {
    int i, j;
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (array[i] > array[j]) {
                swap_int(&array[i], &array[j]);
            }
        }
    }
}

void dec_sort(int* array, int n) {
    int i, j;
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (array[i] < array[j]) {
                swap_int(&array[i], &array[j]);
            }
        }
    }
}

int max(int x, int y) {
    if (x > y) {
        return x;
    } else {
        return y;
    }
}

int min(int x, int y) {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}

int main(void) {
    char str[2000];
    int w;
    int i;

    scanf("%s", str);
    scanf("%d", &w);
    int n = strlen(str);
    for (i = 0; i < n; i += w) {
        printf("%c", str[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int cnt[110];
int a,b,c,ans;

int main()
{
	cin>>a>>b>>c;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	for(int i=1;i<=100;i++)
	{
		if(cnt[i])
		{
			ans++;
		}
	}
	printf("%d\n",ans);
}

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

using namespace std;

typedef pair<int,int> ii;
int N,M,CNT = 1;

int main(){
  while(cin >> N >> M,N|M){
    vector<ii> phase;    
    int turn=0;
    phase.push_back(ii(0,N));
    while(true){
      turn++;
      int zero = 0,tmp[M+1],mex = 0;
      for(int i=0;i<=M;i++)tmp[i] = 0;
      for(int i=0;i<phase.size();i++){
	int key = phase[i].first;
	int value = phase[i].second;
	if(value&1)value--,tmp[key]++;
	if(value / 2)mex = max(mex,key+1);
	tmp[key+1] += value / 2, tmp[0] += value / 2;
      }
      phase.clear();
      for(int i=0;i<=M;i++)if(tmp[i] != 0)phase.push_back(ii(i,tmp[i]));
      if(mex == M){
	cout << "Case " << CNT++ << ": " << turn << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){	
	int n;
	cin >> n;
	string sign;
	cin >> sign;
	string input[101];
	for(int i=0;i<n;i++){
		cin >> input[i];
	}
	int answer = 0;
	for(int i=0;i<n;i++){
		string str="";
		for(int j=0;j<100;j++){//??????
//			if(j*sign.size() > input[i].size())break;
			for(int k=0;k<input[i].size();k++){//?§????
				for(int l=0;l<sign.size();l++){//?????????????????????????????????
					if(k + j*l >= input[i].size())break;
					str += input[i][k + j*l];
				}
				if(str == sign){
					answer ++;
					break;
				}else{
					str = "";
				}
			}
			if(str == sign){
				break;
			}
		}
	}
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 3132
N = int(input())
A = list(map(int,input().split()))
import bisect
B = [(i+A[i],i-A[i]) for i in range(N)]

B.sort(key=lambda x: x[1])
C = [B[i][1] for i in range(N)]

ans = 0
for i in range(N):
    idl = bisect.bisect_left(C,B[i][0])
    idr = bisect.bisect_right(C,B[i][0])
    
    if 0<=idl<idr<=N and C[idl]==C[idr-1]==B[i][0]:
        ans += idr-idl
print(ans)


Measured memory_bytes: 124432
# テストケースによってTLEするのか確認するために再提出
import fractions
from functools import reduce
 
MOD = 10**9 + 7
 
def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    def lcm_base(x, y):
        return (x * y) // fractions.gcd(x, y)
 
    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)
 
    l = lcm_list(A)
    ans = 0
 
    for x in A:
        ans += l // x
        
    print(ans % MOD)
 
    
if __name__ == "__main__":
    main()

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	int ans = 0;
	rep(i, 0, 3)
	{
		if (S[i] == 'o')ans++;
	}

	cout << ans * 100 + 700 << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
int i=0;
for(auto it:v){
	if(i > 0){os << ' ';}
	os << it;
	i++;
} 
return os;
}
template<class T,class TT> ostream& operator <<(ostream &os, const map<T,TT> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
return os;
}
using ll = long long ;


int main(){
	ios::sync_with_stdio(false);
	// int X,Y;cin>>X>>Y;
	// map<int,int>mp;
	// int ans=0;
	// if(X<=3){
	// 	ans+=4-X;
	// }
	// if(Y<=3)ans+=4-Y;
	// if(X==1&&Y==1)ans+=1;
	// cout<<ans*100000<<endl;

	int H,W,K;cin>>H>>W>>K;
	vector<string>field(H);
	for(int i=0;i<H;++i){
		cin>>field[i];
	}
	vector<vector<int>>types(H,vector<int>(W));
	int id=0;

	int ah=-1;
	int preh=-1;
	for(int y=0;y<H;++y){
		vector<int>stos;
		for(int x=0;x<W;++x){
			if(field[y][x]=='#')stos.push_back(x);
		}
		if(stos.empty()){
			if(preh==-1){
			}else{
				types[y]=types[preh];
			}
		}else{
			if(ah==-1)ah=y;
			preh=y;
			int cnt=-1;
			for(int x=0;x<W;++x){
				if(field[y][x]=='#'){
					cnt++;
					
				}
				if(cnt==-1){
					types[y][x]=id;
				}else{
					types[y][x]=id+cnt;
				}
			}
			id+=cnt+1;
		}
	}
	for(int y=0;y<ah;++y){
		types[y]=types[ah];
	}
	for(int y=0;y<H;++y){
		for(int x=0;x<W;++x){
			cout<<types[y][x]+1;
			if(x==W-1)cout<<endl;
			else cout<<' ';
		}
	}

	return 0;
}

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

using namespace std;

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

using ll = long long;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	int n, k;
	cin >> n >> k;
	double res = 0;
	rep (i, n) {
	  double start = i + 1, pr = 1.0;
	  while (start < k) {
		start *= 2;
		pr *= 0.5;
	  }
	  res += pr;
	}
	cout << res * (1.0 / (double)n) << endl;
	
	
    return 0;
}



Measured memory_bytes: 3772
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial



def main():
    data = input()[::-1]

    index = 0
    while index < len(data):
        if data[index:index+5] == 'maerd':
            index += 5
        elif data[index:index+7] == 'remaerd':
            index += 7
        elif data[index:index+5] == 'esare':
            index += 5
        elif data[index:index+6] == 'resare':
            index += 6
        else:
            print('NO')
            sys.exit()

    print('YES')







if __name__ == '__main__':
    main()

Measured memory_bytes: 40432
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <deque>

using namespace std;

long long n;
int m;
deque<int> ans;

void solve(long long n)
{
	if(n <= 1) return ;
	if(n & 1)
		solve(n - 1), ans.push_front(++m);
	else
		solve(n / 2), ans.push_back(++m);
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	m = 0;
	solve(n + 1);

	cout << 2 * m << endl;
	for(int i = 0; i < ans.size(); i++)
		cout << ans[i] << ' ';
	for(int i = 1; i <= m; i++)
		cout << i << ' ';

	return 0;
}


Measured memory_bytes: 384
def is_month(t):
    return 1 <= int(t) <= 12

s = input()
pre, suf = s[:2], s[2:]

if is_month(pre) and is_month(suf):
    print('AMBIGUOUS')
elif not is_month(pre) and not is_month(suf):
    print('NA')
elif is_month(pre) and not is_month(suf):
    print('MMYY')
else:
    print('YYMM')


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{

    int a;
    scanf("%d", &a);
  	if(a <= 2){
      printf("0");
      return 0;
    }
  	int ans = 0;
  	if(a %2 == 0){
		ans = a/2 -1;
    }else{
      a = a+1;
      ans = a/2 -1;
    }
    
  printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public void solve(){
    Scanner sc = new Scanner(System.in);
    int t,n;
        for(int i=0;i<=3;i++){
        t = sc.nextInt();
        n = sc.nextInt();
        if(t==1){
            int kei = 6000*n;
            System.out.println(kei);
        }else{
            if(t==2){
                int kei = 4000*n;
                System.out.println(kei);
                }else{
                    if(t==3){
                        int kei = 3000*n;
                        System.out.println(kei);
                        }else{
                        int kei = 2000*n;
                        System.out.println(kei);
                    }
            }
        }
    }
    }
        public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17308
#include <iostream>

void swap(int &a, int &b) {
  int tmp = a;
  a = b;
  b = tmp;
}

void sort(int &a, int &b, int &c) {
  if (b < c) swap(b, c);
  if (a < b) swap(a, b);
  if (b < c) swap(b, c);
}

int count(int b, int n) {
  return (n % b == 0) ? 1 : 0;
}

int count(int g, int b, int n) {
  int sum = 0;
  while (n >= 0) {
    sum += count(b, n);
    n -= g;
  }
  return sum;
}

int count(int r, int g, int b, int n) {
  int sum = 0;
  while (n >= 0) {
    sum += count(g, b, n);
    n -= r;
  }
  return sum;
}

int main(void) {
  int r, g, b, n;
  std::cin >> r >> g >> b >> n;
  sort(r, g, b);
  std::cout << count(r, g, b, n);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 301

int main()
{
  char array[MAX]={'\0'};
  int i,j;
  int count[4]={0};
  int temp;

  scanf("%s",&array);

  for( i=0; i<MAX; i++ ){
    if( array[i]=='K' ) count[0]++;
    if( array[i]=='U' ) count[1]++;
    if( array[i]=='P' ) count[2]++;
    if( array[i]=='C' ) count[3]++;
  }

  for( i=0; i<4; i++ ){
    for( j=2; j>=i; j-- ){
      if( count[j]<count[j+1] ){
	temp=count[j];
	count[j]=count[j+1];
	count[j+1]=temp;
      }
    }
  }
  printf("%d\n",count[3]);

  return 0;
}

Measured memory_bytes: 536
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int a = (N*(N-1))/2;
    int b = (M*(M-1))/2;
    System.out.println(a+b);
  }
}

Measured memory_bytes: 25172
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        char[] s = new char[100000];
        int N = in.read(s, 0, s.length);
        int k = in.i();

        for (int i = 0; i < N; i++) {
            int d = k - ('z' - s[i] + 1) % 26;
            if (d >= 0) {
                s[i] = 'a';
                k = d;
            }
        }
        s[N - 1] += k % 26;

        out.println(new String(s, 0, N));
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0;i<3;i++){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int nums[10];

bool dfs(int index, int left, int right)
{
  // std::cout << index << std::endl;
  if (index == 10)
  {
    return true;
  }
  // try put at the larger one
  if (left >= right)
  {
    if (left < nums[index])
    {
      return dfs(index + 1, nums[index], right);
    }
    if (right < nums[index])
    {
      return dfs(index + 1, left, nums[index]);
    }
    return false;
  }
  if (right > left)
  {
    if (right < nums[index])
    {
      return dfs(index + 1, left, nums[index]);
    }
    if (left < nums[index])
    {
      return dfs(index + 1, nums[index], right);
    }
    return false;
  }
  return false;
}

int main()
{
  int count = -1;
  std::cin >> count;
  for (int i = 0; i < count; i++)
  {
    for (int j = 0; j < 10; j++)
    {
      std::cin >> nums[j];
    }
    if (dfs(0, -1, -1))
    {
      std::cout << "YES" << std::endl;
    }
    else
    {
      std::cout << "NO" << std::endl;
    }
  }
  return 0;
}


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

using namespace std;
#define taskname "A"
#define pb  push_back
#define mp  make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 505;
const int maxm = 1e4 + 5;

struct edge{
    int u , v , c;
    edge(){};
    edge(int u , int v , int c):u(u) , v(v) , c(c){};
}e[maxm * 2];
int nEdge = 0;
vector<int> adj[maxn];
void add_edge(int u , int v , int c){
    adj[u].pb(nEdge * 2);
    adj[v].pb(nEdge * 2 + 1);
    e[nEdge * 2] = edge(u,v,c);
    e[nEdge * 2 + 1] = edge(v,u,0);
    ++nEdge;
}
int lv[maxn] , s , t , n , m;
int a[maxn];

void BFS(){
    queue<int> q;
    fill_n(lv,maxn,-1);
    q.push(t);
    lv[t] = 0;
    while(!q.empty()){
        int u = q.front();q.pop();
//        cout << u << endl;
        for(int c : adj[u]){
            if(e[c ^ 1].c != 0 && lv[e[c].v] == -1){
                q.push(e[c].v);
//                cout << 2 << " " << e[c].v << endl;
                lv[e[c].v] = lv[u] + 1;
            }
        }
        if(lv[s] != -1)return;
    }

}
int DFS(int u , int In){
    if(u == t)return In;
    int Out = 0;
    for(int c : adj[u]){
        if(e[c].c != 0 && lv[e[c].v] == lv[u] - 1){
            int w = DFS(e[c].v , min(In , e[c].c));
            In -= w;
            Out += w;
            e[c].c -= w;
            e[c ^ 1].c += w;
        }
        if(In == 0)return Out;
    }
    return Out;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin);
        freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i];
    }
    ll res = 0;
    for(int i = 1 ; i <= n ; ++i){
        if(a[i] < 0)add_edge(0,i,-a[i]);
        else add_edge(i,n+1,a[i]);
        if(a[i] >= 0)res += a[i];
        for(int j = i ; j <= n ; j += i){
            add_edge(i,j,(int)1e9);
        }
    }
    s = 0;t = n + 1;
    while(BFS() , lv[s] != -1){
        res -= DFS(s , (1ll << 31) - 1);
    }
    cout << res;
}


Measured memory_bytes: 256