akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

/*
 * k
 * t1 t2
 * if t1 + k < t2 ans += k
 * else ans += (t2 - t1)
 */

int main() {
	int n, k;
	cin >> n >> k;
	vector <int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	ll ans = 0;
	for (int i = 0; i + 1 < n; i++) {
		ans += min(k, A[i + 1] - A[i]);
	}
	cout << ans + k;	
}


Measured memory_bytes: 1152
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include<iostream>
using namespace std;

int main(){

	int x,y;

	while(1){
		cin>>x>>y;
		if(x==0 && y==0)break;
		if(x>y){
			cout<<y<<" "<<x<<endl;
		}else{
		cout<<x<<" "<<y<<endl;
		}

	}

	return 0;
}







Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    String strA = scan.next();
    String strB = scan.next();
    
    int a = Integer.parseInt(strA);
    int b = Integer.parseInt(strB);
    
    int c = a + b;
    
    if (c % 2 == 0) {
      System.out.print(c / 2);
    } else {
      System.out.print("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 21460
#include<stdio.h>


int main(){

  int x, y, a, i;

  while(1){
    scanf("%d %d", &x, &y);
    if(x==0 && y==0) break;

    if(x<y){
      a=y;
      y=x;
      x=a;
    }

    for(i=0;;i++){
      x=x%y;
      a=x;
      x=y;
      y=a;
      if(y==0) break;
    }

    printf("%d %d\n", x, i+1);

  }
  return 0;
}

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

int main(){
  long long a,b,ca,cb,i,j,cur,ans=0,bi;
  cin >> a >> b;
  if(a!=0) a-=1;
  
  vector<long long> bia(41),bib(41),bians(41);
  /*
  ca=a; cb=b;
  for(i=0; i<41; i++){
    bia[i]=ca%2; ca/=2;
    bib[i]=cb%2; cb/=2;
  }
  */
  if((a%4 == 1) || (a%4 == 2)){
    bia[0]=1;
  }else{
    bia[0]=0;
  }
  if((b%4 == 1) || (b%4 == 2)){
    bib[0]=1;
  }else{
    bib[0]=0;
  }
  if(bia[0]+bib[0]==1){
    ans++;
  }
  
  bi=2;
  for(i=1; i<41; i++){
    bi*=2;
    if((a%bi >= bi/2) && (a%2 == 0)){
      bia[i]=1;
    }else{
      bia[i]=0;
    }
    if((b%bi >= bi/2) && (b%2 == 0)){
      bib[i]=1;
    }else{
      bib[i]=0;
    }
    
    if(bia[i]+bib[i]==1){
      ans+=bi/2;
    }
  }
  /*
  for(i=0; i<41; i++){
    cout << bia[i] << ' ';
  }
  cout << endl;
  for(i=0; i<41; i++){
    cout << bib[i] << ' ';
  }
  cout << endl;
  */
  
  cout << ans;
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

const ll INF = 1LL << 50;

ll C[22], X[20202];
ll dp[20202][256];

void solve(int n, int m) {
    for (int i = 0; i < m; i++) cin >> C[i];
    for (int i = 1; i <= n; i++) cin >> X[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 255; j++) dp[i][j] = INF;
    }
    dp[0][128] = 0;
    for (int i = 0; i < n; i++) {
        for (ll j = 0; j <= 255; j++) {
            if (dp[i][j] == INF) continue;
            for (int k = 0; k < m; k++) {
                ll next_num = min(max(j + C[k], 0LL), 255LL);
                dp[i + 1][next_num] = min(dp[i][j] + (X[i + 1] - next_num) * (X[i + 1] - next_num), dp[i + 1][next_num]);
            }
        }
    }
    ll ans = INF;
    for (ll i = 0; i <= 255; i++) {
        ans = min(ans, dp[n][i]);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    while (true) {
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        solve(N, M);
    }
    return 0;
}


Measured memory_bytes: 43248
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt(),m=sc.nextInt(),X=sc.nextInt(),Y=sc.nextInt();
		Integer[] Amap=new Integer[n],Bmap=new Integer[m];

		for(int i=0;i<n;i++) {
			Amap[i]=sc.nextInt();
		}
		for(int i=0;i<m;i++) {
			Bmap[i]=sc.nextInt();
		}

		Arrays.sort(Amap,Collections.reverseOrder());
		Arrays.sort(Bmap);

		if(X<=Amap[0] && Amap[0]<=Y) {
			if(X<=Bmap[0] && Bmap[0]<=Y) {
				if(Amap[0]<Bmap[0]) {
					System.out.println("No War");
					return;
				}
			}
		}
		System.out.println("War");
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


class BIT:
    def __init__(self, n: int):
        self.tr = [0] * (n + 1)

    def add(self, n: int, v: int):
        while n < len(self.tr):
            self.tr[n] += v
            n += n & -n

    def cumsum(self, n: int):
        ans = 0
        while n > 0:
            ans += self.tr[n]
            n -= n & -n
        return ans


def solve(N: int, a: "List[int]"):

    def f(m):
        s = [0] * (N + 1)
        for i, ai in enumerate(a):
            s[i + 1] = s[i] + (-1 if ai < m else 1)
        ms = min(s)
        b = BIT(max(s) - ms + 1)
        t = 0
        for si in s:
            t += b.cumsum(si - ms + 1)
            b.add(si - ms + 1, 1)
        return t >= -(-(N * (N + 1) // 2) // 2)

    lb = 0
    rb = max(a) + 1
    while lb + 1 < rb:
        m = (lb + rb) // 2
        if f(m):
            lb = m
        else:
            rb = m

    print(lb)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 106144
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/01 06:28:04 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	n, limit;
	cin >> n >> limit;
	vector<int>	dp(limit + 1);
	rep(i, n)
	{
		int	v, w;
		cin >> v >> w;
		rrep(j, min(limit, (limit - w)))
			dp.at(j + w) = max(dp.at(j + w), dp.at(j) + v);
	}
	cout << dp.back() << endl;
}
// END

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



Measured memory_bytes: 3240
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void) {

	int a, b, k,sei[1000],num=0;

	cin >> a >> b >> k;

	for (int l = 1; l <= min(a,b); l++) {
		if (a>=l&&b>=l&&a%l == 0 && b%l == 0) {
			sei[num] = l;
			//printf("l=%d\nsei[%d]=%d\n", l, num, l);
			num++;
		}
	}

	cout << sei[num - k] << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;

int a[3][3];

int main() {
    for (int i = 0; i < 9; i++) cin >> a[i / 3][i % 3];
    int n, b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if (a[j / 3][j % 3] == b) a[j / 3][j % 3] = 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        int col = 0, row = 0;
        for (int j = 0; j < 3; j++) {
            col += a[j][i], row += a[i][j];
        }
        if (col == 0 || row == 0) {
            puts("Yes");
            return 0;
        }
    }
    if (a[0][0] + a[1][1] + a[2][2] == 0 || a[0][2] + a[1][1] + a[2][0] == 0) {
        puts("Yes");
        return 0;
    }
    puts("No");
}


Measured memory_bytes: 3632
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float("inf")] * N
dp[0] = 0

for i in range(N):
  for k in range(1,K+1):
    if i + k < N:
      dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))

print(dp[-1])

Measured memory_bytes: 55264
n = int(input())
taegrt = ["3","5","7"]
ans = 0
count_num = []

def dfs(s):
    global count_num
    global taegrt
    global ans 
    for val in taegrt:
        tmp = s+val
        if int(tmp) > n:
            return
        if tmp in count_num:
            continue
        count_num.append(tmp)
        #print(tmp)
        if "7" in list(tmp) and "5" in list(tmp) and "3" in list(tmp):
            ans += 1
        dfs(tmp)

for i in taegrt:
    dfs(i)

print(ans)


Measured memory_bytes: 57180
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(a[k]<a[j]+a[i]) ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<ll>> a(110000,vector<ll>(3));
  vector<vector<ll>> dp(110000,vector<ll>(3));
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      cin>>a.at(i).at(j);
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(j==k)continue;
        dp.at(i+1).at(k)=max(dp.at(i+1).at(k),dp.at(i).at(j)+a.at(i).at(j));
      }
    }
  }
  ll ans=0;
  for(int i=0; i<3; i++){
    ans=max(ans,dp.at(N).at(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15408
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N;
  cin >> N;
  int ma = 0;
  int po = 0;
  rep(i, N)
  {
    int a, b;
    cin >> a >> b;
    if (ma < a) {
      ma = a;
      po = b;
    }
  }
  cout << ma + po << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N=10e5;
struct P{int maxs,num;};
pair<int,int > A[MAX_N+1];
P B[MAX_N+1];
bool C[MAX_N+1];
stack <int>D;


int main(void){
	int N,K;
		cin >> N >> K;
	memset(B,-1,sizeof(B));
	for(int i=0;i<N;i++){
		int s,o;
			cin >> s >> o;
		s--;
		A[i].first=o*-1;
		A[i].second=i;
		if(B[s].maxs<o){
			B[s].maxs=o;
			B[s].num=i;
		}
	}
	for(int i=0;i<N;i++){
		if(B[i].num==-1)continue;
		C[B[i].num]=true;
	}
	sort(A,A+N);
	
	
	
	long long res=0,typer=0;
	for(int i=0;i<K;i++){
		res+=(long long)A[i].first*(-1);
		typer+=C[A[i].second];
		if(!C[A[i].second])
			D.push(A[i].first);
	}
	long long ans=res+typer*typer;
	for(int i=K;i<N && D.size();i++){
		if(C[A[i].second]){
			res-=D.top()*(-1);
			res+=(long long)A[i].first*(-1);
			D.pop();
			typer++;
			ans=max(ans,res+typer*typer);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll H,W;
    cin >> H >> W;
    vc<string> S(H);
    rep(i, H) cin >> S[i];

    ll cnt=0;
    rep(i,H)rep(j,W){
        if (S[i][j] == '#') cnt++;
    }
    cout << (cnt == H + W - 1 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(a) (int)(a.size())
#define all(a) begin(a), end(a)
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

const int MAX = 1e6 + 5;

lli dp[4][MAX];

lli n;

lli MOD = 1e9 + 7;

lli solve(lli u, lli v) {
    if(v == n) return u == 3;
    lli &ans = dp[u][v];
    if(ans != -1) return ans;
    ans = 0;
    ans = (ans + solve(u | 1, v + 1)) % MOD;
    ans = (ans + solve(u | 2, v + 1)) % MOD;
    fore(i, 1, 9) {
         ans = (ans + solve(u, v + 1))% MOD;
    }
    return ans;
}

int main()
{   _
    cin >> n;
    lli u = 1, v = 0, w = 0, wv = 0;
    fore(i, 0, n) {
        wv = (wv * 10) % MOD;
        wv = (w + v + wv) % MOD;
        w = (w*9 + u) % MOD;
        v = (v*9 + u) % MOD;
        u = (u * 8) % MOD;
    }
   cout << wv << ENDL;
   /// cout << solve(0, 0) << ENDL;
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;



public class Main {

	
	public static int lengthOfSub(String x, String y) {
		int max = 0;
		
		//initialize the table
		int[][] matches = new int[x.length()+1][y.length()+1];
		
		//for(int i = 0; i < x.length(); i++) { matches[i][0] = 0;}
		//for(int j = 0; j < y.length(); j++) { matches[0][j] = 0;}
		//now fill in the table
		
		for(int i = 0; i <= x.length(); i++) {
			for(int j = 0; j <= y.length(); j++) {
				//base case
				if( j == 0 || i == 0) {
					matches[i][j] = 0;
				}
				else if(x.charAt(i-1) == y.charAt(j-1)) {
					matches[i][j] = matches[i-1][j-1] + 1;
				}else {
					matches[i][j] = max(matches[i-1][j], matches[i][j-1]);
				}
				
				if(matches[i][j] > max) {
					max = matches[i][j];
				}
			}
		}
		
		return max;
		
	}
	
	private static int max(int i, int j) {
		if (i > j) return i;
		else if (i == j) return i;
		else return j;
		
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int reps = in.nextInt();
		
		for(int i = 0; i < reps; i++) {
			String x = in.next();
			String y = in.next();

			System.out.println(lengthOfSub(x,y));
		}
		
		in.close();

	}

}



Measured memory_bytes: 65008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[3009],dp[3009][3009];
ll best(ll l,ll r,bool b)
{
    if(r<l)return 0;
    ll &ret=dp[l][r];
    if(ret!=LLONG_MAX)
    return ret;
    if(b)
    return ret=max(best(l+1,r,0)+a[l],best(l,r-1,0)+a[r]);
    return ret=min(best(l+1,r,1)-a[l],best(l,r-1,1)-a[r]);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=0;i<n;i++)
    cin>>a[i];
for(ll i=0;i<=n;i++)
for(ll j=0;j<=n;j++)
dp[i][j]=LLONG_MAX;
cout<<best(0,n-1,1);
return 0;
}


Measured memory_bytes: 74348
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;
int a[maxn];

void solve() {
    int n;
    cin >> n;
    int tot = 0;
    rep(i, 1, n)cin >> a[i], tot ^= a[i];;
    rep(i, 1, n)cout << (a[i] ^ tot) << ' ';
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 5180
#include<iostream>
#include<string>
using namespace std;
int main(){
   int A,B,C,X,Y,ans;
   cin >> A >> B >> C >> X >> Y;
   if(A+B<2*C){
     ans=A*X+B*Y;
   }else{
     if(X<=Y){
       if(B<2*C){
         ans=2*C*X+B*(Y-X);
       }else{
         ans=2*C*Y;
       }
     }
     if(X>Y){
       if(A<2*C){
         ans=2*C*Y+A*(X-Y);
       }else{
         ans=2*C*X;
       }
     }
   }
   cout <<ans;
   return 0;
}

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

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int x = Integer.parseInt(br.readLine());
			System.out.println(x*x*x);
		} catch (Exception e) {
			System.exit(0);
		}
	}
}

Measured memory_bytes: 24208
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int d[25][25][25][25];
char c[25][25];
int d1[4]={0,0,1,-1};
int d2[4]={1,-1,0,0};
queue<int> q; 
bool ok(int x,int y)
{
	return x>=0 && y>=0 && x<n && y<m && c[x][y]=='.';
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			cin >>c[i][j];
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<m;j++)
		{
			if (c[i][j]=='#') continue;
			//cout <<i<<" "<<j<<" ###\n";
			for (int ii=0;ii<n;ii++)
				for (int jj=0;jj<m;jj++)
					d[i][j][ii][jj]=-1;
			d[i][j][i][j]=0;
			q.push(i),q.push(j);
			while (!q.empty())
			{
				int x=q.front(); q.pop();
				int y=q.front(); q.pop();
				//cout <<x<<" "<<y<<" "<<d[i][j][x][y]<<" $$\n"; 
				for (int k=0;k<4;k++)
				{
					int xi=x+d1[k],yi=y+d2[k];
					if (ok(xi,yi) && d[i][j][xi][yi]==-1)
					{
						d[i][j][xi][yi]=d[i][j][x][y]+1;
						q.push(xi); q.push(yi);
					}
				}
			}
		}
	}
	int res=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			for (int ii=0;ii<n;ii++)
				for (int jj=0;jj<m;jj++)
				{
					res=max(res,d[i][j][ii][jj]);
					//if (d[i][j][ii][jj]==9) cout <<i<<" "<<j<<" "<<ii<<" "<<jj<<"\n";
				}	
	cout <<res;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

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

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

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

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

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

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
    int n, x; cin >> n >> x;
    vector<int> a(n + 2);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i + 1] + a[i] - x;
            a[i + 1] = x - a[i];
        }
        debug(a);
    }
    cout << ans;

}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
const int mod = 1e9+7;
const int maxn = 1e5+5;
const double eps = 1e-6;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	if(k==0) return printf("%lld\n",n*n),0;
	ll ans = 0;
	rep(b,k+1,n+1){
		ll cnt = n/b;
		ans = ans + cnt*(b-k);
		if(cnt*b+k>n) continue;
		ans = ans + n - (cnt*b+k)+1;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) {
		Reader rd = new Reader();
		int n = rd.nextInt();
		int k = rd.nextInt();
		int[] h = new int[n+1];
		h[0] = 0;
		for(int nn=1; nn<n+1; nn++){
			h[nn] = rd.nextInt();
		}
		int[] dp = new int[n+1];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		dp[1] = 0;
		dp[2] = Math.abs(h[2]-h[1]);
		for(int nn=3; nn<=n;nn++){
			int val = 1;
			while(val <= k && nn-val >= 1){
				dp[nn] = Math.min(dp[nn], Math.abs(h[nn]-h[nn-val]) + dp[nn-val]);
				val++;
			//System.out.println(Arrays.toString(dp) + " " + val);
			}
			//System.out.println(Arrays.toString(dp));
		}
		System.out.println(dp[n]);
	}

	static void sort(int[] ar){
		ArrayList<Integer> ls = new ArrayList<>();
		for(int i=0; i<ar.length; i++) ls.add(ar[i]);
		Collections.sort(ls);
		for(int i =0; i<ls.size(); i++) ar[i] = ls.get(i);
	}
}

class Reader { 
	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer tok = new StringTokenizer("");
	static String next() {
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(bf.readLine());
			}
			catch(IOException e) {
				e.printStackTrace();
			}
		}
		return tok.nextToken();
	} 
	static int nextInt() {
		return Integer.parseInt(next());
	}
}


Measured memory_bytes: 44436
#include <stdio.h>
int main(){
  int A[100],i,j,k,l,N;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=N-1;i++){
    for(k=0;k<N;k++){
      printf("%d",A[k]);
      if(k!=N-1)
	printf(" ");
    }
    printf("\n");
    l=A[i];
    j=i-1;
    while(j>=0&&A[j]>l){
      A[j+1]=A[j];
      j=j-1;
      A[j+1]=l;
    }
  }
  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k!=N-1)
      printf(" ");
  }
  printf("\n");
  return 0;
} 

Measured memory_bytes: 604
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()

cnt = 0
ans = 0
for j in range(1,n+1,2):
	for i in range(1,j+1):
		if j%i == 0:
			cnt += 1
	if cnt == 8:
		ans += 1
	cnt = 0
print(ans)

Measured memory_bytes: 8860
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long r;
    cin >> r ;
    long long t=100;
    long long f=0;
    for (int i=0; i<=3760; ++i)
    {
        f=i;
        t=t+t/100;
        if (t>=r)
            break;
    }
    cout << f+1 << endl;
}

Measured memory_bytes: 3672
a,b,c,x,y = gets.split.map(&:to_i)

array=[]
array << a*x+b*y
array << 2*c*[x,y].max
if x > y
  array << 2*c*[x,y].min + (x-y) * a
else
  array << 2*c*[x,y].min + (y-x) * b
end

puts array.min

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

type IntSlice []int

func (p IntSlice) Len() int {
	return len(p)
}

func (p IntSlice) Less(i, j int) bool {
	return p[i] > p[j]
}

func (p IntSlice) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

type IntHeap [][]int

func (p IntHeap) Len() int {
	return len(p)
}

func (p IntHeap) Less(i, j int) bool {
	return p[i][0] > p[j][0]
}

func (p IntHeap) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p *IntHeap) Push(x interface{}) {
	*p = append(*p, x.([]int))
}

func (p *IntHeap) Pop() interface{} {
	old := *p
	n := len(old)
	ret := old[n - 1]
	*p = old[:n - 1]
	return ret
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)

	/* 単語ごとに入力するならこれ */
	sc.Split(bufio.ScanWords)

	sc.Scan()
	X, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	Y, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	Z, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	K, _ := strconv.Atoi(sc.Text())

	a := make([]int, X)
	b := make([]int, Y)
	c := make([]int, Z)

	for i := 0; i < X; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	for i := 0; i < Y; i++ {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
	}

	for i := 0; i < Z; i++ {
		sc.Scan()
		c[i], _ = strconv.Atoi(sc.Text())
	}

	sort.Sort(IntSlice(a))
	sort.Sort(IntSlice(b))
	sort.Sort(IntSlice(c))

	h := &IntHeap{}

	heap.Init(h)
	var done [1000][1000][1000]bool

	var i, j, k int
	heap.Push(h, []int{a[i] + b[j] + c[k], i, j, k})
	done[i][j][k] = true
	for l := 0; l < K; l++ {
		p := heap.Pop(h).([]int)
		_, _ = fmt.Fprintf(stdout, "%v\n", p[0])
		i, j, k = p[1], p[2], p[3]
		if i < X - 1 && !done[i + 1][j][k] {
			heap.Push(h, []int{a[i + 1] + b[j] + c[k], i + 1, j, k})
			done[i + 1][j][k] = true
		}
		if j < Y - 1 && !done[i][j + 1][k] {
			heap.Push(h, []int{a[i] + b[j + 1] + c[k], i, j + 1, k})
			done[i][j + 1][k] = true
		}
		if k < Z - 1 && !done[i][j][k + 1] {
			heap.Push(h, []int{a[i] + b[j] + c[k + 1], i, j, k + 1})
			done[i][j][k + 1] = true
		}
	}
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 895872
unittest
{
	assert( [ "4", "1 2 3 4", "3", "1 2", "3 4", "2 4" ].solve == "11\n12\n16" );
	assert( [ "4", "1 1 1 1", "3", "1 2", "2 1", "3 5" ].solve == "8\n4\n4" );
	assert( [ "2", "1 2", "3", "1 100", "2 100", "100 1000" ].solve == "102\n200\n2000" );
}



import std.conv;
import std.range;
import std.stdio;

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto q = input.front.to!( long );
	auto bcs = new long[ 2 ][ q ];
	foreach( ref bc; bcs )
	{
		input.popFront;
		bc = input.front.split.to!( long[] );
	}
	
	auto t = 0L;
	auto ds = new long[ 1 + 10L ^^ 5 ];
	foreach( a; as )
	{
		t += a;
		ds[ a ]++;
	}
	
	auto anss = new long[ bcs.length ];
	foreach( ref ans, bc; lockstep( anss, bcs ) )
	{
		t = t - bc[ 0 ] * ds[ bc[ 0 ] ] + bc[ 1 ] * ds[ bc[ 0 ] ];
		ds[ bc[ 1 ] ] += ds[ bc[ 0 ] ];
		ds[ bc[ 0 ] ] = 0;
		ans = t;
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 15568
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int A[N];
    for(int i=0; i<N; i++)
        cin >> A[i];
    
    int n = 0;
    
    for(int i=0; i<N; i++){
        while(1){
            if(A[i]%2 == 0){
                n++;
                A[i] /= 2;
            }
            else
                break;
        }
    }
    
    cout << n << endl;
}


Measured memory_bytes: 256
import numpy as np

N, D = map(int, raw_input().split(' '))

nizyo = np.array(range(1, 127))
nizyo = nizyo ** 2
X = []
for i in range(N):
    X.append(map(int, raw_input().split(' ')))

count = 0
for j in range(1, N):
    for k in range(j):

        if j > k:

            d = np.sum( (np.array(X[k]) - np.array(X[j])) **2)
            
            if d in nizyo:
                count += 1
            
print(count)


Measured memory_bytes: 16260
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define _rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define SF scanf
#define PF printf
int l,r,d,ans;
int  main(){
	SF("%d%d%d",&l,&r,&d);
	_rep(i,l,r){
		if(i%d==0)ans++;
	}
	PF("%d",ans);
	return 0;
}

Measured memory_bytes: 1680
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, sum, last, cnt, ans, a;
string str,ss;
struct Edge { LL to, cost; };
vector<LL>v;
bool f;
char c;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m >> k >> h;
	rep(i, n+1)rep(j, m+1) {
		if ((h - (i * 500 + j * 100)) >=0&&(h - (i * 500 + j* 100)) % 50 == 0 && (h - (i * 500 + j * 100)) / 50 <= k)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 100030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int dp[N];
int n,k;

int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>k;
vector<int> arr(n);
rep(i,0,n)
cin>>arr[i];
rep(i,0,k+1)
{
	for(auto x:arr)
	{
		if(i-x>=0&&!dp[i-x])
		{

			dp[i]=1;
		}
	}
}
if(dp[k])
cout<<"First";
else
cout<<"Second";


}

Measured memory_bytes: 640
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  as <- map read . words <$> getLine :: IO [Integer]                                                                                                  
  let (c,a,b) = solve as 0 0 1000000000                                                                                                               
  print $ if even c then a else a - 2 * b                                                                                                             
                                                                                                                                                      
solve :: [Integer] -> Int -> Integer -> Integer -> (Int,Integer,Integer)                                                                              
solve [] c a b = (c,a,b)                                                                                                                              
solve (x:xs) c a b                                                                                                                                    
  | x >= 0 && x < b = solve xs c (a + x) x                                                                                                            
  | x >= 0 && x >= b = solve xs c (a + x) b                                                                                                           
  | x < 0 && (-x) < b = solve xs (c + 1) (a - x) (-x)                                                                                                 
  | x < 0 && (-x) >= b = solve xs (c + 1) (a - x) b  

Measured memory_bytes: 40188
#include <iostream>
#include <algorithm>
#include <cstdio>

int bus[201];

int main(){
    int n, m;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        int h, m;
        std::cin >> h >> m;
        bus[i] = h * 60 + m;
    }
    std::cin >> m;
    for(int i = n; i < n + m; i++){
        int h, m;
        std::cin >> h >> m;
        bus[i] = h * 60 + m;
    }
    std::sort(bus, bus + n + m);
    printf("%d:%02d", bus[0] / 60, bus[0] % 60);
    for(int i = 1; i < m + n; i++){
        if(bus[i] != bus[i - 1])printf(" %d:%02d", bus[i] / 60, bus[i] % 60);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200009];
int main()
{
    ll n,t,m,x,y,i,j,k,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0;
    map<ll,ll>mp;
    map<ll,ll> :: iterator it;
    cin>>n>>k;
    for(i = 0 ;i<n ;i++)
    {
        cin>>x>>y;
        mp[x]+=y;
    }
    for(it = mp.begin();it!=mp.end() ;it++)
    {
        sum+=it->second;
        if(sum>=k)
        {
            x=it->first;
            break;
        }
    }
    cout<<x<<endl;
    return 0;

}



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

int main() {
  int N, K; cin >> N >> K;
  int p; double e, C[N+1]; C[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> p; e = (double)(p + 1) / 2;
    C[i+1] = C[i] + e;
  }
  
  double max_dif = 0;
  for (int i = 0; i <= N-K; i++) {
    max_dif = max(max_dif, C[i+K] - C[i]);
  }
  cout << setprecision(10) << max_dif << endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
S = input().replace("01", "0 1").replace("10", "1 0").split()
S = [""]*("0" in S[0])+S+[""]*("0" in S[-1])
*L, = map(len, S)
A = [sum(L[:2*k+1])]
for i in range(0, len(S)-2*k-1, 2):
    A += A[-1]-L[i]-L[i+1]+L[i+2*k+1]+L[i+2*k+2],
print(max(A))

Measured memory_bytes: 6116
def c_sum_of_gcd_of_tuples_easy():
    import numpy as np
    K = int(input())

    r = np.arange(1, K + 1)
    return np.gcd.outer(np.gcd.outer(r, r), r).sum()

print(c_sum_of_gcd_of_tuples_easy())

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 H, W;
        while(cin >> H >> W && !(H == 0 && W == 0)){
            _rep(i, H) { _rep(j, W) { cout << "#"; } cout << endl; } cout << endl;
        }
    }
    return 0;
}


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

ll dfs(const string& s, bitset<9> plus_pos)
{
    for (ll i = 0; i < (ll)s.size() - 1; ++i) {
        if (plus_pos.test(i)) {
            return stoll(s.substr(s.size() - 1 - i))
                + dfs(s.substr(0, s.size() - 1 - i), plus_pos >> (i + 1));
        }
    }

    return stoll(s);
}

void main_()
{
    string S;
    cin >> S;

    ll ans = 0;
    for (ll i = 0; i < (1 << (S.size() - 1)); ++i) {
        ans += dfs(S, i);
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList <String> cityNames = new ArrayList<String>();
        ArrayList <Integer> scores = new ArrayList<Integer>();
        ArrayList <String> dictionary = new ArrayList<String>(); 
        for(int i = 0; i < n; i++){
            String temp = sc.next();
            String cityName = temp;
            temp = sc.next();
            int score = Integer.parseInt(temp);
            if(!cityNames.contains(cityName)){
                dictionary.add(cityName);
            }
            cityNames.add(cityName);
            scores.add(score);
        }
        Collections.sort(dictionary);
        for(int i = 0; i < dictionary.size(); i++){
            ArrayList <Integer> scoreOrder = new ArrayList<Integer>();
            String cityName = dictionary.get(i);
            for(int j = 0; j < cityNames.size(); j++){
                if(cityNames.get(j).equals(cityName)){
                    scoreOrder.add(scores.get(j));
                }
            }
            Collections.sort(scoreOrder,Comparator.reverseOrder());
            for(int j = 0; j < scoreOrder.size();j++){
                System.out.println(scores.indexOf(scoreOrder.get(j)) + 1);
            }
            scoreOrder.clear();
        }
        
    }

}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

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

    int N; cin >> N;
    vi data(N); F0R(i, N) cin >> data[i];
    sort(all(data));
    cout << data[N/2] - data[N/2-1] << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 640
while True:
    m,f,r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int ans=0;
		ans=(N*(N-1))/2+(M*(M-1))/2;
		System.out.println(ans);
        }
    }

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

using namespace std;

#define M 33

int n, z;
long long x[1005], y[1005];
char ans[40];
set<int> s;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, y + i);
		s.insert(abs(x[i] + y[i]) & 1);
	}
	if (s.size() == 2)
		printf("-1\n");
	else {
		z = *s.begin();
		if (z) {
			printf("%d\n", M);
			for (int i = 0; i < M; i++)
				printf("%lld%c", 1LL << i, i == M - 1 ? '\n' : ' ');
		} else {
			printf("%d\n", M + 1);
			for (int i = 0; i < M; i++)
				printf("%lld ", 1LL << i);
			puts("1");
			ans[M] = 'L';
		}
		for (int i = 0; i < n; i++) {
			if (!z)
				x[i]++;
			for (int j = 0; j < M - 1; j++)
				if (abs(x[i]) & (1LL << j))
					if ((x[i] < 0) ^ !((abs(x[i]) ^ abs(y[i])) & (1LL << (j + 1))))
						ans[j] = 'L', x[i] += 1LL << j;
					else
						ans[j] = 'R', x[i] -= 1LL << j;
				else
					if ((y[i] < 0) ^ !((abs(x[i]) ^ abs(y[i])) & (1LL << (j + 1))))
						ans[j] = 'D', y[i] += 1LL << j;
					else
						ans[j] = 'U', y[i] -= 1LL << j;
			if (abs(x[i]) & (1LL << (M - 1)))
				if (x[i] < 0)
					ans[M - 1] = 'L', x[i] += 1LL << (M - 1);
				else
					ans[M - 1] = 'R', x[i] -= 1LL << (M - 1);
			else
				if (y[i] < 0)
					ans[M - 1] = 'D', y[i] += 1LL << (M - 1);
				else
					ans[M - 1] = 'U', y[i] -= 1LL << (M - 1);
			printf("%s\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
const MOD: u64 = 1_000_000_007;

mod enumeration {
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }
    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }
        pub fn c(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let r = n - b;
    let e = enumeration::Enumeration::new(2020, MOD);

    let mut out = Vec::new();
    for i in 0..b {
        let t = e.c(b - 1, i);
        let u = e.c(r + 1, i + 1);
        writeln!(out, "{}", u * t % MOD).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 4352
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		sc.close();
		out.println(Math.min(a*n,b));
	}
}


Measured memory_bytes: 21076