akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
a = gets.split.map(&:to_i)

hst = a.each_with_object(Hash.new(0)) { |i,h| h[i] += 1 }
cnt1 = hst.map do |i,j|
  [i, j * (j-1) / 2]
end.to_h
cnt2 = hst.map do |i,j|
  [i, (j-1) * (j-2) / 2]
end.to_h
sum = cnt1.values.inject(0, :+)

a.each do |i|
  puts sum - cnt1[i] + cnt2[i]
end

load __FILE__ unless $stdin.eof?


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

ll toint(string &s,int st,int en){
    ll ans=0;
    for(int i=st;i<=en;++i){
        ans = ans*10 + s[i] - '0';
    }
    return ans;
}

int main(){
    string s;
    cin>>s;
    int st{0},en{0};
    ll ans=0;
    ll range = 1<<(s.size()-1);
    int endd = s.size() -1 ;
    for(ll i=0;i<range;++i){
        ll j = i;
        st=en=0;
        while(j){
            if(j&1){
                ans+=toint(s,st,en);
                st = 1 + en++;
            }else{
                ++en;
            }
            j>>=1;
        }ans+=toint(s,st,endd);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{int n,sum=0;
 string s;
 char now=s[0];
 cin>>n>>s;
 for(int i=0;i<n;i++)
 {if(now!=s[i])
 {sum++;
  now=s[i];
 }
 }
 cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 512
from collections import deque

N, K = map(int, input().split())
R, S,P = map(int, input().split())
T = list(str(input()))

score = deque()

for i in range(len(T)):
    if T[i] == "r":
        score.append(P)
    elif T[i] == "s":
        score.append(R)
    elif T[i] == "p":
        score.append(S)

for i in range(len(score)-K):
    if T[i] == T[i+K]:
        if score[i] >= score[i+K]:
            score[i+K] = 0
        else:
            score[i] = 0

print(sum(score))

Measured memory_bytes: 49616
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define maxn 1000005
#define maxm 205
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
 
int n, m, k;
int main(){
	int i, j, x;
	n =read(),m= read(),k=read();
	printf("%d\n",(n +m -1)/m *k);
	return 0;
}

Measured memory_bytes: 3748
x,y = map(int,input().split())

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

if (x in a)&(y in a) or (x in b)&(y in b) or (x in c)&(y in c):
  print("Yes")
else:
  print("No")  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, A, M = 60, i, j, ans = 0;
	scanf("%lld", &N);
	vector<int> count(M, 0);
	for(i = 0; i < N; i++){
		scanf("%lld", &A);
		for(j = 0; j < M; j++){
			count[j] += ((A >> j) & 1);
		}
	}
	for(j = 0; j < M; j++){
		ans = MOD(ans + MOD(1ll << j) * MOD(count[j] * (N - count[j])));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

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

    int n,k=2;
    cin>>n;
    int h[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=max(i-k,0);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  cin >> A; 
  cin >> B;

  if (A % 500 - B <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
broken = set([int(input()) for _ in range(m)]) # ここが'list'だとPypyでも通らない

def ptn_num(x): # 'x'stepまでのパターン数
    if x == 1:
        print(1)
    else:
        dp = [0] * (x+1) # DP枠_including step'0'
        cnt = 0 # 連続して壊れている階段を記録, '2'でゴール不可能
        if 1 in broken: # in case, step'1' broken 
            dp[:2] = 1, 0
        else:
            dp[:2] = 1, 1 # Usually

        for i in range(2, x+1):
            if i in broken: # 階段が壊れている場合は...
                cnt += 1 # 壊れている階段を記録するのみ
                if cnt == 2: # 2段連続で壊れている場合
                    print(0)
                    exit()
            else: # 階段が壊れてない場合...
                dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7) # -1段目と-2段目の合計
                cnt = 0 # 壊れている階段の記録はリセット
        print(dp[-1])

ptn_num(n)

Measured memory_bytes: 13216
# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num_min = 1000001
num_max = -1000001
num_sum = 0
num = int(input())

# a = []
# a = [ *map(int,input().split() ) ]
a = input().split()

for i in range(num):
	a[i]=int(a[i])
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );

Measured memory_bytes: 8348
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    lli n, k;
    cin>>n>>k;
    vector<lli> a(n);
    for(int i = 0; i < n; i ++)  {
        cin>>a[i];
        a[i] ++;
    }
    vector<lli> X(n + 1, 0);
    for(int i = 0; i < n; i ++) {
        X[i + 1] = X[i] + a[i];
    }
//    for(auto it : X)
//        cout<<it<<' ';
//    cout<<endl;
    lli ans = 0;
    for(int i = k; i <= n; i ++) {
     //   cout<<X[i] - X[i - k]<<endl;
        ans = max(ans, X[i] - X[i - k]);
    }
    cout<<fixed<<setprecision(10);
    cout<<ans / 2.0;
    cout<<'\n';
    return ;
}



/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3328
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var input = MyUtil.ReadintArray();
        var result = input[0] > 10 ? input[1] : input[1] + (10 - input[0]) * 100;
        WriteLine(result);

        ReadKey();
    }
}


static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    bool count = true;
    for(int i=1;count;i++){
        int x;
        cin >> x;
        if(x==0){
            count = false;
        }
        else{
            cout << "Case " << i << ": " << x << endl;
        }
    }
}


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

using namespace std;

int main(){
   int n;
   cin >> n;
   string s;
   cin >> s;
	for(int i=0;i<s.length();i++){
		s[i] = s[i] + n;
		if(s[i]>90){
		 s[i] = 65+s[i]-90-1;
		}
	  cout << s[i];	
	}
}

Measured memory_bytes: 256
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int c,d;
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
LL lcm(int x,int y){return 1ll*x*y/gcd(x,y);}

LL sv(LL x){
	return x-(x/c+x/d-x/(lcm(c,d)));
}

int main(){
	LL a,b;
	scanf("%lld%lld%d%d",&a,&b,&c,&d);
	printf("%lld\n",sv(b)-sv(a-1));

	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
count = 0

for i in range(1, N+1):
    sum = 0
    ans = i
    for j in range(len(str(i))):
        sum += i % 10
        i //= 10

    if A <= sum <= B:
        count += ans

print(count)
        

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define PB push_back
#define MP make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
const ld PI = 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);AIN(ll,A,N);
  ll dp[N][N];
  REP(i,N){
      dp[0][i] = A[i];
  }
  REP(i,N-1){
      REP(j,N-1){
          if(i+j+1>=N)continue;
          dp[i+1][j] = max(A[j]-dp[i][j+1],A[i+j+1]-dp[i][j]);
      }
  }
  OUT(dp[N-1][0]);
}

Measured memory_bytes: 70400
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;
int main(){
    int n;
    cin >> n;
    unordered_map<string,int> m;
    string emp;
    getline(cin,emp);
    int ct = 0;
    for(int i = 1; i <= n; i++){
        string a;
        getline(cin,a);
        if(m.find(a) != m.end())continue;
        else {m[a] = 1;ct++;}
    }
    cout << ct;
    
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=1e5+5;

int cnt[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,k,q,x;
	cin >> n >> k >> q;
	for(int i=0; i<q; i++){
		cin >> x;
		cnt[x-1]++;
	}
	for(int i=0; i<n; i++){
		cnt[i] = k-(q-cnt[i]);
		if(cnt[i]>0)cout << "Yes \n";
		else cout << "No \n";
	}
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
	long long h,w;cin >>h>>w;
	long long out =1;
	if(h>1 && w>1){
		out= (h/2 + h%2)*(w/2 + w%2) + (h/2)*(w/2);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var p = readLine()!!.split(' ').map { it.toInt() }
    var q = readLine()!!.split(' ').map { it.toInt() }
    var a = 0
    var b = 0
    var cnt = 0

    fun dfs(list: List<Int>) {
        if (list.size < n) {
            (1..n).forEach { if (!list.contains(it)) dfs(list + it) }
            return
        }
        cnt++
        if (list == p) a = cnt
        if (list == q) b = cnt
    }
    dfs(listOf())

    println(Math.max(a-b, b-a))
}


Measured memory_bytes: 50580
#include<stdio.h>

void
swp(long int *a, long int *b)
{
        long int tmp;
        tmp = *a;
        *a = *b;
        *b = tmp;
}

int
main(int argc, char *argv[])
{
        char buf[64];
        long int a, b, t_a, t_b;
        long int GCD, LCM;

        while (fgets(buf, 64, stdin)) {
                sscanf(buf, "%ld %ld", &a, &b);
                if (a < b) swp(&a, &b);
                t_a = a;
                t_b = b;
                while (t_a % t_b != 0) {
                        t_a = t_a % t_b;
                        swp(&t_a, &t_b);
                }
                GCD = t_b;
                LCM = a / GCD * b;
                printf("%ld %ld\n", GCD, LCM);

        }
        return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long lli;

lli devc(lli a, lli b){ return a / b + (a % b != 0); }

int main(){
	lli M, rd, rr, cd, cr;
	cin >> M >> rd >> rr >> cd >> cr;
	lli d = devc(100 * cd, rd);
	lli r = devc(100 * cr, rr);
	if(d + r > M) cout << -1 << endl;
	else cout << M - (d + r) << endl;
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int n,x,m;
int num[6],l[10],r[10],s[10],ans[6],sum;
bool done;

int Sum(){
	int res=0;
	rep(i,0,n) res+=num[i];
	return res;
}

bool Check(){
	rep(i,0,m){
		int cnt=0;
		rep(j,l[i],r[i]) cnt+=num[j];
		if(cnt!=s[i]) return false;
	}
	done=true;
	return true;
}

void DFS(int i){
	if(i==n){
		int sum=0;
		if(Check()&&sum<Sum()){
			rep(j,0,n) ans[j]=num[j];
			sum=Sum();
		}
		return;
	}

	rep(j,0,x+1){
		num[i]=j;
		DFS(i+1);
	}
}

void Solve(){
	cin >> n >> x >> m;
	rep(i,0,m){
		cin >> l[i] >> r[i] >> s[i];
		--l[i];
	}

	DFS(0);
	if(done){
		rep(i,0,n){
			cout << ans[i];
			if(i!=n-1) cout << ' ';
			else cout << endl;
		}
	}else cout << -1 << endl;
}

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

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int n,k;
char s[200005];
int t,f,h;
void output(){
	for (int i=0;i<n;i++)
		putchar('A'+(s[(h+i)%n]==f));
	exit(0);
}
int main(){
	scanf("%d%d%s",&n,&k,s);
	for (int i=0;i<n;i++)
		s[i]=(s[i]=='A');
	h=0,t=0;
	for (;h<n;){
		if (s[h]!=f) s[h]^=1;
		else h++,f^=1;
		if ((++t)==k) output();
	}
	h=0;
	if (n%2==1&&(k-t)%2==1)
		s[h]^=1;
	output();
}

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

void solve() 
{
    int n,ans=0;cin>>n;
    for(int i=1;i<=n;i+=2){
        int sum=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)sum++;
        }
        if(sum==8)ans++;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
////////////////////////////////////////////////////////////////////
using namespace std ;

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

  REP(i,b-a+1){
    if((b-i)%k==0){
      s++;
    }
  }
  if(s>0){
    puts("OK");
  }else{
    puts("NG");
  }
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n, l, sum;
int main(){
    scanf("%d%d", &n, &l);
    vector<int> v;
    for(int i = 1 ; i <= n ; ++i)
        v.emplace_back(l + i - 1), sum += v.back();
    int mn = INT_MAX, ans;
    for(auto i : v){
        int hna = sum - i;
        if(abs(hna - sum) < mn)
            mn = abs(hna - sum), ans = hna;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, Count[2][100005], Max[2][5], result;

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
    {
        int num;
        scanf("%d", &num);
        Count[i % 2][num]++;
    }
    for(int i = 1; i <= 100000; i++)
    {
        for(int j = 0; j < 2; j++)
        {
            if(Count[j][Max[j][0]] < Count[j][i])
            {
                Max[j][1] = Max[j][0];
                Max[j][0] = i;
            }
            else if(Count[j][Max[j][1]] < Count[j][i])
            {
                Max[j][1] = i;
            }
        }
    }
    if(Max[0][0] != Max[1][0])
    {
        result = Count[0][Max[0][0]] + Count[1][Max[1][0]];
    }
    else
    {
        result = max(Count[0][Max[0][0]] + Count[1][Max[1][1]], Count[0][Max[0][1]] + Count[1][Max[1][0]]);
    }
    printf("%d", N - result);
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,a,b;
    cin >> n >> a  >> b;
    cout << min(n*a,b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
int n,m,i,j,k,count1=0,count2=0;
using namespace std;
void ABC120(void);
void ABC121(void);
void ABC122(void);
void ABC123(void);
void ABC124(void);
void ABC125(void);
void ABC126(void);
void ABC127(void);
void ABC128(void);
void ABC129(void);

int main(void){
    ABC121();
}

void ABC121(){
    int c;
    cin>>n>>m>>c;
    vector<int> bvec(m);
    for(i=0;i<m;i++){
        cin>>bvec[i];
    }
    int sum=0,a;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a;
            sum+=a*bvec[j];
        }
        sum+=c;
        if(sum>0)count1++;
        sum=0;
    }
    cout<<count1<<endl;
}

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

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ar[3];
    ar[0]=a;
    ar[1]=b;
    ar[2]=c;
    sort(ar,ar+3);
    cout << ar[0] << " " << ar[1] << " " << ar[2] << endl;
}

Measured memory_bytes: 1180
N = int(input())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))

p_num = ""
q_num = ""
for j in range(N):
    p_num = p_num + str(p_list[j])
    q_num = q_num + str(q_list[j])
p_num = int(p_num)
q_num = int(q_num)
p_result_list = []

def perm(p, i, NUM):
    if i<NUM-1: # 脱出条件
        for j in range(i, NUM):
            # スワップ処理
            t = p[i]
            p[i] = p[j]
            p[j] = t

            # n-1個の順列
            perm(p, i+1, NUM)

            # 元に戻すスワップ処理
            t = p[i]
            p[i] = p[j]
            p[j] = t
    else:
        ans_num = ""
        for j in range(0,N):
            ans_num = ans_num + str(p[j])
        ans_num = int(ans_num)
        p_result_list.append(ans_num)

perm(p_list,0,N) # permutation generate
p_result_list = sorted(p_result_list)
p_ord = p_result_list.index(p_num) + 1
q_ord = p_result_list.index(q_num) + 1
print(abs(p_ord-q_ord))


Measured memory_bytes: 50780
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

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

   int ans =0;
   int ar[27];
   SET(ar);
   for(int i=0;i<s.size();i++){
       int br[27];
       SET(br);
       for(int j= i+1; j<s.size(); j++){
           br[s[j] - 'a']++;
       }   
       ar[s[i] - 'a']++;
       int koto =0;
       for(int j=0;j<27;j++){
           if( ar[j] && br[j])koto++;
       }
       ans = max(ans, koto);
   }

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

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<stack>
#include<cstring>
#include<map>
#include<vector>
#define ll long long int
using namespace std;
int main()
{
    char dp[105][105];
    ll m,n,i,j;
    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        cin>>dp[i][j];
    for(i=1;i<=2*n;i++)
    {
        for(j=1;j<=m;j++)
            cout<<dp[(i+1)/2][j];
        cout<<endl;
    }
}


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


map<Int, int> prime_factor(Int n) {
    map<Int, int> res;
    for(Int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
  Int A, B;
  cin >> A >> B;
  
  Int GCD;
  GCD = __gcd(A,B);
  
  cout << prime_factor(GCD).size() + 1 << endl;
}


Measured memory_bytes: 256
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    for line in readlines():
        v = int(line)
        res = []
        for i in range(10):
            if v & (1 << i):
                res.append(1 << i)
        write(" ".join(map(str, res)))
        write("\n")
solve()



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

int main(){
    int N;
    string S,T;
    cin >> N >> S >> T;

    string ans;
    rep(i,N){
        ans += S[i];
        ans += T[i];
    }

    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main{

    static final int BITS = 10;
    //Does not manage input == 1024;
    public static void main(String[] args) throws IndexOutOfBoundsException {
        
        //read from standard input
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int number = in.nextInt();
            ArrayList<Integer> numbersList = new ArrayList<>();
            
            for (int i = 0; i < BITS; i++) {
                
                //if the reminder of ((number/2) / 2) is 1
                if ((number >> i) % 2 == 1) {
                    //...then add pow(i,2) to the numbersList
                    numbersList.add(1 << i);
                }
            }
            System.out.print(numbersList.get(0));
            for (int i = 1; i < numbersList.size(); i++) {
               
                System.out.print(" " + numbersList.get(i));
                
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 26180
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n; cin>>n;
  int a[2][n];
  for(int i=0;i<n;i++) cin>>a[0][i];
  for(int i=0;i<n;i++) cin>>a[1][i];

  int an=0;
  for(int i=0;i<n;i++) {
    int sm=0;
    for(int j=0;j<n;j++) {
      if (i>j) sm+=a[0][j];
      else if (i==j) sm+=a[0][j]+a[1][j];
      else sm+=a[1][j];
    }
    an=max(an,sm);
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	N, Q := ReadInt(), ReadInt()
	xseg := MakeSegTree(N - 1)
	yseg := MakeSegTree(N - 1)
	for i := 0; i < N-1; i++ {
		xseg.Update(i, N-1)
		yseg.Update(i, N-1)
	}
	sum := 0
	for q := 0; q < Q; q++ {
		t, v := ReadInt(), ReadInt()-1
		if t == 1 {
			r := yseg.Query(v, N-1) - 1
			sum += r
			xseg.Update(r, Min(xseg.Query(r, r+1), v))
		} else {
			r := xseg.Query(v, N-1) - 1
			sum += r
			yseg.Update(r, Min(yseg.Query(r, r+1), v))
		}
	}
	fmt.Println((N-2)*(N-2) - sum)
}

type SegTree []int

const Inf = 1 << 60

func MakeSegTree(n_ int) SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	t := make([]int, n*2)
	for i := 1; i < len(t); i++ {
		t[i] = Inf
	}
	return t
}
func (t SegTree) Update(i, x int) {
	i += len(t) >> 1
	t[i] = x
	for i > 1 {
		i >>= 1
		t[i] = Min(t[i*2], t[i*2+1])
	}
}
func (t SegTree) Query(a, b int) int {
	return t.queryRecur(a, b, 1, 0, len(t)>>1)
}
func (t SegTree) queryRecur(a, b, k, l, r int) int {
	if b <= l || r <= a {
		return Inf
	}
	if a <= l && r <= b {
		return t[k]
	}
	return Min(
		t.queryRecur(a, b, k*2, l, (l+r)>>1),
		t.queryRecur(a, b, k*2+1, (l+r)>>1, r),
	)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}


Measured memory_bytes: 15336
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s); sys.stdout.write('\n')
def wi(n): sys.stdout.write(str(n)); sys.stdout.write('\n')
def wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\n')


def main():
    n = ri()
    x = rs()

    k = int(x, 2)
    d = x.count('1')
    
    if d > 1:
        k0 = k % (d-1)
    k1 = k % (d+1)

    f = [0] * (n + 1)
    for i in range(1, n+1):
        f[i] = f[i % bin(i).count('1')] + 1

    for i in range(n):
        cnt = 0
        if x[i] == '1' and d - 1 > 0:
            cnt += f[(k0 - pow(2, n - i - 1, d - 1)) % (d - 1)] + 1
        elif x[i] == '0':
            cnt += f[(k1 + pow(2, n - i - 1, d + 1)) % (d + 1)] + 1
        wi(cnt)


if __name__ == '__main__':
    main()


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

int main(){
   long long x, h;
   cin >> x >> h;
   long long a[h], i, sum=0;
   for(i=0; i< h; i++){
      cin >> a[i];
      sum=sum+a[i];
   }
   if(sum<x)cout<<"No"<<endl;
   else cout << "Yes"<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  int n = s.size();
  vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(K+1, vector<int>(2, 0)));

  dp.at(0).at(0).at(0) = 1;
  rep(i, n)rep(j, K+1)rep(k, 2){
    rep(m, 10){
      int ni = i+1, nj = j, nk = k;
      if(m != 0)nj++;
      if(nj > K) continue;
      if(nk == 0){
        if(m < (s.at(i) - '0')) nk = 1;
        if(m > (s.at(i) - '0'))continue;
      }
      // if(dp.at(i).at(j).at(k) == 1){
      //   cout << "tt:" << ni << " " << nj << " " << nk << " " << m << endl;
      // }
      dp.at(ni).at(nj).at(nk) += dp.at(i).at(j).at(k);
    }
  }
  
  // rep(i, n+1){
  //   rep(j, K+1){
  //     cout << dp.at(i).at(j).at(0) << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // rep(i, n+1){
  //   rep(j, K+1){
  //     cout << dp.at(i).at(j).at(1) << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  int ans = dp.at(n).at(K).at(0) + dp.at(n).at(K).at(1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "1222" ].parse.expand.solve == "1+2+2+2=7" );
	assert( [ "0290" ].parse.expand.solve == "0-2+9+0=7" );
//	assert( [ "3242" ].parse.expand.solve == "3+2+4-2=7" );
	assert( [ "3242" ].parse.expand.solve == "3-2+4+2=7" );		// 別解
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto cs = input.front.strip.to!( dchar[] );
	return tuple( cs );
}

auto solve( dchar[] cs )
{
	auto ns = cs.map!( ( a ) => ( a - '0' ) );
	
	foreach( ops; genOps( 3 ) )
	{
		auto s = [ cs[ 0 ] ];
		auto t = ns[ 0 ];
		
		foreach( op, c, n; lockstep( ops, cs[ 1 .. $ ], ns[ 1 .. $ ] ) )
		{
			s ~= [ op, c ];
			switch( op )
			{
				case '+': t += n; break;
				case '-': t -= n; break;
				default : assert( false );
			}
		}
		
		if( t == 7 ) return s ~ "=7";
	}
	
	assert( false );
}

auto genOps( long n )
{
	dchar[][] opss = [ [ '+' ], [ '-' ] ];
	
	foreach( i; 0 .. n - 1 )
	{
		foreach( k; 0 .. opss.length )
		{
			opss ~= opss[ k ].dup;
			opss[ k ] ~= '+';
			opss[ $ - 1 ] ~= '-';
		}
	}
	
	return opss;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
#define int long long
using namespace std;
int n,m,a[N];
char c[N];
long long ans;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=-n+1;i<=n-1;i++){
		int t=m+i;
		if(abs(t)<=1000000)printf("%lld ",t);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)-1
a = [1]+[0]*n
b = [0]+[1]*n
difA = 0
difB = 0

for i in range(1,n+1):
    a[i] = 0 if a[i-1] == 1 else 1
    b[i] = 0 if b[i-1] == 1 else 1

for j in range(n+1):
    if a[j] != int(s[j]):
        difA += 1
    if b[j] != int(s[j]):
        difB += 1

ans = min(difA,difB)

print(ans)

Measured memory_bytes: 6172
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int N;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;

	int ans = 0;
	if (N%2==0) {
		ans = N/2 -1;
	}
	else {
		ans = N/2;
	}

	cout << ans << endl;

	return 0;
}




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

void die() {
    cout << "NO\n";
    exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.size();
    reverse(s.begin(), s.end());
    int pos = 0;
    while (pos < n) {
        if (n - pos >= 5 && s.substr(pos, 5) == "maerd") {
            pos += 5;
            continue;
        }
        if (n - pos >= 5 && s.substr(pos, 5) == "esare") {
            pos += 5;
            continue;
        }
        if (n - pos >= 7 && s.substr(pos, 7) == "remaerd") {
            pos += 7;
            continue;
        }
        if (n - pos >= 6 && s.substr(pos, 6) == "resare") {
            pos += 6;
            continue;
        }
        die();
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 512
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = 0
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))

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

using namespace std;

int main() {
    int N;

    cin >> N;
    vector<int> a(N);
    vector<int> sorted_a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sorted_a[i] = a[i];
    }
    sort(sorted_a.begin(), sorted_a.end());

    int max = sorted_a[N-1];
    int pre_max = sorted_a[N-2];

    for (int i = 0; i < N; i++) {
        if (a[i] == max) {
            cout << pre_max << endl;
        } else {
            cout << max << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3200
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1,k+1):
        if i<n-j:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])

Measured memory_bytes: 56928
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

	int H, W;
	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}




Measured memory_bytes: 2060
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
switch(n){
case 1: printf("1"); break;
case 2: printf("3"); break;
case 3: printf("4"); break;
case 4: printf("7"); break;
case 5: printf("11"); break;
case 6: printf("18"); break;
case 7: printf("29"); break;
case 8: printf("47"); break;
case 9: printf("76"); break;
case 10: printf("123"); break;
case 11: printf("199"); break;
case 12: printf("322"); break;
case 13: printf("521"); break;
case 14: printf("843"); break;
case 15: printf("1364");  break;
case 16: printf("2207"); break;
case 17: printf("3571"); break;
case 18: printf("5778"); break;
case 19: printf("9349"); break;
case 20: printf("15127"); break;
case 21: printf("24476"); break;
case 22: printf("39603"); break;
case 23: printf("64079"); break;
case 24: printf("103682"); break;
    
case 35: printf("20633239"); break;
    
case 42: printf("599074578"); break;
case 51: printf("45537549124"); break;
case 62: printf("9062201101803"); break;
case 79: printf("32361122672259149"); break;
case 85: printf("580696784543856761"); break;
case 86: printf("939587134549734843"); break;
default: break;
}
return 0;
}


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

const int MAXN = 5005;
const int MOD = 1e9 + 7;

int N;
vector <int> E[MAXN];
int fact[MAXN], choose[MAXN][MAXN];
int sz[MAXN];
int centroid;
int mini = MAXN;
int dp[MAXN][MAXN];

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
}

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
	else if (x < 0)
		x += MOD;
	return x;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i < MAXN; i++)
		fact[i] = mul(fact[i - 1], i);
	
	choose[0][0] = 1;
	for (int i = 1; i < MAXN; i++) {
		choose[i][0] = 1;
		for (int j = 1; j <= i; j++)
			choose[i][j] = add(choose[i - 1][j], choose[i - 1][j - 1]);
	}
}

void dfs(int x, int p) {
	sz[x] = 1;
	int mx = 0;
	for (auto it : E[x])
		if (it != p) {
			dfs(it, x);
			mx = max(mx, sz[it]);
			sz[x] += sz[it];
		}
	mx = max(mx, N - sz[x]);
	if (mx < mini) {
		mini = mx;
		centroid = x;
	}
}

int go(int x, int p) {
	int res = 1;
	for (auto it : E[x])
		if (it != p)
			res += go(it, x);
	return res;
}

int solve() {
	dfs(1, 0);
			
	vector <int> a;
	a.push_back(0);
	for (auto it : E[centroid]) 
		a.push_back(go(it, centroid));
	
	int K = a.size();
	dp[0][0] = 1;
	for (int i = 1; i < K; i++) 
		for (int j = 0; j < N; j++)
			for (int k = 0; k <= a[i] && k <= j; k++) 
				dp[i][j] = add(dp[i][j], mul(dp[i - 1][j - k], mul(mul(choose[a[i]][k], choose[a[i]][k]), fact[k])));
	
	int sol = 0;
	for (int i = 0; i < N; i++) {
		int tmp = mul(fact[N - i], dp[K - 1][i]);
		sol = add(sol, i % 2 ? -tmp : tmp);
	}
	
	return sol;
}

int main() {
	init();
	load();
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 196352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int N;
vi A;
vi dst;
vvi G;
vi dp;

struct Log {
  int from,to,pos;
  Log(int f,int t,int p): from(f),to(t),pos(p) {}
};

stack<Log> st;

void dfs(int k,int p=-1) {
  int pos = lower_bound(rng(dp),A[k])-dp.begin();
  Log l(dp[pos],A[k],pos);
  st.push(l);
  dp[pos] = A[k];
  dst[k] = (lower_bound(rng(dp),INF)-dp.begin());
  for(int q:G[k]) {
    if(q==p) continue;
    dfs(q,k);
    Log last = st.top();
    st.pop();
    dp[last.pos]=last.from;
  }
}
  
int main() {
  cin >> N;
  A = vi(N);
  rep(i,N) {
    cin >> A[i];
  }
  G = vvi(N);
  rep(i,N-1) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dst = vi(N);
  dp = vi(N,INF);
  dfs(0);
  rep(i,N) {
    cout << dst[i] << endl;
  }
  return 0;
}

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

#define int long long
int numB , numW , sumB , sumW; char str[200003];

signed main(){
	scanf("%s" , str + 1); int L = strlen(str + 1);
	for(int i = 1 ; i <= L ; ++i)
		if(str[i] == 'W') sumB += i - ++numB;
		else sumW += L - numW++ - i;
	cout << (sumB + sumW) / 2 << endl;
	return 0;
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	cin.ignore();
	int passed = 0;
	int overseas = 0;
	for (int i = 0; i < N; i++) {
		char ch;
		cin >> ch;
		if (ch != 'c' && passed < A + B && (ch == 'a' || overseas < B)) {
			cout << "Yes" << endl;
			++passed;
			if (ch == 'b') {
				++overseas;
			}
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

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

	if (a * b % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

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

ll A[101010];
ll L[101010];
ll R[101010];

int main(){
    
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    L[1] = A[1];
    for(int i = 2; i <= n; i++)L[i] = gcd(L[i-1], A[i]);
    R[n] = A[n];
    for(int i = n-1; i >= 1; i--)R[i] = gcd(R[i+1], A[i]);
    
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        if(i == 1)ans = max(ans, R[2]);
        else if(i == n)ans = max(ans, L[n-1]);
        else{
            ans = max(ans, gcd(L[i-1], R[i+1]));
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        sc.close();
        long c = gcd(a, b);
        int d = 0;
        for (int i = 2 ; i <= Math.sqrt(c) ; i++) {
            if (c % i == 0) {
                d++;
                while (c % i == 0) {
                    c /= i;
                }
            }
        }
        if (c > 1) d++;

        System.out.println(d + 1);


    }

    static long gcd(long a, long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }

}


Measured memory_bytes: 23252