akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
    int n,sum=0,tmp;
    cin >> n;
    vector<vector<int> > vec(n,vector<int>(3));
    rep(i,n){
        cin >> vec.at(i).at(0);
        if(!i){
            vec.at(i).at(1)=0;
            sum+=abs(vec.at(i).at(0));
        }
        else{
            vec.at(i).at(1)=vec.at(i-1).at(0);
            vec.at(i-1).at(2)=vec.at(i).at(0);
            sum+=abs(vec.at(i).at(0)-vec.at(i).at(1));
        }
    }
    vec.at(n-1).at(2)=0;
    sum+=abs(vec.at(n-1).at(0));
    rep(i,n){
        if(!i)tmp=sum-abs(vec.at(i).at(0))-abs(vec.at(i).at(2)-vec.at(i).at(0))+abs(vec.at(i).at(2));
        else tmp=sum-abs(vec.at(i).at(0)-vec.at(i).at(1))-abs(vec.at(i).at(2)-vec.at(i).at(0))+abs(vec.at(i).at(2)-vec.at(i).at(1));
        cout << tmp << endl;
    }
}

Measured memory_bytes: 6656
N = int(input())
name = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
march = "MARCH"
for _ in range(N):
  S = input()
  if(S[0] in name):
    name[S[0]] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += name[march[i]] * name[march[j]] * name[march[k]]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

struct Card {
    char suit;
    int value;
};

void BubbleSort(struct Card C[], int N) {
    int i,j;
    struct Card dummy;
    for (i=0; i<N; i++) {
        for (j=N-1; j>=i; j--) {
            if(C[j].value < C[j-1].value) {
                dummy = C[j];
                C[j] = C[j-1];
                C[j-1] = dummy;
            }
        }
    }
}

void SelectionSort(struct Card C[], int N) {
    int i,j,minj;
    struct Card dummy;
    for (i=0; i<N; i++) {
        minj = i;
        for(j=i; j<N; j++) {
            if (C[j].value < C[minj].value) minj = j;
        }
        if (i != minj) {
            dummy = C[i];
            C[i] = C[minj];
            C[minj] = dummy;
        }
    }
}

void print(struct Card A[], int N) {
    int i;
    for (i=0; i<N; i++) {
        if(i>0) printf(" ");
        printf("%c%d",A[i].suit,A[i].value);
    }
    printf("\n");
}

int isStable(struct Card B[], struct Card S[], int N) {
    int i;
    for (i=0; i<N; i++) {
        if(B[i].suit != S[i].suit) return 0;
    }

    return 1;
}


int main(void) {
    struct Card B[36],S[36];
    int N,i;
    char dummy;
    scanf("%d\n",&N);
    for (i=0; i<N; i++) {
        scanf("%c%d",&B[i].suit, &B[i].value);
        scanf("%c",&dummy);
    }

    for (i=0; i<N; i++) S[i] = B[i];
    BubbleSort(B, N);
    SelectionSort(S, N);

    print(B, N);
    printf("Stable\n");
    print(S, N);

    if(isStable(B, S, N)) {
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }

    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)
 
inline ll ii(){ ll x; cin >> x; return x; }
inline string is(){ string x; cin >> x; return x; }
inline ld id(){ ld x; cin >> x; return x; }
inline void oi(ll x){ cout << x; }
inline void od(ld x){ cout << fixed << setprecision(10) << x; }
inline void os(string x){ cout << x; }
inline void oe(){ cout << endl; }
inline void oie(ll x){ oi(x); oe(); }
inline void ode(ld x){ od(x); oe(); }
inline void ose(string x){ os(x); oe(); }
inline void maxin(ll &a, ll b){ a=max(a,b); }
inline void minin(ll &a, ll b){ a=min(a,b); }

ll mod=1e9+7;


int main(){
    ll N=ii();
    ll none=1, zero=0, nine=0, ok=0;
    ll _none, _zero, _nine, _ok;
    if(N<=1){
        oie(0);
        return 0;
    }
    REP(i,0,N){
        _none = none * 8 % mod;
        _zero = ((zero * 9) % mod + none) % mod;
        _nine = ((nine * 9) % mod + none) % mod;
        _ok = (((ok * 10) % mod + zero) % mod + nine) % mod;
        none=_none;
        zero=_zero;
        nine=_nine;
        ok=_ok;
    }
    oie(ok);
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
ll a[maxn],b[maxn];

int main(){
	ll n,k;
	cin>>n>>k;
	ll sum = 0;
	a[0] = n;
	for(int i = 1; i <= n; i++){
		a[i] = a[i-1] + n - i;
	}
	b[0] = 0;
	for(int i = 1; i <= n; i++){
		b[i] = b[i-1] + i;
	}
	for(int i = k-1; i <= n; i++){
		ll tmp = a[i] - b[i] + 1;
		tmp %= mod;
		sum += tmp;
		sum %= mod;
		
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  string ans = "No";
  if ((A < C && C < B) || (B < C && C < A)) ans = "Yes";
  
  cout << ans << endl;
}


Measured memory_bytes: 384
//
// Created by Ильдар Ялалов on 14.01.2020.
//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double dbl;
typedef unsigned int uint;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()


#ifdef zxc

#include "debug.h"

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

bool debug = 0;
const int MAXN = (1e6) + 100;
const int LOG = 21;
const int mod = 1e9 + 7;
const int MX = (3e7 + 100);


void solve() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        sum += x;
        sum = sum % 2;
    }
    if (sum == 0) {
        cout << "YES\n";
        return;
    }
    cout << "NO\n";
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES ( n==1)
signed main() {

#ifdef zxc
    freopen("../input.txt", "r", stdin);
//    freopen("../output.txt", "w", stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(15);


    int t = 1;
    while (t--) {
        solve();
    }
    debug(1.0 * clock() / CLOCKS_PER_SEC);
}


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

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

    vector<int> num(N + 2, 0);
    for (int i = N - 1; i >= 0; i--) {
        num[P[i]] = num[P[i] + 1] + 1;
    }

    cout << N - *max_element(num.begin(), num.end()) << endl;
}

Measured memory_bytes: 1920
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    if(a + b == c || a + c == b || c + b == a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;
using ll = long long;
ll N;

int cnt_digits(ll N) {
	int digits = 0;
	while (N > 0) {
		N /= 10;
		digits++;
	}
	return digits;
}

void solve() {
	int ans = cnt_digits(N);
	for (ll A = 1LL; A*A <= N; ++A) {
		if (N % A != 0) continue;
		const ll B = N / A;
		const int cur = max(cnt_digits(A), cnt_digits(B));
		if (ans > cur) {
			ans = cur;
		}	
	}
	cout << ans << endl;
}

int main()
{
	// 入力
	cin >> N;
	solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
i = l[0]
while i % 2 == 0:
    ans += 1
    i /= 2
for i in l[1:]:
    c = 0
    while i % 2 == 0 and c <= ans:
        c += 1
        i /= 2
    if c <= ans:
        ans = c
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N[4];
  cin>>N[0]>>N[1]>>N[2]>>N[3];
  bool isok=false;
  repeat(i,4){
    isok |= N[i]==1;
  }
  if(!isok){
    cout << "NO" << endl;
    return 0;
  }
  isok=false;
  repeat(i,4){
    isok |= N[i]==9;
  }
  if(!isok){
    cout << "NO" << endl;
    return 0;
  }
  isok=false;
  repeat(i,4){
    isok |= N[i]==7;
  }
  if(!isok){
    cout << "NO" << endl;
    return 0;
  }
  isok=false;
  repeat(i,4){
    isok |= N[i]==4;
  }
  if(!isok){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import itertools as itr
MOD=pow(10,9)+7

N=int(input())

A=list(map(int, input().split()))
sumA = list(itr.accumulate(A))
ans=0
for i in range(len(A)-1):
    a=A[i+1]
    b=sumA[i]
    ans=(ans+a*b%MOD)%MOD

print(ans)

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

const static ll MOD = (1e+9)+7;

int main(){
    ll n;cin>>n;
    vector<ll> lst(n);
    vector<ll> lst2(n);
    rep(i,n){
        ll tmp;cin>>tmp;
        lst[i] = tmp;
        lst2[i] = -tmp;
    }
    sort(lst.begin(),lst.end());
    sort(lst2.begin(),lst2.end());
    ll mid = lst[n-1]/2;
    //midを下限として、これを超える最小の数字を取り出す.
    ll l_b = *lower_bound(lst.begin(),lst.end(),mid);
    ll u_b = *lower_bound(lst2.begin(),lst2.end(),-mid);
    u_b = -u_b;
    //このうち、n/2に近い方を採用する.
    ll ans;
    if(abs(mid-l_b) > abs(u_b-mid)){
        ans = u_b;
    }else if(abs(mid-l_b) < abs(u_b-mid)){
        ans = l_b;
    }else{
        ans = (lst[n-1] != l_b ? l_b:u_b);
    }
    cout<<lst[n-1]<<' '<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
using namespace std;
int main(void){
    long long int n,x,i=0,h[200000],ans=0,c=0;
    string s;
    cin >> x;
    while(1)
    {
        if(IsPrime(x))
        {
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>

int main(void) {
    int m[50] = { 0 }, f[50] = { 0 }, r[50] = { 0 }, i = 0, count = 0;

    while (1) {
        scanf("%d %d %d", &m[i], &f[i], &r[i]);
        if (m[i] == -1 && f[i] == -1 && r[i] == -1) {
            break;
        }
        i++;
        count++;
    }

    for (i = 0; i < count; i++) {
        if (m[i] == -1 || f[i] == -1) {
            printf("F\n");
        }
        else if (m[i] + f[i] >= 80) {
            printf("A\n");
        }
        else if (m[i] + f[i] < 80 && m[i] + f[i] >= 65) {
            printf("B\n");
        }
        else if (m[i] + f[i] < 65 && m[i] + f[i] >= 50) {
            printf("C\n");
        }
        else if (m[i] + f[i] < 50 && m[i] + f[i] >= 30) {
            if (r[i] >= 50) {
                printf("C\n");
            }
            else {
                printf("D\n");
            }
        }
        else {
            printf("F\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <ctype.h>
int main(void)
{
	char s1[11], s2[11], s3[11];

	scanf("%s",s1);
	scanf("%s",s2);
	scanf("%s",s3);

	s1[0]=toupper(s1[0]);
	s2[0]=toupper(s2[0]);
	s3[0]=toupper(s3[0]);

	printf("%c%c%c\n", s1[0], s2[0], s3[0]);

	return 0;
}

Measured memory_bytes: 128
from collections import Counter
import marshal
N = int(input())
D = Counter(list(map(int, input().split())))
P = [[0]]
for i in range(13):
    if D.get(i,0) == 0:
        continue
    if D.get(i,0) == 1:
        Q = marshal.loads(marshal.dumps(P))
        for p in P:
            p.append(i)
        for q in Q:
            q.append(24-i)
        P += Q
    if D.get(i,0) == 2:
        for p in P:
            p.append(i)
            p.append(24-i)
    if D.get(i,0) >= 3:
        print(0)
        exit()
res = 0
for p in P:
    m = float("inf")
    for i in range(len(p)):
        for j in range(i+1,len(p)):
            if abs(p[i]-p[j])>12:
                m = min(24-abs(p[i]-p[j]),m)
            else:
                m = min(abs(p[i]-p[j]),m)
    res = max(m,res)
print(res)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 h, w;
void solve(){
	cin >> h >> w;
	
	if(h == 1 || w == 1) cout << 1 << endl;
	else cout << (h*w+1)/2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int n,q;
vector<vector<ll>> graph;
vector<ll> ques;
vector<ll> score;
void dfs(int now,ll point){
    point+=ques.at(now);
    score.at(now)=point;
    for(int i=0;i<graph.at(now).size();i++){
        dfs(graph.at(now).at(i),point);
    }
    return;
}
int main(){
cin>>n>>q;
graph.resize(n);
for(int i=0;i<n-1;i++){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    graph.at(a).push_back(b);
}
score.resize(n);
ques.resize(n);
for(int i=0;i<q;i++){
     ll c,d;
     cin>>c>>d;
     c--;
     ques.at(c)+=d;
}
dfs(0,0);
for(int i=0;i<n;i++){
    cout<<score.at(i)<<" ";
}
cout<<endl;
}

Measured memory_bytes: 25856
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(void){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (H2-H1)*60+M2-M1-K << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int s;
	cin >> s;
	set<int> st;

	while (!st.count(s)) {	// !:否定,st.count(s)はsの数を返すので 0 or 1
		st.insert(s);
		s = s & 1 ? s * 3 + 1 : s / 2;	// ビット演算子(s & 1)が１の時奇数、０の時偶数
	}
	cout << st.size() + 1 << endl;	 // stのサイズ+1が添え字
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(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;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	ll A, B, C;
	cin >> N;

	cout << N + N * N + N * N * N;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int h=1, w=1;
  while(h != 0 || w != 0){
    cin >> h >> w;
    rep(i, h){
      rep(j, w){
        cout << "#";
      }
      cout << endl;
    }
    if(h == 0 && w == 0) break;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3156
import collections
h,w,d = map(int, raw_input().split())
mat = [map(int, raw_input().split()) for i in range(h)]
coord,cost = {mat[i][j]:(i,j) for i in range(len(mat)) for j in range(len(mat[0]))}, collections.Counter()
def f(uu,vv): 
	return abs(uu[0] -vv[0]) + abs(uu[1] -vv[1]) 
for u in range(1, h * w + 1):
	if u - d >= 1: cost[u] = f(coord[u], coord[u - d]) + cost[u - d]
for qi in  range(int(raw_input())):
	u,v = map(int, raw_input().split())
	print cost[v] - cost[u]

Measured memory_bytes: 120116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int N;
ll memo[1000000];
int a[20][20];

ll keisan(int A) {
	if (A == 0) return 0;
	if (memo[A] != -1e18) return memo[A];
	int kari = -1;
	rep(i, N) if (A >> i & 1) kari = i;
	ll kari2 = keisan(A - (1 << kari));
	rep(i, N) if (A >> i & 1) kari2 += a[kari][i];
	memo[A] = kari2;
	return memo[A];
}

ll memo2[1000000];

ll keisan2(int A) {
	if (A == 0) return 0;
	if (memo2[A] != -1e18) return memo2[A];
	int kazu = 0;
	vector<int> V;
	rep(i, N) if (A >> i & 1) {
		kazu++;
		V.pb(1 << i);
	}
	ll ret = -1e18;
	rep(j, (1 << kazu - 1)) {
		int kari = V[0];
		rep(i, N) if (j >> i & 1) {
			kari += V[i + 1];
		}
		ret = max(ret, keisan(kari) + keisan2(A - kari));

	}
	memo2[A] = ret;
	return memo2[A];
}

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

	
	cin >> N;
	rep(i, N) rep(j, N) cin >> a[i][j];

	rep(i, 1000000) memo[i] = -1e18;
	rep(i, 1000000) memo2[i] = -1e18;

	co(keisan2((1 << N) - 1));

	Would you please return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int a, b, c, K;
int m;
ll int ans;

int main(){
    scanf("%d%d%d%d", &a, &b, &c, &K);

    m = max(a, b);
    m = max(m, c);

    ans = a + b + c + m * (pow(2, K)-1);

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

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int n, m, c[10][10], c2[10][10], a[200][200];
int main() {
  cin >> n >> m;
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      cin >> c[i][j];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      cin >> a[i][j];
  for(int k = 0; k < 10; ++k)
    for(int i = 0; i < 10; ++i)
      for(int j = 0; j < 10; ++j)
        if(c[i][j] > c[i][k] + c[k][j])
          c[i][j] = c[i][k] + c[k][j];
  int cnt = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      if(a[i][j] == -1)
        continue;
      else
        cnt += c[a[i][j]][1];
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trvii(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<"("<<a[zz].F<<","<<a[zz].S<<") ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define trsetii(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll


ll fun(ll n)
{
    ll p= sqrtl(2*n);
    ll ans=0;
    for(ll m=max(0ll,p-2);m<=p+2;m++)
    {
        if(m*(m+1)<=2*n)
        {
            ans=m;
        }
    }
    return ans;
}

int main()
{
    fast();
    ll n,m;
    cin>>n;
    m=n;
    vii fac;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll mul=0;
            while(n%i==0)
            {
                n/=i;
                mul++;
            }
            fac.pb({i,mul});
        }
    }
    if(n>1)
    {
        fac.pb({n,1});
    }
    n=m;
    ll ans=0;
    for(ll i=0;i<sz(fac);i++)
    {
        ans+=fun(fac[i].S);
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3676
x, k, d = map(int, input().split())
if x >= 0:
    if x-k*d >= 0:
        print(x-k*d)
    else:
        n = x//d
        if (n%2 == 0 and k%2 == 0) or (n%2 == 1 and k%2 == 1):
            print(min(abs(x-n*d), abs(x-(n-1)*d)))
        else:
            print(abs(x-(n+1)*d))
else:
    if x+k*d <= 0:
        print(abs(x+k*d))
    else:
        n = ((-1)*x)//d
        if (n%2 == 0 and k%2 == 0) or (n%2 == 1 and k%2 == 1):
            print(min(abs(x+n*d), abs(x+(n-1)*d)))
        else:
            print(abs(x+(n+1)*d))

Measured memory_bytes: 61988
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        var sb = new StringBuilder();
        for (int l = 1; l <= n; l++) {
            int cnt = 0;
            for (int i = 1; i * i <= n; i++) {
                for (int j = 1; j * j <= n; j++) {
                    for (int k = 1; k * k <= n; k++) {
                        if (i * i + j * j + k * k + i * j + j * k + k * i > l) {
                            break;
                        }
                        if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
                            cnt++;
                        }
                    }
                }
            }
            sb.append(cnt);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 35872
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = lc()

alpha = [chr(i) for i in range(ord("a"), ord("z")+1)]
lst = [0]*26

for i,a in enumerate(alpha):
    lst[i] = s.count(a)
    
exist = False
for i in range(26):
    if lst[i] == 0:
        print(alpha[i])
        exist = True
        break
        
if not exist:
    print("None")

Measured memory_bytes: 3956
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()
s = arr_data[0][0]

#print(s,s[::-1],s[::-1].translate(str.maketrans('bdpq', 'dbqp')))


print("Yes" if s == s[::-1].translate(str.maketrans('bdpq', 'dbqp')) else "No")

Measured memory_bytes: 3700
from collections import Counter
import math
n=int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)

    return a

s=dict(Counter(prime_factorize(n)))
#print(s)
sum_ans=0
for i in s.values():
  
  if i==1:
    sum_ans+=1
    
  else:
    k=1
    while i>0:
      i-=k
      k+=1
      #print(i)
      if i<0:
        break
      sum_ans+=1
      
print(sum_ans)
      

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

int main(void){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    
    for(int i=0;i<K;i++){
        int n=max(A,max(B,C));
        if(n==A)A*=2;
        else if(n==B)B*=2;
        else if(n==C)C*=2;
    }
    cout<<A+B+C;
}

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

using namespace std;

int main() {
    int R, G, B, N;

    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r=0; R*r <= N; r++) {
        for (int g=0; R*r+G*g <= N; g++) {
            int a = N - (R*r + G*g);
            if (a%B == 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  int placeA=0;
  int placeZ=0;
  
  for(int i=0; i<s.size(); i++){
    if(s[i]=='A'){
      placeA=i;
      break;
    }
  }

  for(int j=0; j<s.size(); j++){
    if(s[j]=='Z'){
      placeZ=j;
    }
  }
  
  cout << placeZ-placeA+1 << endl;
}


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

int main() {
	int a,b;
	string s,t,u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(s==u){
		cout << a-1 << " " << b << endl;
	}else{
		cout << a << " " << b-1 << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long COMBMAX = 500500;

struct mint {
long long x;
    mint(long long x = 0):x((x % MOD + MOD) % MOD){}
    mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD; return *this;}
    mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD; return *this;}
    mint& operator*=(const mint a) {(x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res += a;}
    mint operator-(const mint a) const {mint res(*this); return res -= a;}
    mint operator*(const mint a) const {mint res(*this); return res *= a;}
    mint pow(long long t) const {if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t&1) a *= *this; return a;}
    mint inv() const {return pow(MOD - 2);}
    mint& operator/=(const mint a) {return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res /= a;}
};

class combination {
    public:
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for(int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        if (COMBMAX < n){
            mint ret = 1;
            for(long long i = 1; i <= k; i++){
                ret *= (n - i + 1);
                ret /= i;
            }
            return ret;
        }
        return fact[n] * ifact[k] * ifact[n - k];
    }

    mint multi(long long n, long long sum, long long l, long long r){
        long long m = r - l + 1;
        long long t = sum - n * (l - 1);
        mint ans = 0;
        for(long long k = 0; k <= (t - n) / m; k++){
            long long sign = k % 2 == 0 ? 1 : -1;
            mint temp = this->operator() (n, k);
            temp *= this->operator() (n + (t - n - m * k - 1), t - n - m * k);
            temp *= sign;
            ans += temp;
        }
        return ans;
    }
} com(COMBMAX);

int main(){
    long long N, K; cin >> N >> K;
    mint ans = 0;
    for(int i = 0; i <= min(K, N - 1); i++){
        mint temp = com(N - 1, i);
        temp *= com(N, i);
        ans += temp;
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>

using namespace std;

int a,b;

int main(){
  cin >> a >> b;
  if(b % a == 0){
    cout << a + b << endl;
  }else{
    cout << b - a << endl;
  }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define MAXN 300000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int pre[MAXN+5], suf[MAXN+5]; char s[MAXN+5]; int n, Ans = MAXN+5;

int main()
{
	n = read(); scanf("%s",s+1); for(rint i = 1; i <= n; pre[i] = pre[i-1]+(s[i]=='W'), i++);
	for(rint i = n; i; suf[i] = suf[i+1]+(s[i]=='E'), i--); for(rint i = 1; i <= n; Ans = min(Ans,pre[i-1]+suf[i+1]), i++);
	cout << Ans << endl; return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
#define abs(x) (x>0?x:-x)
#define decimal(x) cout<<fixed<<setprecision(x)
#define gc getchar//_unlocked
#define pc putchar//_unlocked
const ll mod=998244353;
int solve(); void precomp();

#define multitest 0
#define usecase 0
int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	if(multitest) cin>>t;
	precomp();
	for(int tc=1; tc<=t; tc++){
		if(multitest && usecase)
			cout<<"Case #"<<tc<<": ";
		solve();
	}
}
void precomp(){	
	return;
}
int solve(){
	int w, a, b; cin>>w>>a>>b;
	if(max(a, b)<=min(a+w, b+w)) cout<<0<<endl;
	else if(a+w<b) cout<<b-a-w<<endl;
	else cout<<a-b-w<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	string s;cin>>s;if(s[0]=='1') s[0]='9'; else if(s[0]=='9') s[0]='1';
	if(s[1]=='1') s[1]='9';else if(s[1]=='9') s[1]='1';
	if(s[2]=='1') s[2]='9';else if(s[2]=='9') s[2]='1';
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re return
#define ll long long
#define oo 1e9
#define mm(o,k) memset(o,k,sizeof o)
using namespace std;
ll m,n,k,a[500000],ans,x,z,o,zz,y   ;
map<int,int>mp;
int main()
{
     cin>>n;
    for (int i=0;i<n;++i){
            cin>>x;
        if (mp[x]){
            mp[x]=0;
        }
        else mp[x]++;
    }
    for (auto i :mp)if (i.second)z++;
    cout<<z;
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include <string.h>
int main(void){
   char str[1024], xstr[1024];
   int i, l;
   scanf("%s", str);
   l = strlen(str);
   for ( i = 0; i < l; i++ ) {
      xstr[i] = str[l - i - 1];
   }
   for ( i = 0; i < l; i++ ) {
      str[i] = xstr[i];
   }
   printf("%s\n", str);
   return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  for (ll i = 1; i <= n; ++i) {
    if (!(i % 3 == 0 || i % 5 == 0)) {
      sum += i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  int X,Y;
  cin>>X>>Y;
  int cnt = 0;
  while(X <= Y)
  {
    X *= 2;
    cnt++;
  }  
  cout<<cnt<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 11) * 2;
	x %= 11;
	if (x == 0) ans += 0;
	else if (x <= 6) ans += 1;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// E - Colorful Hats 2
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	c[0] = 3;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		int x = a[i];
		ans = ans * c[x] % MOD;
		c[x]--;
		c[x + 1]++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-12)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

double calc(P x, P y) {
    double dx = (x.X - y.X) * (x.X - y.X);
    double dy = (x.Y - y.Y) * (x.Y - y.Y);
    return dx + dy;
}

signed main() {
    int n;
    while(cin >> n, n) {
        vector<P> v(n);
        double x, y;
        int ma = 0;
        rep(i,0,n) {
            scanf("%lf,%lf", &x, &y);
            v[i] = P(x, y);
        }
        for(double i = 0.0; i <= 10.01; i += 0.01) {
            for(double j = 0.0; j <= 10.01; j += 0.01) {
                int cnt = 0;
                rep(k,0,n) if(calc(P(i, j), v[k]) <= 1.0 + EPS) cnt++;
                ma = max(ma, cnt);
            }
        }
        cout << ma << endl;
    }
    return 0;
}

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

ll N;
ll A[1000000], B[1000000];
ll ids[1000000];
int main(void){
  cin>>N;
  for(ll i=0;i<N;i++){
    ids[i] = i;
    cin>>A[i]>>B[i];
  }
  sort(ids,ids+N,[](ll x, ll y){return B[x]<B[y];});
  ll time = 0;
  for(ll i=0;i<N;i++){
    ll id = ids[i];
    if(B[id]-A[id]-time < 0){
      cout<<"No"<<endl;
      return 0;
    }
    time += A[id];
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 9984
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: i32 = read();
    if n / 10 == 9 || n % 10 == 9 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include<cassert>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#define inver(a) power(a,mod-2)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;
const int mod=998244353;
const int maxm=200+50;
const int maxn=8000+50; 
const int maxlog=20;
const int maxnode=maxn<<2;
int n,m;
int a[maxnode];
int b[maxnode];
int fac[maxn];
int fac_inv[maxn];
int f[maxm][maxn];
inline int add(int x)
{
	return x>=mod?x-mod:x;
}
inline int dec(int x)
{
	return x<0?x+mod:x;
} 
ll power(ll x,ll y)
{
	ll re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
ll C(int x,int y)
{
	return (ll)fac[x]*fac_inv[y]%mod*fac_inv[x-y]%mod;
}
void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
	{
		fac[i]=(ll)fac[i-1]*i%mod;
	}
	fac_inv[n]=inver(fac[n]);
	for(int i=n;i>=1;--i)
	{
		fac_inv[i-1]=(ll)fac_inv[i]*i%mod;
	}
}
namespace pol
{
	const int g=3;
	vector<int> w[2][maxlog];
	void init()
	{
		int g_inv=inver(g);
		for(int i=1,s=0;i<maxnode;i<<=1,++s)
		{
			ll w0=power(g,(mod-1)/(i<<1));
			ll w1=power(g_inv,(mod-1)/(i<<1));
			w[0][s].push_back(1);
			w[1][s].push_back(1);
			for(int k=1;k<i;++k)
			{
				w[0][s].push_back(w[0][s][k-1]*w0%mod);
				w[1][s].push_back(w[1][s][k-1]*w1%mod);
			}
		}
	}
	void FFT(int *a,int n,int f)
	{
		int d=f==-1;
		for(int i=0,j=0;i<n;++i)
		{
			if(i<j) swap(a[i],a[j]);
			for(int l=n>>1;(j^=l)<l;l>>=1);
		}
		for(int i=1,s=0;i<n;i<<=1,++s)
		{
			for(int j=0,p=i<<1;j<n;j+=p)
			{
				int *u=a+j;
				int *v=a+j+i;
				for(int k=0;k<i;++k,++u,++v)
				{
					int x=*u;
					int y=(ll)*v*w[d][s][k]%mod;
					*u=add(x+y);
					*v=dec(x-y);
				}
			}
		}
		if(f==-1)
		{
			int r=inver(n);
			for(int i=0;i<n;++i)
			{
				a[i]=(ll)a[i]*r%mod;
			}
		}
	}
}
int solve()
{
	for(int i=0;i<=n;++i)
	{
		f[1][i]=1;
	}
	init(n+2);
	pol::init();
	for(int i=1;i<=n;++i)
	{
		b[i]=fac_inv[i+2];
	}
	int deg=1;
	while(deg<=n*2) deg<<=1;
	pol::FFT(b,deg,1);
	for(int k=1;k<m;++k)
	{
		memset(a,0,sizeof(a));
		for(int i=0;i<=n;++i)
		{
			a[i]=(ll)f[k][i]*fac_inv[i]%mod;
			f[k+1][i]=f[k][i]*(C(i+1,2)+1)%mod;
		}
		pol::FFT(a,deg,1);
		for(int i=0;i<deg;++i)
		{
			a[i]=(ll)a[i]*b[i]%mod;
		}
		pol::FFT(a,deg,-1);
		for(int i=0;i<=n;++i)
		{
			f[k+1][i]=(f[k+1][i]+(ll)a[i]*fac[i+2])%mod;
		}
	}
	int an=0;
	for(int i=0;i<=n;++i)
	{
		an=(an+f[m][i]*C(n,i))%mod;
	}
	return an;
}
int main()
{
	scanf("%d%d",&n,&m);
	printf("%d\n",solve());
	return 0;
} 

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
const ll inf = pow(2, 31) - 1;
int main()
{
	ll k, r = 1;
	cin >> k;
	priority_queue<ll, vll, greater<ll> > que;
	que.push(r);
	while(r < 9)que.push(++r);
	while(--k){
		ll tmp = que.top();
		//cout << tmp << endl;
		//cout << " ok" << endl; 
		int d0 = tmp % 10;
		if(d0 != 0)que.push(tmp * 10 + d0 - 1);
		que.push(tmp*10 + d0);
		if(d0 != 9)que.push(tmp*10 + d0 + 1);
		que.pop();
	}
	//cout << endl;
	cout << que.top() << endl;
	return 0;
}

Measured memory_bytes: 2420
T = int(input())
a = T//1000
b = (T % 1000)//100
c = (T % 100)//10
d = T % 10
if a + b + c + d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b + c + d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c - d == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
else:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

struct Way{
	int p,q,cost;
	Way(){}
	Way(int _p,int _q,int _cost){
		p=_p; q=_q; cost=_cost;
	}
	bool operator<(const Way &a)const{
		return cost>a.cost;
	}
};

struct Node{
	int x,y;
};

int par[10000],_rank[10000];

void init(int n){
	for(int i=0;i<n;i++) par[i]=i,_rank[i]=1;
}

int find(int a){
	if(par[a]==a) return a;
	else return par[a] = find(par[a]);
}

void unite(int _a,int _b){
	int a = find(_a);
	int b = find(_b);
	if(a==b) return;
	if(_rank[a]>_rank[b]){
		par[b] = a;
	}
	else{
		par[a] = b;
		if(_rank[a]==_rank[b]) _rank[b]++;
	}
}

int main(){
	int N,M;
	Node node[10000];
	Way way[100000];
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>node[i].x>>node[i].y;
	}
	for(int i=0;i<M;i++){
		int a,b;
		cin>>way[i].p>>way[i].q;
		a = node[--way[i].p].x-node[--way[i].q].x;
		b = node[way[i].p].y-node[way[i].q].y;
		way[i].cost = a*a+b*b;
		//printf("\t%d\n",way[i].cost);
	}

	double ans=0;
	sort(way,way+M);
	init(N);
	for(int i=0;i<M;i++){
		int a = find(way[i].p),
			b = find(way[i].q);
		if(a!=b) unite(a,b);
		else ans += sqrt(way[i].cost);
	}
	printf("%lf\n",ans);
}

Measured memory_bytes: 1688