akhauriyash/Code-Regression huggingface dataset:
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
using namespace std;
int n,m,cnt1,cnt2,cnt,a[1005][1005];
ll k,x[2][2],ans[2][2];
void mul(ll a[][2],ll b[][2],ll c[][2]){
    ll r[2][2];
    r[0][0]=a[0][0]*b[0][0]+a[0][1]*b[1][0];
    r[0][1]=a[0][0]*b[0][1]+a[0][1]*b[1][1];
    r[1][0]=a[1][0]*b[0][0]+a[1][1]*b[1][0];
    r[1][1]=a[1][0]*b[0][1]+a[1][1]*b[1][1];
    c[0][0]=r[0][0]%orz;
    c[0][1]=r[0][1]%orz;
    c[1][0]=r[1][0]%orz;
    c[1][1]=r[1][1]%orz;
}
    
int main(){
    scanf("%d%d%lld",&n,&m,&k);
    if(!k){
        puts("1");
        return 0;
    }
    --k;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            char c;
            scanf(" %c",&c);
            if(c=='#')a[i][j]=1,++cnt;
        }
    }
    for(int i=1;i<=n;++i)if(a[i][1]&&a[i][m])++cnt1;
    for(int i=1;i<=m;++i)if(a[1][i]&&a[n][i])++cnt2;
    if(cnt1&&cnt2){
        puts("1");
        return 0;
    }
    if(!cnt1&&!cnt2){
        ll x=cnt,ans=1;
        while(k){
            if(k&1)ans=ans*x%orz;
            k>>=1,x=x*x%orz;
        }
        printf("%lld\n",ans);
        return 0;
    }
    if(cnt1){
        for(int i=1;i<=n;++i){
            for(int j=1;j<m;++j)if(a[i][j]&&a[i][j+1])++cnt2;
        }
    }
    else{
        cnt1=cnt2,cnt2=0;
        for(int i=1;i<=m;++i){
            for(int j=1;j<n;++j)if(a[j][i]&&a[j+1][i])++cnt2;
        }
    }
    x[0][0]=cnt,x[0][1]=orz-cnt2,x[1][1]=cnt1;
    ans[0][0]=ans[1][1]=1;
    while(k){
        if(k&1)mul(ans,x,ans);
        k>>=1;
        mul(x,x,x);
    }
    x[0][0]=x[1][0]=1,x[0][1]=x[1][1]=0;
    mul(ans,x,x);
    printf("%lld\n",x[0][0]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main(){
int a,b,c,t;
cin>>a>>b>>c;
if(a>b){t=a,a=b,b=t;};
if(a>c){t=a,a=c,c=t;};
if(b>c){t=b,b=c,c=t;};
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;}


Measured memory_bytes: 3068
// 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;
#define int LL

const int inf = 1e9,maxn=2e5+5;
int n,m;
int fac[maxn],inv[maxn],s[3005][3005];
int pw(int x,int y,int mod=m){if(y==0)return 1;if(y==1)return x;int mid=pw(x,y>>1,mod);if(y&1)return 1ll*mid*mid%mod*x%mod;return 1ll*mid*mid%mod;} 
int C(int x,int y){return 1ll*fac[x]*inv[y]%m*inv[x-y]%m;}
int f[maxn],p2[3005*3005];

signed main(){
	scanf("%lld%lld",&n,&m);
	fac[0]=inv[0]=1;
	for(int i=1;i<=maxn-5;i++)fac[i]=1ll*fac[i-1]*i%m;
	inv[maxn-5]=pw(fac[maxn-5],m-2,m);
	for(int i=maxn-6;i>=1;i--)inv[i]=1ll*inv[i+1]*(i+1)%m;
//	printf("%d\n",C(5,3));
	s[0][0]=1;for(int i=1;i<=n;i++){
		s[i][0]=1;
		for(int j=1;j<=i;j++)s[i][j]=(s[i-1][j-1]+1ll*(j+1)*s[i-1][j]%m)%m;
	}
	p2[0]=1;for(int i=1;i<=n*n;i++)p2[i]=2ll*p2[i-1]%m;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++)(f[i]+=1ll*s[i][j]*p2[(n-i)*j]%m)%=m;
		f[i]=1ll*f[i]*pw(2,pw(2,n-i,m-1),m)%m;
	}
	int ans=0;
	for(int i=0;i<=n;i++)
		if(i%2==0)(ans += 1ll*C(n,i)*f[i]%m)%=m;
		else (ans+=m-1ll*C(n,i)*f[i]%m)%=m;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 146048
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: [f64]);
    let mut sum = 0.0;
    for a in a {
        sum += 1.0 / a;
    }
    puts!("{}\n", 1.0 / sum);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#define MOD (LL)(1e9+7)

//累乗 O(log N)
long long power(long long x, long long N){
	if(N == 0) return 1LL;
	if(N == 1) return x;
	long long tmp = power(x, N/2);
	if(N%2 == 0) return tmp * tmp % MOD;
	else return tmp * tmp % MOD * x % MOD;
}

//逆元 O(log x)
long long inverse(long long x){
	return power(x, MOD-2);
}

//コンビネーション
struct Combination{
private:
	int N;
	vector<long long> factorial, inv;
public:
	void init(int n){ //初期化する O(N)
		N = n;
		factorial.push_back(1);
		inv.push_back(1);
		for(long long i=1; i<=N; i++){
			factorial.push_back(factorial.back()*i%MOD);
			inv.push_back(inverse(factorial.back()));
		}
	}
	long long fact(int n){
		return factorial[n];
	}
	long long comb(int n, int k){ //nCkを求める O(1)
		return factorial[n] * inv[k] % MOD * inv[n-k] % MOD;
	}
};

int N, M;
map<int,int> so;
vector<int> li;

int main(){
	cin >> N >> M;
	int tmp = sqrt(M);
	for(int i=2; i<=tmp; i++){
		if(M%i == 0) li.PB(i);
		while(M % i == 0){
			so[i]++;
			M /= i;
		}
	}
	if(M > 1){
		li.PB(M);
		so[M]++;
	}

	Combination comb;
	comb.init(N+100);

	LL ans = 1;
	for(int i=0; i<li.size(); i++){
		int n = so[li[i]];
		//cout << li[i] << " " << n << endl;
		ans *= comb.comb(N-1 + n, n);
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    vector<pair<int,int>> tasks; //pairを配列にして用意する.
    cin >> n;

    for(int i = 0; i < n;i++){
        int x,y;
        cin >> x >> y;
        tasks.emplace_back(y,x); //入力 push_backよりもこっちを使う方がいい
    }

    sort(tasks.begin(),tasks.end()); //sort
    int sum = 0;
    bool out = true;
    for(int i = 0; i < n; i++){
        sum += tasks[i].second;
        if(sum > tasks[i].first){
            out = false;
            break;
        }
    }
    if(out){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let l: i64 = input();

    let s: i64 = (1..n + 1).map(|i| l + i - 1).sum();
    let m: i64 = (1..n + 1)
        .map(|i| l + i - 1)
        .min_by_key(|&i| i64::abs(i))
        .unwrap();
    println!("{}", s - m);
}


Measured memory_bytes: 4352
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 085 C "Otoshidama"
 *   https://abc085.contest.atcoder.jp/tasks/abc085_c/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int Y = in.nextInt();

		int ans10000 = -1;
		int ans5000 = -1;
		int ans1000 = -1;

		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N - i; j++) {
				int sum = i * 10000 + j * 5000 + (N - i - j) * 1000;
				if (sum == Y) {
					ans10000 = i;
					ans5000 = j;
					ans1000 = N - i - j;
                  	break;
				}
			}
		}

		out.println(ans10000 + " " + ans5000 + " " + ans1000);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

vector<int> prime,flag;

void list_prime(int N){
	flag.resize(N + 1);
	flag[0] = 1;
	flag[1] = 1;
	for(int i = 4;i <= N;i += 2) flag[i] = 1;
	for(int i = 3;i * i <= N;i += 2){
		if(flag[i]) continue;
		for(int j = i * 2;j <= N;j += i) flag[j] = 1;
	}
	for(int i = 0;i <= N;i++) if(!flag[i]) prime.push_back(i);
	for(int i = 0;i <= N;i++) flag[i] = !flag[i];
}

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(!b) return a;
	return gcd(b,a % b);
}

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

const int ofs = 510;
int n,a[1520][1520] = {};

signed main(){
	cin >> n;
	list_prime(10000);
	for(int i = 0;i <= 2 * n;i += 2){
		int t = n + 1;
		for(int j = (int)(n / 2) * -2;j <= (int)(n / 2) * 2;j += 2){
			int x = (i + j) / 2,y = (i - j) / 2;
			a[x + ofs][y + ofs] = prime[i / 2] * prime[t];
			t++;
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(!a[i + ofs][j + ofs]){
				a[i + ofs][j + ofs] = 1;
				for(int k = 0;k < 4;k++){
					int x = i + dx[k],y = j + dy[k];
					a[i + ofs][j + ofs] = lcm(a[i + ofs][j + ofs],a[x + ofs][y + ofs]);
				}
				a[i + ofs][j + ofs]++;
			}
			cout << (j ? " " : "") << a[i + ofs][j + ofs];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 17536
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
  for b in range(k + 1):
    for c in range(2):
      nd = int(s[a])
      for d in range(10):
        na, nb, nc = a + 1, b, c
        if d != 0:
          nb += 1
        if nb > k:
          break
        if nc == 0:
          if d < nd:
            nc = 1
          if d > nd:
            break
        dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1 && b == 2) cout << 3;
    if (a == 2 && b == 1) cout << 3;
    if (a == 1 && b == 3) cout << 2;
    if (a == 3 && b == 1) cout << 2;
    if (a == 2 && b == 3) cout << 1;
    if (a == 3 && b == 2) cout << 1;
    return 0;
}


Measured memory_bytes: 256
#ifndef _LOCAL
#	define NDEBUG
#	define dprint(...)
#endif

#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);
	
	ll s;
	cin >> s;

	ll x = (ll)ceil(sqrt(s)) + 1;
	ll x1 = x, y2 = x;
	ll step = x/2;
	while(0 < step)
	{
		if(s <= x1*(y2-step))
			y2 -= step;
		step /= 2;
	}

	step = x/2;
	while(0 < step)
	{
		if(s <= (x1-step)*y2)
			x1 -= step;
		step /= 2;
	}
	
	ll x2 = x1*y2 - s, y1 = 1;
	
	dprint(x1*y2 - x2*y1);
	assert(x2 <= 1000000000);
	cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int x, t;
    scan(x, t);
    writeln(max(x - t, 0));
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
n, l =  [ int(v) for v in input().split() ]

taste = (l-1)*n + (n**2+n)//2


apple_list = [ l+i for i in range(n)]


ans = taste
if 0 in apple_list:
    ans = taste
elif taste < 0:
    ans = taste - apple_list[-1]
else:
    ans = taste - apple_list[0]

print(ans)

Measured memory_bytes: 38448
package main

import (
	"fmt"
)
func pow(a int,b int) int {
	c := 1
	for i := 0; i < b; i++ {
		c *= a
	}
	return c
}

func main() {
	var d, n int
	fmt.Scan(&d, &n)
	if n == 100 {
		n += 1
	}

	kotae := pow(100, d) * n
	fmt.Println(kotae)
}



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

int main() {
	int N; cin >> N;
	int a[3010];
	for(int i=0; i<N; ++i) cin >> a[i];
	int S=0;
	for(int i=0; i<N; ++i) S += a[i]-1;
	cout << S << endl;
	return 0;
}


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

using namespace std;

const int mod = 1000000009;

struct Mat{
  long long v[80][80];
  int h,w;

  Mat():h(0),w(0){}
  Mat(int h, int w):h(h),w(w){}
};

vector<Mat> A2;

Mat operator * (const Mat &a, const Mat &b){
  Mat c(a.h,b.w);
  for(int i = 0; i < a.h; ++i){
    for(int j = 0; j <= i && j <= a.h - i - 1; ++j){
      c.v[i][j] = 0;
      for(int k = 0; k < a.w; ++k) (c.v[i][j] += a.v[i][k] * b.v[k][j]) %= mod;
      c.v[j][i] = c.v[c.h-i-1][c.w-j-1] = c.v[c.w-j-1][c.w-i-1] = c.v[i][j];
    }
  }
  return c;
}


Mat power(const Mat &a, long long e)
{
  Mat x = a;
  Mat ret(a.h,a.w);
  
  for(int i = 0; i < ret.h; ++i) for(int j = 0; j < ret.w; ++j)
      ret.v[i][j] = i == j ? 1 : 0;
  A2[0] = ret;

  int ref = 1;
  while(e){if(e&1)ret=ret*A2[ref];++ref;e>>=1;};
  
  return ret;
}

int solve(int w, long long h, int n, const vector<pair<long long, int> > &st)
{
  long long pre = 0;
  Mat b1(w,1), b2(w,1);
  Mat A(w,w);

  for(int i = 0; i < w; ++i){
    b1.v[i][0] = 0;
    b2.v[i][0] = 0;
  }
  b1.v[0][0] = 1;
  for(int i = 0; i < w; ++i){
    for(int j = 0; j < w; ++j){
      if( abs(i-j) <= 1 ) A.v[i][j] = 1;
      else A.v[i][j] = 0;
    }
  }

  A2.clear();
  A2.push_back(A);
  A2.push_back(A);
  for(int i = 2; i < 70; ++i){
    A2.push_back( A2[i-1] * A2[i-1] );
  }
  
  for(int i = 0; i < n; ++i){
    Mat Ae = power(A, st[i].first - pre);
    for(int j = 0; j < w; ++j){
      for(int k = 0; k < w; ++k){
        (b2.v[j][0] += Ae.v[j][k] * b1.v[k][0]) %= mod;
      }
    }

    for(int j = 0; j < w; ++j){
      b1.v[j][0] = j!=st[i].second?b2.v[j][0]:0;
      b2.v[j][0] = 0;
    }

    pre = st[i].first;
  }

  return b1.v[w-1][0];
}

int main()
{
  int W,N;
  long long H;
  int tc = 1;

  while( cin >> W >> H >> N ){
    if( W == 0 && H == 0 && N == 0 ) break;
    
    vector<pair<long long,int> > stones;
    for(int i = 0; i < N; ++i){
      int x;
      long long y;
      cin >> x >> y;
      stones.push_back(make_pair(y-1,x-1));
    }
    stones.push_back(make_pair(H-1,W));
    sort(stones.begin(),stones.end());
    
    int res = solve(W,H,N+1,stones);

    cout << "Case " << tc << ": " << res << endl;
    ++tc;
  }
  return 0;
}

Measured memory_bytes: 4852
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    for(int i = 1;i<n;i++){
      s += sc.next();
    }
    int bf = s.length();
    s = s.replace("Y","");
    if(s.length() == bf){
      System.out.println("Three");
    }else{
      System.out.println("Four");
    }
  }
}


Measured memory_bytes: 23764
def abc(N, K):
    # 答えの準備
    ans = 0
    
    # 足す個数(K個足す最大値-最小値～N+1個足す最大値-最小値)
    for i in range(K, N+2):
        # i個足すときの最大値は、項数i,初項N-i+1,末項Nの階差数列の和
        max = int(0.5*i*(N-i+1+N))
        # i個足すときの最小値は、項数i,初項0,末項i-1の階差数列の和
        min = int(0.5*i*(0+i-1))
        # 最大値から最小値を引いて、個数なので最初の分1足す
        ans += max - min + 1
    
    # 答え
    if ans > 10**9 + 7:
        ans = ans % (10**9 + 7)
    return(ans)


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を空白で分割された2つの数値として扱う
    N, K = map(int, input().split())
    
    # 関数呼び出し
    f = abc(N, K)
    
    # 答えの出力
    print(f)


Measured memory_bytes: 9192
#include<stdio.h>
#include<string.h>
#define min(x,y) ((x<y)?x:y)

int yy(int n){
	if(n=='1' || n=='4' || n=='7')return 1;
	if(n=='3' || n=='6' || n=='9')return 3;
	if(n=='2' || n=='8')return 2;
}
char s[100005],t[100005];


int main(){
	int i,j,k,n,m,ans,p[3];
	while(1){
		scanf("%s",s);
		if(s[0]=='#')break;
		m=strlen(s);n=1000000;
		t[0]=1;t[1]=0;
		p[1]=yy(s[0]);
		p[0]=yy(s[1]);
		if(p[0]<=p[1]){
			n=0;
			for(i=2;i<m;i++){
				t[i]=(t[i-1]+1)%2;
				if(t[i]==0){
					if(yy(s[i])>p[1]){
						n++;
						t[i]=1;
						p[1]=yy(s[i]);
					}else p[0]=yy(s[i]);
				}else{
					if(yy(s[i])<p[0]){
						n++;
						t[i]=0;
						p[0]=yy(s[i]);
					}else p[1]=yy(s[i]);
				}
			}
		}
		//printf("1:%d ",n);
		ans=n;n=1000000;
		t[0]=0;t[1]=1;
		p[1]=yy(s[1]);
		p[0]=yy(s[0]);
		if(p[0]<=p[1]){
			n=0;
			for(i=2;i<m;i++){
				t[i]=(t[i-1]+1)%2;
				if(t[i]==0){
					if(yy(s[i])>p[1]){
						n++;
						t[i]=1;
						p[1]=yy(s[i]);
					}else p[0]=yy(s[i]);
				}else{
					if(yy(s[i])<p[0]){
						n++;
						t[i]=0;
						p[0]=yy(s[i]);
					}else p[1]=yy(s[i]);
				}
			}
		}
		//printf("2:%d ",n);
		ans=min(ans,n);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())

dic = []
S, P = [], []
for i in range(N):
    _s, _ = [x for x in input().split()]
    _p = int(_)
    S.append(_s)
    P.append(_p)
    dic.append((_s, -_p, i+1))

dic.sort()

for i in dic:
    print(i[2])
    


Measured memory_bytes: 3064
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

x = list(range(N))
x = [y+1 for y in x]
p = itertools.permutations(x)
a=None
b=None
cnt = 1
for l in p:
    if list(l) == P:
        a = cnt
    if list(l) == Q:
        b = cnt
    if a!=None and b!=None:
        print(abs(a-b))
        exit()
    cnt += 1


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

const int INF = 2e9;

int main(){
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    rep(i,5){
        if(a[i] == 0) cout << i + 1 << endl;
    }
}

Measured memory_bytes: 3628
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

struct P { ll x, v; };

int main() {
  ll n, c; in(n),in(c);
  vector<P> A(n);
  loop(i,0,n) in(A[i].x),in(A[i].v);
  vector<ll> acc(n+1);
  acc[0] = 0;
  loop(i,0,n) acc[i+1] = acc[i] + A[i].v;
  ll ans = 0;
  loop(i,1,n+1) { // i個取る
    ans = max(ans, acc[i] - A[i-1].x); // 右にi個とる時の最大価値
  }
  loop(i,1,n+1) {
    ans = max(ans, acc[n] - acc[n-i] - (c - A[n-i].x)); // 左にi個とる時の最大価値.
  }
  
  // 3) 右にi個とり、Oに戻って最大でn-i個とる時の最大値 O(N)
  // 左側: 事前計算
  vector<ll> maxL(n+1, 0); // 右にiまで取った時の左の最大価値.
  for (int i=n-1; i>=1; i--) { // 右に1個もとらない or 全部取るのは考慮不要.
    int j = n-i; // 残り数
    ll left = acc[n] - acc[n-j] - (c - A[n-j].x);
    maxL[i] = max(maxL[i+1], left);
  }
  
  // 右側: 全探索
  loop(i,1,n) { // 1個からn-1まで. 0個の場合は左からしか取らない、nの場合は右からしか取らないので.
    ll right = acc[i] - 2 * A[i-1].x; // 往復コスト
    ll left = maxL[i];
    ans = max(ans, right+left);
  }
  
  // 4) 左にi個とり、Oに戻って最大でn-i個とる時の最大値O(N^2)
  vector<ll> maxR(n+1, 0); // 左にiまで取った時の右の最大価値.
  for (int i=n-1; i>=1; i--) {
    int j = n-i;
    ll right = acc[j] - A[j-1].x;
    maxR[i] = max(maxR[i+1], right);
  }
  
  loop(i,1,n) {
    ll left = acc[n] - acc[n-i] - 2 * (c - A[n-i].x); // 往復コスト
    ll right = maxR[i];
    ans = max(ans, left+right);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 7188
/**
 *   author: malviyanshiv
 *   created: 13 April 2019  17:34:27
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

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


void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
	optimizeIO();

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int temp = b * 2 + 1, ans;
	if(a % temp == 0) ans = a / temp;
	else              ans = a / temp + 1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


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

Measured memory_bytes: 3596
#include<stdio.h>
int main(){
    int a, b, c;
    int count = 0;
    int i;
    scanf("%d %d %d", &a, &b, &c);
    for(i=a; i<=b; i++){
        if(c%i == 0){
            count += 1;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
      
        int a = n % 10;
        string yomi = "hon";
        if(a==3) yomi = "bon";
        if(a*(a-1)*(a-6)*(a-8)==0) yomi = "pon";
		Console.WriteLine(yomi);
	}

}



Measured memory_bytes: 27540
using System;

namespace AGC025A
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < str.Length; i++)
            {
                ans += int.Parse(str[i].ToString());
            }

            if (ans == 1)
            {
                Console.WriteLine(10);
                return;
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main() {
	int n, m, d;
	cin >> n >> m >> d;
	cout << setprecision(10) << fixed;
	if(d == 0) {
		cout << (double)(m-1) / n << endl;
	} else {
		cout << (double)(m-1) * 2 * (n-d) / n / n << endl;
	}
	return 0;
}


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

d = 10 ** 9
ans = 0

s = 0
for i in range(n):
    s += L + i

for i in range(n):
    if d > abs(L + i):
        d = abs(L + i)
        ans = s - (L + i)

print(ans)

Measured memory_bytes: 3060
N,K=map(int,input().split())
A=list(map(int,input().split()))
if K in A:
  print("POSSIBLE")
  exit(0)
if K>max(A):
  print("IMPOSSIBLE")
  exit(0)

diffs=[]
for i in range(len(A)):
  if A[i]>K:
    diffs.append(A[i]-K)
    
def gcd(a,b):
  if a>b:
    a,b=b,a
  while a%b>0:
    a,b=b,a%b
  return b

g=A[0]
for i in range(1,len(A)):
  g=gcd(g,A[i])
  
for dif in diffs:
  if dif%g==0:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 14228
sd=input()
t=input()
lsd=len(sd)
lt=len(t)
for i in range(lsd-lt,-1,-1):
    for j in range(lt):
        if sd[i+j]!='?' and sd[i+j]!=t[j]:
            break
    else:
            print((sd[:i]+t+sd[i+lt:]).replace('?','a'))
            break
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    vector<vector<char>> c(h+1,vector<char>(w+1));
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            cin>>c[i][j];
        }
    }
    FOR(i,1,2*h+1){
        FOR(j,1,w+1){
            cout<<c[(i+1)/2][j];
        }
        cout<<'\n';
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
int dx[2] = {1, 0}, dy[2] = {0, 1};
int H, W;
string S[1010];
int dp[1010][1010];
bool used[1010][1010];


void bfs() {
    queue<P> que;
    que.push(P(0, 0));
    dp[0][0] = 1;

    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;
        if (used[p.first][p.second]) continue;
        used[p.first][p.second] = true;
        for(int i = 0; i < 2; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (nx < H && ny <= W && S[nx][ny] == '.') {
                dp[nx][ny] += dp[nx - dx[i]][ny - dy[i]]; 
                dp[nx][ny] %= mod;
                que.push(P(nx, ny));
            }
        }
    }
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i, H) cin >> S[i];
    int x = 0, y = 0;
    bfs();
    /*
    rep(i, H) {
        rep(j, W) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << dp[H - 1][W - 1] << endl;

    return 0;
}


Measured memory_bytes: 6272
def resolve():
    N, M, C = map(int, input().split())
    Blist = [int(i) for i in input().split()]
    count = 0
    for i in range(N):
        Alist = [int(j) for j in input().split()]
        if sum(Alist[j] * Blist[j] for j in range(M)) + C > 0:
            count += 1
    print(count)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100000
char s[N+5];
int a[N+5];
int main()
{
	scanf("%s",s+1);
	int lens=strlen(s+1);
	for(int i=1;i<=lens;i++)
	{
		if(s[i]=='g') a[i]=1;
		else a[i]=-1;
	}
	int sum=0;
	for(int i=1;i<=lens;i++)
	sum+=a[i];
	printf("%d",sum/2);
}//

Measured memory_bytes: 640
# from pprint import pprint
import math

import collections

n = int(input())
# n, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))

b = [[_a - 1, _a, _a + 1] for _a in a]

numbers = {}
for i in range(n):
    c = collections.Counter(b[i])

    for k, v in c.items():
        if k in numbers.keys():
            numbers[k] += 1
        else:
            numbers.update({k: 1})

ans = sorted(numbers.items(), key=lambda x: x[1], reverse=True)

print(ans[0][1])


Measured memory_bytes: 43508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    reverse(s.begin(), s.end());
    ll now = 0;
    vector<ll> ans;
    ll fl = 0;
    for (int i = 1; i < 1234567; i++) {
        if (n - now <= m) {
            ans.push_back(n - now);
            break;
        }
        for (int j = m+now; j > now; j--) {
            if (s[j] == '0') {
                ans.push_back(j - now);
                now = j;
                break;
            }
        }
        if (ans.size() != i) {
            fl = -1;
            break;
        }
    }
    if (fl == -1)cout << fl << endl;
    else {
        reverse(ans.begin(), ans.end());
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 4284
import java.util.Scanner;
 
 
//Print a Rectangle
//
//??????H cm ?????? W cm ???????????¢?????????????????°?????????????????????????????????
//
//1 cm ?? 1cm ???????????¢??? '#'??§??¨????????????
//Input
//
//??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
//
//H W
//
//H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
//Output
//
//????????????????????????????????????H ?? W ?????? '#' ??§????????????????????¢???????????????????????????
//
//?????????????????????????????????????????????????????\??????????????????
//Constraints
//
//H, W ? 300
//Sample Input
//
//3 4
//5 6
//2 2
//0 0
//
//Sample Output
//
//####
//####
//####
//
//######
//######
//######
//######
//######
//
//##
//##
 
 
public class Main {
    public static void main(String[] args) {
 
        /*Scanner = ??????????????\????????±?????????????????????
         *??????????????????????????\???????????????????????´??????
         *System.in????????£???????¨??????????????¨???°
         */
        Scanner scan = new Scanner(System.in);
 
        //for??????????????¨????????°??????
        int i;
        int j;
 
        /*while?????§????????????????¨????
         * if?????§break????????????
         * ?±?????????????????????????????????£??????????????????????§????????????????????????????
         * ????¨??????£?????????????????????
         */
 
        while(true){
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H == 0 && W == 0 || H > 300 || W > 300)break;
            for(j = 0; j < H; j++){
                for(i = 0; i < W; i++){
                    System.out.print("#");
                }
            System.out.println();
            }
            System.out.println();
        }
    }
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    vector<int> n(3);
    REP(i, 3) cin >> n[i];

    vector<int> r(3);
    REP(i, 3) r[i] = n[i] % 2;

    int rSum = accumulate(r.begin(), r.end(), 0);

    if (rSum == 0 && n[0] == n[1] && n[1] == n[2]) cout << -1 << '\n';
    else if (rSum > 0) cout << 0 << '\n';
    else {
        int cnt = 0;
        while (true) {
            int sum;
            REP(i, 3) sum += n[i] % 2;
            if (sum > 0) break ;
            vector<int> h(3);
            REP(i, 3) h[i] = n[i] / 2;
            n[0] = h[0] + h[1];
            n[1] = h[1] + h[2];
            n[2] = h[2] + h[0];
            cnt++;
        }
        cout << cnt << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int A,B;
    cin >> A >> B;
    int xa,xb;
    xa = (A*100+8-1) / 8;
    xb = (B*100+10-1) / 10;
    int ans;
    if(int(xa*0.10) == B && int(xb*0.08) == A){
        ans = min(xa,xb);
    }
    else if(int(xa*0.10) == B && int(xb*0.08) != A){
        ans = xa;
    }
    else if(int(xa*0.10) != B && int(xb*0.08) == A){
        ans = xb;
    }
    else{
        ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3192
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b, h, m := nextInt4()
	deg := float64(6*m) - (float64(30*h) + float64(m)/2.0)
	if deg < 0 {
		deg *= -1
	}
	if deg > 180.0 {
		deg = 360.0 - deg
	}
	pi := (math.Pi / 180.0) * deg

	dist := math.Sqrt(float64(a*a) + float64(b*b) - 2.0*float64(a)*float64(b)*math.Cos(pi))
	puts(dist)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef long long ll;
#define ALL(V) V.begin(), V.end()
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}


int Main(int N, VI &P)
{
    int ans = 1;
    int mi = P[0];
    REP2(i, 1, N) if(mi > P[i]) {
        mi = P[i];
        ans++;
    } 
    return ans;
}

int main(void){
    int N;
    cin >> N;
    VI P(N);
    REP(i, N) cin >> P[i];
    cout << Main(N, P) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;
  
  int zenbu = H * W;
  int kieru = w * H + h * W;
  int kieru_kaburi = h * w;
    
  cout << zenbu - kieru + kieru_kaburi << endl;
}

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

using namespace std;

const int N = 1e6 + 6;

int a[N], b[N];

int main() {
  int n;
  scanf("%d", &n);
  bool same = 1;
  long long sum = 0;
  int mi = 1e9 + 7;
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", a+i, b+i);
    sum += a[i];
    if (a[i] > b[i]) {
      mi = min(mi, b[i]);
      same = 0;
    }
  }
  if (same)
    puts("0");
  else
    printf("%lld\n", sum - mi);

  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l,r;cin>>l>>r;
  if(r-l>=2018)
  cout<<"0"<<endl;
  else
  {
      int m=INT_MAX;
      for(int i=l;i<r;i++)
      {
          for(int j=i+1;j<=r;j++)
          {
              int p=(i%2019)*(j%2019)%2019;
              if(p<m)
              m=p;
          }
      }
      cout<<m<<endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n;
ll a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=n;i>=0;i--)a[i]+=a[i+1];
	ll cur=1,ans=0;
	int dep=0;
	while(cur<a[dep])
	{
		ans+=cur;
		if(cur<a[dep]-a[dep+1])
		{
			printf("-1\n");
			return 0;
		}
		cur-=a[dep]-a[dep+1];
		cur*=2;
		dep++;
	}
	for(int i=dep;i<=n;i++)ans+=(a[i]-a[i+1])*(i-dep+1);
	printf("%lld\n",ans);
	return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}

ll dp[3000][3000];
ll n;
ll a[3000];
ll calc(ll i,ll j){
    if(i==j)
        return a[i];
    else if(dp[i][j]!=5e12)
        return dp[i][j];
    else{
        dp[i][j]=max(a[i]-calc(i+1,j),a[j]-calc(i,j-1));
        return dp[i][j];
    }
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                dp[i][j]=5e12;
        cout<<calc(0,n-1);
    }
}

Measured memory_bytes: 74040