akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll n, k;
    cin(n);
    cin(k);

    vector<ll> a(n);
    rep2(i, n) cin(a[i]);

    ll town = 1;

    while (k) {
        if (k & 1) town = a[town - 1];

        vector<ll> an(n);
        rep2(i, n) an[i] = a[a[i] - 1];

        a.swap(an);

        k >>= 1;
    }

    print(town);
    return 0;
}

Measured memory_bytes: 6728
#include <cassert>
#include <iostream>
#include <string>
#include <set>
using namespace std;


//// ??????????????????k????????????ok??¨?????????
//// \sum |S_i| < 26^k
//// 400000 < 26^4 = 676^2, so k = 4 is ok


const int N = 123456;
string s[N];
#define rep(i, n) for (int i = 0; i < int(n); ++i)


string dfs(const set<string> &occur, int len, string cur) {
	if (cur.length() == len) {
		if (occur.count(cur) == 0) {
			return cur;
		} else {
			return "";
		}
	}
	rep(i, 26) {
		char c = 'a' + i;
		string res = dfs(occur, len, cur + c);
		if (res.length() > 0) {
			return res;
		}
	}
	return "";
}

string search(const set<string> &occur, int len) {
	return dfs(occur, len, "");
}

// RUPC D
int main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> s[i];
	}
	// Enumerate all substrings of length <= 4
	set<string> occur;
	rep(i, n) {
		int l = s[i].length();
		rep(j, l) {
			rep(k, 4) {
				if (j + k + 1 <= l) {
					occur.insert(s[i].substr(j, k + 1));
				}
			}
		}
	}
	rep(i, 4) {
		int len = i + 1;
		string result = search(occur, len);
		if (result.length() > 0) {
			cout << result << endl;
			return 0;
		}
	}
	assert (0);
	// your code goes here
	return 0;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define MPS
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 300050;

int n, a, b, v[maxn];

int main()
{
	cin >> n >> a >> b;
	if(a + b - 1 > n) return 0 * pf("-1\n");
	if(1ll * n > 1ll * a * b) return 0 * pf("-1\n");
	fo(i,1,n) v[i] = i;
	a = n - a;
	for(int i = 1; a && i <= n; i += b)
	{
		a = min(n - i, a);
		if(a >= b-1) {reverse(v + i, v + i + b); a -= b - 1;}
		else {reverse(v + i, v + i + a + 1); a = 0;}
	}
	fo(i,1,n) pf("%d ", v[i]);
	return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int n, cnt = 2, ans = 1;
   cin >> n;

   while (n != 1)
   {
      n /= 2;
      ans += cnt;
      cnt *= 2;
   }
   cout << ans << '\n';
}

Measured memory_bytes: 256
package main

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

func main() {
	defer writer.Flush()
	var N int
	fmt.Scan(&N)
	for N > 0 {
		sum := 0
		for i := 1; ; i++ {
			sum += i
			if sum >= N {
				Println(i)
				N -= i
				break
			}
		}
	}
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }


Measured memory_bytes: 1880
#include <cstdio>

using namespace std;

const int mod = 998244353;
char s[300001];
int c[8];

int main() {
    int n, i, j;
    long long ans = 1;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    c[0] = n;
    
    for (i = 0; i < n * 3; i++) {
        int x;
        
        if (s[i] == 'R') {
            x = 1;
        } else if (s[i] == 'G') {
            x = 2;
        } else {
            x = 4;
        }
        
        for (j = 6; j >= 0; j--) {
            if (c[j] > 0 && (j | x) != j) {
                ans = ans * c[j] % mod;
                c[j]--;
                c[j | x]++;
                
                break;
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(N*A, B) << "\n";
	return 0;
}


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

int main() {
	int ma;
	cin >> ma;
	if(ma<10){
		cout << ma <<"\n";
	}else if (ma < 100){
		cout << "9\n";
	}else if (ma < 1000){
		cout << ma-99 + 9 << "\n";
	}else if (ma < 10000){
		cout << "909\n";
	}else if (ma < 100000){
		cout << ma-9999 + 909 << "\n";
	}else{
		cout << "90909\n";
	}
	return 0;
}

Measured memory_bytes: 256
use std::cmp::{self, Ordering};
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let s: String = sc.read().unwrap();
    let s: Vec<char> = s.chars().collect();
    let l = s.len();

    let c1 = s[0] == 'A';
    let c2 = &s[2..l - 1]
        .iter()
        .fold(0, |acc, c| acc + (c == &'C') as i32)
        == &1;
    let c3 = s.iter().all(|&c| match c {
        'A' | 'C' => true,
        c => c >= 'a' && c <= 'z',
    });

    if c1 && c2 && c3 {
        println!("AC");
    } else {
        println!("WA");
    }
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int BUF = 300005;


int N;
int vList[BUF];

void read() {
    cin >> N;
    for (int i = 0; i < N * 3; ++i) {
        cin >> vList[i];
    }
}


vector<long long> calc() {
    priority_queue<int, vector<int>, greater<int> > aChose;
    
    long long sum = 0;
    for (int i = 0; i < N; ++i) {
        aChose.push(vList[i]);
        sum += vList[i];
    }

    vector<long long> ret;
    ret.push_back(sum);
    
    for (int cur = N; cur < N * 2; ++cur) {
        if (aChose.top() < vList[cur]) {
            sum -= aChose.top();
            sum += vList[cur];
            aChose.pop();
            aChose.push(vList[cur]);
        }
        ret.push_back(sum);
    }

    return ret;
}

void work() {
    vector<long long> aVec = calc();
    
    for (int i = 0; i < N * 3; ++i) {
        vList[i] *= -1;
    }
    reverse(vList, vList + N * 3);
    
    vector<long long> bVec = calc();

    long long maxV = aVec[0] + bVec.back();
    for (int i = 0; i < aVec.size(); ++i) {
        maxV = max(maxV, aVec[i] + bVec[bVec.size() - i - 1]);
    }
    cout << maxV << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<pll, pll> node;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const int Maxk = 60;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

bitset<16032> X, Y;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	X[0] = Y[0] = true;
	str s;
	cin >> s;
	s += 'T';
	ll fx, fy;
	cin >> fx >> fy;
	ll smx = 0, smy = 0;
	
	ll cnt = 0;
	ll f = 0, f2 = 0;
	for(auto x : s){
		if(x == 'T'){
			if(!f){
				smx += cnt;
				if(f2){
					X |= (X << (2 * cnt));
				}
			} else {
				smy += cnt;
				Y |= (Y << (2 * cnt));
			}
			cnt = 0;
			f = 1 - f;
			f2 = 1;
		} else {
			cnt ++;
		}
	}
	if(smx < fx || smy < fy) cout << "No\n";
	else cout << (X[smx - fx] & Y[smy - fy] ? "Yes\n" : "No\n");
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000

//Common memset settings
//memset(memo, -1 , sizeof memo);   //intialize DP memoization with -1
//memset(arr, 0, sizeof arr);       //to clear arrray of integers

//SHORTCUTS
// trueCase =  a ? b:c // if(a) trueCase = b; else ans = c;
// and

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

    string s;
    cin>>s;

    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';

    cout<<s;

}



Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const int INF = 2000000000; //2e9
const int large_P = 1000000007; //1e9 + 7



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// base を底としたときの、n の i桁目を、v.at(i) に入れる。(桁数は n に応じて自動で設定する。)
void ll_to_vector(int base, long long n, vector<int>& v) {
	long long tempo = n;
	long long tempo2 = n;

	//ll n_digit = floor(log10(n) / log10(base)) + 1;  // 桁の計算を1行で。ただ誤差があるのでよくない。
	int n_digit = 1;
	while (tempo2 >= 10) {
		tempo2 /= 10;
		n_digit++;
	}

	v.assign(n_digit, 0);

	//ll n_digit = v.size();  // v のサイズをそのままにする場合。

	for (int i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}



int char_to_int(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2; case '3': return 3; case '4': return 4;
	case '5': return 5; case '6': return 6; case '7': return 7; case '8': return 8; case '9': return 9;
	default: return 0;
	}
}


//エラトステネスの篩で、prime で ないところに false を入れる。
//true で初期化された vector を代入する必要がある。
void prime_judge(vector<bool>& prime_or_not) {

	prime_or_not.at(0) = false;
	prime_or_not.at(1) = false;

	ll n = prime_or_not.size() - 1;
	ll region = (ll)sqrt(n) + 1;

	for (ll i = 2; i <= n / 2; i++) {
		prime_or_not.at(2 * i) = false;
	}


	for (ll i2 = 1; i2 < n / 2; i2++) {
		ll i = 2 * i2 + 1;  //ここからは奇数のみ探索
		if (i < region && prime_or_not.at(i)) {
			ll j = i * i;
			while (j < n + 1) {
				prime_or_not.at(j) = false;
				j += 2 * i;
			}
		}
	}
};



map<ll, ll> divide_to_prime(int target) {
	map<ll, ll> res;

	//sqrt(target) まで調べる。
	ll upper_lim = ceil(sqrt(target));
	vector<bool> prime_or_not(upper_lim + 1, true);

	if (upper_lim < 20) prime_or_not.assign(25, true);
	prime_judge(prime_or_not);

	ll tempo = target;
	rep(i, (upper_lim + 1)) {
		if (prime_or_not.at(i)) {
			while (tempo % i == 0) {
				tempo /= i;
				res[i]++;
			}
		}
	}

	if (tempo != 1) res[tempo]++; //sqrt(target) より大きな素因数は高々1つしかない。



	return res;
}




signed main() {
	int N, M;
	cin >> N >> M;

	if (M % 2 == 1) {
		rep(i, M / 2) cout << i + 1 << " " << M - i << endl;
		rep(i, M / 2 + 1) cout << M + i + 1 << " " << 2*M + 1 - i << endl;
	}
	else {
		rep(i, M / 2) cout << i + 1 << " " << M + 1 - i << endl;
		rep(i, M / 2) cout << M + i + 2 << " " << 2 * M + 1 - i << endl;
	}


}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////


int main() {
  long long n, m, k; cin >> n >> m >> k;
  vector<long long> a(n);
  vector<long long> b(m);
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<m; i++) cin >> b[i];

  vector<long long> aa;
  vector<long long> bb;
  long long tmp = 0;
  aa.push_back(0);
  for(int i=0; i<n; i++) {
    tmp += a[i];
    aa.push_back(tmp);
  }
  tmp = 0;
  bb.push_back(0);
  for(int i=0; i<m; i++) {
    tmp += b[i];
    bb.push_back(tmp);
  }

  long long ans = 0;
  tmp = m;
  for(long long i=0; i<=n; i++) {
    if(aa[i] > k) break;
    for(long long j=tmp; j>=0; j--) {
      if (bb[j] <= k - aa[i]) {
        tmp = j;
        ans = max(ans, i+j);
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

// EOF

Measured memory_bytes: 11104
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

const int N = 3005;
int a[N][N];
int dp[N][N][4];

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

    int r,c,k; cin >> r >> c >> k;

    for(int i=0;i<k;i++){
        int x,y,c; cin >> x >> y >> c;
        a[x][y] = c;
    }

    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            dp[i][j][0] = max(dp[i][j-1][0], dp[i-1][j][0]);
            for(int type = 1;type<=3;type++){
                dp[i][j][type] = a[i][j] + max(dp[i-1][j][3], dp[i][j-1][type-1]);
                dp[i][j][type] = max(dp[i][j][type], dp[i][j-1][type]);
            }
        }
    }

    cout << dp[r][c][3] << "\n";


}


Measured memory_bytes: 355652
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define forsn(i,x,y) for(long long i = (x) ; i <= (y) ; ++i)
typedef long long ll;
typedef long double ld;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a;
  forn(i,n) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  ll total = 0;
  for(int i = 1;i < n; i++) {
    if(a[i] + a[i-1] <= x) {
      continue;
    }
    else {
      int d = x - a[i-1];
      if(a[i-1] >= x) {
        total += a[i];
        a[i] = 0;
        total += a[i-1] - x;
        a[i-1] = x;
      }
      else {
        total += a[i-1] + a[i] - x;
        a[i] = x - a[i-1];
      }
    }
  }
  cout << total << endl;
  return 0;
}


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

int main() {
  int a,b,c; cin >> a >> b >> c;
  int ans=0;
  while(1) {
    int min_num = min(a,min(b,c));
    int count=0;
    if (min_num==a) {
      count++;
    }
    if (min_num==b) {
      count++;
    }
    if (min_num==c) {
      count++;
    }
    if(count==2) {
      if (min_num==a) {
        a++;
      }
      if (min_num==b) {
        b++;
      }
      if (min_num==c) {
        c++;
      }
    }
    else if(count==1) {
      if (min_num==a) {
        a+=2;
      }
      if (min_num==b) {
        b+=2;
      }
      if (min_num==c) {
        c+=2;
      }
    }
    else {
      break;
    }
    ans++;
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  if(n%2==0||n%5==0){
    cout << -1 << endl;
    return 0;
  }
  int64_t m=7,c=1;
  while(m%n!=0){
    m = (m*10+7)%n;
    c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
    int h,w;
    for(;;){
        scanf("%d%d",&h,&w);
        if(h==0&&w==0) break;
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                if((i+j)%2==0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1992
#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        while (n--) {
            int a[4], b[4], c[4];

            for (int i = 0; i < 4; i++) {
                cin >> a[i];
                c[i] = 0;
            }
            for (int i = 0; i < 4; i++) 
                cin >> b[i];

            c[0] = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
            c[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
            c[2] = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
            c[3] = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
            
            for (int i = 0; i < 3; i++)
                cout << c[i] << " ";
            cout << c[3] << endl;
        }
    }
    

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	int i,j,k;
	int H=0,W=0;

	while(1){

		cin >> H >> W;               //????§???¢??????????????\???
		if(H==0&&W==0)		break;             //??????????§£???
			
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				cout << "#" ;          //????????????????????????????§???¢?????????							
			}
		    cout << endl;
		}
		cout <<endl;     //??????
	}

	return 0;

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(100001);
    for(int i=2;i<=100000;i++){
        for(int j=i*2;j<=100000;j+=i)a[j]++;
    }
    vector<int> cnt(100001);
    for(int i=1;i<=100000;i++){
        if(i!= 1 and i%2 and a[i]==0 and a[(i+1)/2]==0)cnt[i]=1;
        cnt[i]+=cnt[i-1];
    }
    int q;scanf("%d",&q);
    while(q--){
        int l,r;scanf("%d%d",&l,&r);
        printf("%d\n",cnt[r]-cnt[l-1]);
    }
}

Measured memory_bytes: 1408
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;

  vector<pair<ll,ll>> a;

  for(ll i = 1; i * i <= n; ++i)
  {
    if(n % i == 0)
    {
      pair<ll,ll> buf;
      buf.first = i;
      buf.second = n / i;
      a.push_back(buf);
    }
  }

  ll max = LLONG_MAX;
  ll x = 1,y = 1;

  rep(i,sz(a))
  {
    ll buf = a[i].first + a[i].second;
    if(max > buf)
    {
      max = buf;
      x = a[i].first;
      y = a[i].second;
    } 
  }

  cout << x - 1 + y - 1 << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<ll> A(N+1, 0);
  vector<ll> AR(N+1, 0);
  REP(i, N+1){
    cin >> A[i];
  }
  for(int i = N; i >= 0; i--){
    if(i != N){
      AR[i] = AR[i+1]+A[i];
    }else{
      AR[i] = A[i];
    }
  }
  if(A[0] > 1){
    cout << -1 << endl;
    return 0;
  }
  if(A[0] == 0 && N == 0){
    cout << -1 << endl;
    return 0;
  }
  if(A[0] == 1){
    if(N == 0){
      cout << 1 << endl;
      return 0;
    }else{
      cout << -1 <<endl;
      return 0;
    }
  }
  ll res = 1;
  ll ans = 1;
  for(int i = 1; i <= N; i++){
    if(A[i] == 0){
      res = min(res*2, AR[i]);
      ans += res;
    }else{
      if(res*2 < A[i]){
        cout << -1 <<endl;
        return 0;
      }
      res = min(res*2-A[i], AR[i]-A[i]);
      ans += res + A[i];
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int N, M;

    scanf("%d %d", &N, &M);
    int ans = (N * (N - 1)) / 2 + (M * (M - 1)) / 2;

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, x, y;
    cin >> n >> x >> y;
    int ans[n + 1];
    fill(ans, ans + n + 1, 0);
    auto add = [&] (int l, int r) {
        ans[l]++;
        ans[r + 1]--;
    };
    int tot = n - (y - x) + 1;
    for (int i = 1; i <= tot; i++) {
        add(0, i - 1);
        add(1, tot - i);
    }

    int cyc = y - x + 1;
    rep(i, 1, cyc + 1) {
        add(0, (cyc - 1) / 2);
        add(1, cyc / 2);

        if (i == 1 || i == cyc) {
            continue;
        }

        int d = min(i - 1, cyc - i + 1);
        add(d + 1, d + (x - 1));
        add(d + 1, d + (x - 1));


        d = min(cyc - i, i - 1 + 1);
        add(d + 1, d + (n - y));
        add(d + 1, d + (n - y));


        //add(i - 1 + 1, i - 1 + (x - 1));
        //add(cyc - i + 1, cyc - i + (n - y));
    }

    rep(i, 1, n + 1) {
        ans[i] += ans[i - 1];
    }

    ans[1] -= 2;

    rep(i, 1, n) {
        cout << ans[i] / 2 << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#A
if False:
    N=int(input())
    E=[int(i) for i in input().split()]
    E.sort()
    s=sum(E)
    if E[-1]<s-E[-1]:
        print('Yes')
    else:
        print('No')
#B
if False:
    N=int(input())
    fac=[]
    for i in range(1,10**6+1000):
        if N%i==0:
            fac.append((i,N//i))
    ans=10**19
    for l,r in fac:
        ans=min(l-1+r-1,ans)
    print(ans)
  
#C
if False:
    N=int(input())
    S=[input() for _ in range(N)]
    march=list('MARCH')
    nam=[[] for _ in range(len(march))]
    for s in S:
        if s[0] in march:
            nam[march.index(s[0])].append(s)
    ans=0
    for i in range(5):
        for j in range(i+1,5):
            for k in range(j+1,5):
                ans+=len(nam[i])*len(nam[j])*len(nam[k])
    print(ans)

#D
if False:
    import sys

    if sys.getrecursionlimit()<10**7:
        sys.setrecursionlimit(10**7)

    N=int(input())
    ver=[[] for _ in range(N)]
    for _ in range(N-1):
        u,v,W=map(int,input().split())
        ver[u-1].append((v-1,W))
        ver[v-1].append((u-1,W))
    his=[-1 for _ in range(N)]

    def dfs(i,col):
        his[i]=col
        for j,w in ver[i]:
            if his[j]==-1:
                if w%2==0:
                    dfs(j,col)
                else:
                    dfs(j,(col+1)%2)

    dfs(0,0)            
    for i in range(N):
        print(his[i])

#E
N,A,B=map(int,input().split())
H=[int(input()) for _ in range(N)]

def ceil(a,b):
    return (a+b-1)//b

def eno(T):
    nee=0
    td=B*T
    dd=A-B
    for h in H:
        if h-td>0:
            nee+=ceil(h-td,dd)
    return nee<=T

l,r=0,10**9+7
while l+1<r:
    mid=(l+r)//2
    if eno(mid):
        r=mid
    else:
        l=mid
print(r)


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

bool checkBegin(int N, vector<int> a) {
    map<int, int> ch;
    for (int i = 0; i < N; i++) ch[a[i]]++;
    if (ch.count(1)) return true;
    else return false;
}

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    if (!checkBegin(N, a)) {
        cout << "-1" << endl;
        return 0;
    }

    int res = 0, j = 1;
    for (int i = 0; i < N; i++) {
        if (a.at(i) == j) {
            j++; continue;
        }
        else res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 14204
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  ll n, a, b;
  cin >> n >> a >> b;
  vvl comb(51, vl(51, 0));
  comb[0][0] = 1;
  comb[1][0] = 1;
  comb[1][1] = 1;
  REP(i, 2, 51) {
    comb[i][0] = 1;
    comb[i][i] = 1;
    REP(j, 1, i) {
      // cout << i << "," << j << endl;
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    }
  }
  map<ll, ll, greater<ll>> mp;
  rep(i, n) {
    ll v;
    cin >> v;
    if (mp.find(v) == mp.end()) {
      mp[v] = 1;
    } else {
      mp[v]++;
    }
  }
  ll total = 0;
  double avg = 0;
  bool first = true;
  ll minnum_cnt = 0;
  ll minnum_select = 0;
  ll s = 0;
  for (auto& x : mp) {
    ll v = x.first;
    ll cnt = x.second;
    if (total + cnt >= a) {
      s += v * (a - total);
      avg = (double)s / a;
      minnum_cnt = cnt;
      minnum_select = a - total;
      break;
    } else {
      total += cnt;
      first = false;
      s += v * cnt;
    }
  }
  cout << setprecision(8) << fixed << avg << endl;
  ll ans = 0;
  if (first) {
    REP(i, a, min(minnum_cnt + 1, b + 1)) {
      ans += comb[minnum_cnt][i];
      // cout << minnum_cnt << ":" << i << ":" << comb[minnum_cnt][i] << endl;
    }
  } else {
    ans += comb[minnum_cnt][minnum_select];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
# 中央値となりうる候補は2種類しか無い。
# 消した数がA[N/2]～A[N-1]にある場合, mid = A[N/2-1](left)
# 消した数がA[0]～A[N/2 - 1]にある場合, mid = A[N/2](right)
N = int(input())
A = list(map(int, input().split()))

B = sorted(A)
L = B[N//2-1]
R = B[N//2]

for a in A:
  print(L if a >= R else R) 

Measured memory_bytes: 25472
def alpha2num(alpha):
    num=0
    for index, item in enumerate(list(alpha)):
        num += pow(26,len(alpha)-index-1)*(ord(item)-ord('A')+1)
    return num

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())
s = str(input())

ans = []
for w in s:
    num = (alpha2num(w) + n)
    if (num % 27) == 0:
        num = 1
    elif num // 27 > 0:
        num = (num % 27) + 1
    else:
        num = (num % 27)
    tmp = num2alpha(num)
    ans.append(tmp)
    
print("".join(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int R;
while(
  cin >> R,R){
 
  map<int,int> num[2];
  REP(k,2){
	int W, H, sx, sy;
	cin >> W >> H >> sx >> sy;
	--sx;
	--sy;
	VVI lv(H, VI(W));
	REP(y,H) REP(x,W) cin >> lv[y][x];
 
	using P = pair<int,PII>;
	priority_queue<P,vector<P>,greater<P>> pq;
	vector<vector<bool>> vis(H, vector<bool>(W));
	pq.push(MP(1, MP(sx, sy)));
	vis[sy][sx] = true;
 
	int acc = 0;
	int cur = 0;
	num[k][0] = 0;
	while(!pq.empty()){
	  cur = pq.top().FF;
	  while(!pq.empty() && pq.top().FF <= cur){
		auto p = pq.top();
		pq.pop();
		++acc;
		REP(d,4){
		  int tx = p.SS.FF + dx[d];
		  int ty = p.SS.SS + dy[d];
		  if(tx < 0 || W <= tx || ty < 0 || H <= ty || vis[ty][tx]) continue;
		  vis[ty][tx] = true;
		  pq.push(MP(lv[ty][tx], MP(tx, ty)));
		}
	  }
	  num[k][acc] = cur;
	}
  }
  /*
  for(auto&p:num[0]) cout << p << endl;
  cout<<"==="<<endl;
  for(auto&p:num[1]) cout << p << endl;
  */
  int ans = 1e9;
  for(auto& p: num[0]){
	auto it = num[1].lower_bound(R - p.FF);
	if(it == end(num[1])) continue;
	
	mini(ans, p.SS + it->SS);
  }
  cout << ans << endl;
 }
  return 0;
}

Measured memory_bytes: 14724
#include<cstdio>
#include<queue>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long int LL;
const int inf=1e9+10;
int main()
{
    char str1[15],str2[15],temp[15];
    scanf("%s",str1);
    scanf("%s",str2);
    int len=strlen(str2);
    for(int i=0;i<len-1;i++)
        temp[i]=str2[i];
    temp[len-1]='\0';
    if(strcmp(str1,temp)==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<vi> g(n, vi(n, INF));
  rep(i, n){
    for(int j=i+1;j<n;j++){
      g[i][j] = j - i;
      g[j][i] = j - i;
    }
  }  
  g[x-1][y-1] = 1;
  g[y-1][x-1] = 1;

  vi kv;
  kv.push_back(x-1);
  kv.push_back(y-1);
  rep(_k, 2){
    int k = kv[_k];
    rep(i, n){
      rep(j, n){
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  vi hist(n);
  rep(i, n){
    for(int j=i+1;j<n;j++){
      hist[g[i][j]]++;
    }
  }
  for(int i=1;i<n;i++){
    cout << hist[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 16128
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");

		//コード
		//    	Scanner sc = new Scanner(file);
		Scanner sc = new Scanner(System.in);

		BigInteger X = BigInteger.valueOf(sc.nextLong());
		BigInteger K = BigInteger.valueOf(sc.nextLong());
		BigInteger D = BigInteger.valueOf(sc.nextLong());

		BigInteger p = K.multiply(D);
		BigInteger A = X.abs();
		if(A.compareTo(p)>=0) {
			BigInteger d = A.subtract(p);
			System.out.println(d);
		} else {
			BigInteger Q = A.mod(D);
			BigInteger Q2 = D.subtract(Q);
			BigInteger P = A.divide(D);
			BigInteger rest = K.subtract(P);
			if(rest.mod(BigInteger.valueOf(2))==BigInteger.valueOf(0)) {
				System.out.println(Q);
			} else {
				System.out.println(Q2);
			}

		}

	}
}


Measured memory_bytes: 36036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

int main()
{
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  cout << a[2] - a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a = [int(i) for i in input().split()]
cnt = 0
for i in range(n-1):
    if a[i] + a[i+1] > x:
        n = a[i] + a[i+1] - x
        a[i+1] -= min(n, a[i+1])
        cnt += n
print(cnt)


Measured memory_bytes: 14132
import Data.Traversable
import Data.List
main :: IO ()
main = do
  (n:t:xs) <- map read . words <$> getLine
  ps <- map read . words <$> getLine
  putStrLn . show $ solve n ps

solve n ps =
  let sorted = reverse . sort . gap . sort $ ps
  in max 0 (sum $ drop (n-1) sorted)

gap :: [Int] -> [Int]
gap [] = []
gap (x:[]) = []
gap (x:y:xs) = abs (y - x) : (gap (y:xs))


Measured memory_bytes: 32764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <stdio.h>
#include <stdlib.h>
#include <float.h>

using namespace std;
#define ll long long


int main(void){
    ll N,ans;
    cin>>N>>ans;
    if(N>12) cout<<ans<<endl;
    else if(5<N && N<13) cout<<ans/2<<endl;
    else cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		String ans = "";

		if ( A <= 8 && B <= 8 ) {
			ans = "Yay!";
		} else {
			ans = ":(";
		}
		System.out.println( ans );
	}
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){

    int n,m;
    cin>>n>>m;
    int ans[n]={};

    rep(i,m){
        int s,c;
        cin>>s>>c;
        s--;
        if((ans[s]!=0 && ans[s]!=c)|| (!(s|c)&& n!=1)){
            cout<<"-1\n";
            return 0;
        }
        else{
            ans[s]=c;
        }
    }
    if(ans[0]==0&& n>1){
        ans[0]=1;
    }
    rep(i,n){
        cout<<ans[i];
    }
    cout<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
const ll INF = 1001001001001;

int main(){
    int a,b,c; cin >> a >> b >> c;
    int ans = abs(a-b)+abs(b-c)+abs(c-a);
    int ma = max(abs(a-b),max(abs(b-c),abs(c-a)));
    ans -= ma;
    cout << ans << endl;
    
}


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

using namespace std;

inline bool valid(int p1, int p2, int p3) {
    int low = min(p1, p3), high = max(p1, p3);
    return (low < p2) && (p2 < high);
}

int main() {
    int N;
    cin >> N;
    int p[N];
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    int ret = 0;
    for (int i = 1; i < N - 1; ++i) {
        ret += valid(p[i-1], p[i], p[i+1]);
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long N; cin >> N; 
	long long total = (N + 2) * (N + 1) * N / 6; 
	for(int i = 0; i < N-1; i++){
		long long u, v; cin >> u >> v; 
		if(u > v) swap(u, v); 
		total -= u * (N + 1 - v); 
	}
	cout << total << "\n"; 
}

Measured memory_bytes: 3644
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

 int n, M[100][100];
 int color[100],d[100],f[100], tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u, v, k, i ,j;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

map<long,int> mp;

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	int n; scanf("%d", &n);
	long sum = 0;
	long res = 0;
	mp[0] = 1;
	for(int i = 0; i < n; i++)
	{
		long x; scanf("%lld", &x);
		sum += x;
		res += mp[sum];
		mp[sum]++;
	}
	printf("%lld\n", res);
}






Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <climits>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	string color[8] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};
	int range[8][3] = {{0, 0, 0}, {0, 0, 255}, {0, 255, 0}, {0, 255, 255},
	{255, 0, 0}, {255, 0, 255}, {255, 255, 0}, {255, 255, 255}};
	char s;
	int a, b, c;
	while(scanf(" %c", &s)) {
		if(s == '0') break;
		scanf("%2x%2x%2x", &a, &b, &c);
		int ret = INT_MAX, ans = 0;
		rep(i,8) {
			int buf = (a-range[i][0])*(a-range[i][0]) + (b-range[i][1])*(b-range[i][1]) 
				+ (c-range[i][2])*(c-range[i][2]);
			if(ret > buf) {
				ret = buf;
				ans = i;
			}
		}
		cout << color[ans] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import bisect
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Q = list(map(int, next(sys.stdin).split()))
STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)]
D = [int(next(sys.stdin)) for _ in range(Q)]

ans = [-1 for _ in range(Q)]
nexts = [-1 for _ in range(Q)]

for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi

print('\n'.join(map(str, ans)))


Measured memory_bytes: 128744
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Main main = new Main();
		main.solve();
	}

	void solve() throws Exception {
		try (Scanner cin = new Scanner(System.in)) {
			int x1 = cin.nextInt();
			int x2 = cin.nextInt();
			int x3 = cin.nextInt();

			List<Integer> list = new ArrayList<>();
			list.add(x1);
			list.add(x2);
			list.add(x3);
			Collections.sort(list);
			System.out.println(list.get(0) + list.get(1));
		} finally {
		}
	}

}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int nature(ll a){
  if(a>=0){return(a);}
  else{return(0);}
}
int main() {
  ll H,N;
  cin>>H>>N;
  vector<vector<ll>> vec(N,vector<ll>(2));
  ll dp[10020];
  for(ll i=0;i<N;i++){cin>>vec.at(i).at(0)>>vec.at(i).at(1);}
  for(ll i=0;i<=H;i++){
    for(ll j=0;j<N;j++){
      if(i==0){dp[i]=0;}
      else if(j==0){dp[i]=dp[nature(i-vec.at(j).at(0))]+vec.at(j).at(1);}
      else{if(dp[nature(i-vec.at(j).at(0))]+vec.at(j).at(1)<dp[i]){dp[i]=dp[nature(i-vec.at(j).at(0))]+vec.at(j).at(1);}}
    }
  }
  cout<<dp[H]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long  long  int H[N];
    for(int i = 0;i < N;i++)cin >> H[i];
    long  long  int ans = 0 ;
    long  long  int a = 0;
    for(int i = 1;i < N;i++){
        if(H[i-1] >= H[i]){
            a++;
        }else{
            ans = max(a,ans);
            a = 0;
        }
        if(i == N- 1){
            ans = max(ans,a);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
    #include <math.h>
    #define LF '\n'
    #define ALL(x) x.begin(), x.end()
    #define iostreamBooster() do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
    using namespace std;
    typedef int64_t i64;
    typedef pair<int,int> pii;
    template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
    template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
    const int INF = 0x3f3f3f3f;
     
     
    signed main()
    {
    int N;
    int T, A;
    int h[1005];
    double t[1005];
     
    cin >> N >> T >> A;
     
    for (int i = 0; i < N; ++i) {
    cin >> h[i];
    t[i] = (double)T - h[i] * 0.006;
    }
     
    int p = 0;
    double v = INF;
     
    for (int i = 0; i < N; ++i) {
    double d = fabs(A - t[i]);
    if (d < v) {
    p = i;
    v = d;
    }
    }
     
    cout << p+1 << endl;
     
    return 0;
    }
     

Measured memory_bytes: 256