akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <typename T, typename E> T qpow(T x, E e) {
    if (e == 0) return 1;
    if (e % 2 == 0) return qpow(x*x, e/2);
    return x * qpow(x*x, e/2);
}

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ull * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

using M = Mint<1'000'000'007>;
using C = Mint<13>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto s = load<string>();
	auto dyn = vector<array<M, 13>>((int)s.size()+1);
	dyn[0][0] = 1;
	auto mult = C(1);
	for (auto e=0; e<(int)s.size(); ++e, mult *= 10) {
		auto chr = s[(int)s.size()-1-e];
		if (chr == '?') {
			for (auto d=0; d<10; ++d) {
				auto digit = C(d);
				for (auto r=0; r<13; ++r) {
					auto r2 = r + digit * mult;
					dyn[e+1][r2.val] += dyn[e][r];
				}
			}
		} else {
			auto digit = C(chr - '0');
			for (auto r=0; r<13; ++r) {
				auto r2 = r + digit * mult;
				dyn[e+1][r2.val] += dyn[e][r];
			}
		}
	}
	cout << dyn[(int)s.size()][5] << '\n';
}


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

using namespace std;

int main(){
    string a, b;
    cin >> a;
    cin >> b;
    int m=a.length();
    int n=b.length();
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++){
        for(int j=0;j<=n;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(a[i-1]==b[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string s="";
    while(1){
        if(m==0 || n==0) break;
        if(a[m-1]==b[n-1] && dp[m-1][n]<dp[m][n] && dp[m][n-1]<dp[m][n]){
            s=a[m-1]+s;
            m--;
            n--;
        }
        else if(dp[m-1][n]>=dp[m][n-1]){
            m--;
        }
        else if(dp[m][n-1]>dp[m-1][n]){
            n--;
        }
    }
    cout << s;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,n2=1,q,b[200010],x,y,add=0,cost[200010],dp[200010],dat[800010];
vector <int> v[200010];

void upd(int k,int val)
{
	dat[k]=min(dat[k],val);
	while(k>0)
	{
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}

int query(int k,int lb,int ub,int tlb,int tub)
{
	if(ub<tlb||tub<lb) return 1e9;
	if(tlb<=lb&&ub<=tub) return dat[k];
	return min(query(k*2+1,lb,(lb+ub)/2,tlb,tub),query(k*2+2,(lb+ub)/2+1,ub,tlb,tub));
}

int main()
{
	cin>>n;
	repn(i,n)
	{
		scanf("%d",&b[i]);
		cost[i]=(b[i]==1 ? 1:-1);
		add+=(b[i]==0);
	}
	cin>>q;
	rep(i,q)
	{
		scanf("%d%d",&x,&y);
		v[x].pb(y);
	}
	repn(i,200005) dp[i]=1e9;
	while(n2<n) n2*=2;
	rep(i,800005) dat[i]=1e9;
	repn(i,n)
	{
		rep(j,v[i].size())
		{
			int ne=min(dp[i-1],query(0,0,n2-1,i,v[i][j]-1));
			if(ne<dp[v[i][j]])
			{
				dp[v[i][j]]=ne;
				upd(v[i][j]+n2-1,dp[v[i][j]]);
			}
		}
		dp[i]=min(dp[i],dp[i-1]+cost[i]);
	}
	cout<<dp[n]+add<<endl;
	return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 2;
int v[T];
int l[T];
int r[T];

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int ans = 0;

    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        l[i] = v[i];
        if(i > 1) l[i] = __gcd(l[i],l[i-1]);
    }

    for(int i = n; i >= 1; i--) {
        r[i] = v[i];
        if(i < n) r[i] = __gcd(r[i],r[i+1]);
    }

    for(int i = 1; i <= n; i++)
        ans = max(ans, __gcd(i-1 >= 1? l[i-1] : r[i+1], i+1 <= n? r[i+1] : l[i-1]));

    cout << ans << endl;

    return 0;
}


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

int main(void){
  int n, m = 0;
  cin >> n;
  for( int i = 0 ; i < n ; i++ ){
    int a, b;
    cin >> a >> b;
    m += ( b - a ) + 1;
  }
  cout << m << endl;
}

Measured memory_bytes: 3580
#[allow(unused)]
use std::io::Write;
use std::cmp::min;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: isize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let a: Vec<isize> = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.split_whitespace().map(|x| x.parse().unwrap()).collect()
    };

    let sum: isize = a.iter().sum();

    let mut mindiff = std::isize::MAX;
    let mut sum_i = 0;
    let mut center_index = 0;
    let mut center_sum = 0;
    for i in 0..(n as usize) {
        sum_i += a[i];
        // if (sum / 2 - sum_i) < mindiff {
        if (sum - sum_i * 2).abs() < mindiff {
            mindiff = (sum - sum_i * 2).abs();
            center_index = i;
            center_sum = sum_i;
        }
    }

    let ans = (center_sum - (sum - center_sum)).abs();
    println!("{}", ans);
}


Measured memory_bytes: 14456
import numpy as np
from decimal import *
from math import sqrt
a, b, c = list(map(int, input().split()))


getcontext().prec = 20    # デフォルト28桁のところを20桁にする

_a = Decimal(a).sqrt()
_b = Decimal(b).sqrt()
_c = Decimal(c).sqrt()

if _a+ _b < _c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 22156
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e16;

signed main()
{
        int A,B,Q; cin>>A>>B>>Q;
        vint s(A+2),t(B+2);
        REP(i,A) cin>>s[i+1];
        REP(i,B) cin>>t[i+1];

        s[0]=-INF; s[A+1]=INF;
        t[0]=-INF; t[B+1]=INF;

        while(Q--){
                int x; cin>>x;
                int rs=lower_bound(ALL(s),x)-s.begin();
                int ls=rs-1;
                int rt=lower_bound(ALL(t),x)-t.begin();
                int lt=rt-1;
/*
                cout<<s[ls]<<' '<<s[rs]<<endl;
                cout<<t[lt]<<' '<<t[rt]<<endl;
*/

                int cost=INF;
                cost=min(cost,abs(s[ls]-x)+abs(t[lt]-s[ls]));
                cost=min(cost,abs(t[lt]-x)+abs(s[ls]-t[lt]));

                cost=min(cost,abs(s[ls]-x)+abs(t[rt]-s[ls]));
                cost=min(cost,abs(t[rt]-x)+abs(s[ls]-t[rt]));

                cost=min(cost,abs(s[rs]-x)+abs(t[lt]-s[rs]));
                cost=min(cost,abs(t[lt]-x)+abs(s[rs]-t[lt]));

                cost=min(cost,abs(s[rs]-x)+abs(t[rt]-s[rs]));
                cost=min(cost,abs(t[rt]-x)+abs(s[rs]-t[rt]));

                cout<<cost<<endl;
        }
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int Y = sc.nextInt();

		int sum=0;
		boolean judge=false;
		int a=0;
		int b=0;
		int c=0;

		for (int i=0; i<X+1; i++) {
			for (int k=0; k<X-i+1; k++) {
				sum = 10000*i + 5000*k + 1000*(X-i-k);
				if (sum==Y) {
					judge = true;
					a=i;
					b=k;
					c=X-i-k;
					break;
				}
			}
		}
		if (judge) {
			System.out.print(a);
			System.out.print(" ");
			System.out.print(b);
			System.out.print(" ");
			System.out.print(c);

		} else {
			System.out.println("-1 -1 -1");
		}

	}

}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

int main(int argc, const char* argv[]) {
  u32 n;
  cin >> n;
  
  vector<u32> a(n);
  for(u32 i = 0; i < n; ++i) {
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  u32 tmp = 0;
  u32 ret = 0;
  for(u32 i = 0; i < n; ++i) {
    if(tmp < a[i]) {
      tmp = a[i];
      ++ret;
    }
  }
  
  cout << ret;
  
  return 0;
}

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

int main()
{
  int w, h, n;

  cin >> w >> h >> n;


  int nx, ny;
  int x, y;

  cin >> nx >> ny;

  int ans = 0;
  for (int i = 1; i < n; i++){
    cin >> x >> y;

    if (x < nx && y < ny) {
      int mini = min(nx - x, ny - y);
      nx -= mini; ny -= mini;
      ans += mini;
    }
    if (x > nx && y > ny) {
      int mini = min(x - nx, y - ny);
      nx += mini; ny += mini;
      ans += mini;
    }

    if (nx == x) {
      ans += abs(y - ny);
    }
    else if (y == ny) {
      ans += abs(x - nx);
    }
    else {
      ans += (abs(ny - y) + abs(nx - x));
    }

    nx = x; ny = y;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3072
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
const double EPS = 1e-8;
bool sgn(double x){return x > EPS - x < EPS;}
int n, a[N][3];
int main(){
    //IN;
    SC(n);
    FF(i ,1, n) SCCC(a[i][0], a[i][1], a[i][2]);
    bool ok = 1;
    FF(i, 1, n){
        int t = abs(a[i][1] - a[i - 1][1]) + abs(a[i][2] - a[i - 1][2]);
        if(t > a[i][0] - a[i - 1][0]) ok = 0;
        else if((a[i][0] - a[i - 1][0] - t) % 2) ok = 0;
    }
    puts(ok ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

#define rep(i,a,b) for(int i=(a); i<(b); i++)
typedef long double D;

int main(){
  int n;
  int cnt=1;
  while(cin >> n , n){
    float sum = 0;

    int a,b;
    cin >> a >> b;

    int c,d;
    cin >> c >> d;

    int e,f;
    rep(i,0,n-2){
      cin >> e >> f;
      int x1 = c-a;
      int y1 = d-b;
      int x2 = e-a;
      int y2 = f-b;

      sum += x1 * y2 - x2 * y1;

      c = e;
      d = f;
    }
    printf("%d %.1f\n",cnt++,abs(sum/2));
  }
  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d,min;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b)
        min=b;
    else min=a;
    if(c>d)
        min+=d;
    else min+=c;
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 128
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n);
    VIN(ll, v, n);
    IN(q);
    map<ll, ll> s;
    ll res = 0;
    rep(i, n) {
        s[v[i]]++;
        res += v[i];
    }
    rep(i, q) {
        IN(b, c);
        ll k = s[b];
        res -= k*b;
        s[b] = 0;
        s[c] += k;
        res += k*c;
        cout << res << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 10052
import java.util.*;
// import java.io.*;
// import java.time.*;

public class Main {
    static StringBuilder sb;
    static List<List<Integer>> permutations;

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

        int num = sc.nextInt();

        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            array.add(i + 1);
        }

        permutations = new ArrayList<List<Integer>>();
        permutation(array, new ArrayList<>());

        for (int i = 0; i < permutations.size(); i++) {
            printListWithWhiteSpace(permutations.get(i));
        }

        System.out.print(sb);
        
        sc.close();
    }

    public static void permutation(List<Integer> q, List<Integer> ans){
        // Base Case
        if(q.size() <= 1) {
            List<Integer> tmp = new ArrayList<>();
            tmp.addAll(new ArrayList<>(ans));
            tmp.add(q.get(0));
            permutations.add(tmp);
        }
        // General Case
        else {
            for (int i = 0; i < q.size(); i++) {
                List<Integer> new_q = new ArrayList<>();
                new_q.addAll(new ArrayList<>(q.subList(0, i)));
                new_q.addAll(new ArrayList<>(q.subList(i + 1, q.size())));
                List<Integer> new_ans = new ArrayList<>();
                new_ans.addAll(new ArrayList<>(ans));
                new_ans.add(q.get(i));
                permutation(new_q, new_ans);
            }
        }
    }

    public static void printListWithWhiteSpace(List<Integer> list) {
        for (int i = 0; i < list.size(); i++) {
            sb.append(list.get(i));
            if (i != list.size() - 1) sb.append(' ');
            else sb.append("\n");
        }
    }
}



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

int main(){
	
	int k , c , sum ;
	
	while(1){
		cin >> k ;
		if( k==0 ) break ;
		
		sum = 0 ;
		for( int i=0 ; i<k*(k-1)/2 ; i++ ){
			cin >> c ;
			sum += c ;
		}
		
		cout << sum/(k-1) << endl ;
	}
	
return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0, flag = 0;
    for(int i = n-1; i >= 0; i--) {
        if(!flag) ans += a[i];
        else ans -= a[i];
        flag = !flag;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<n-1;i++){
        map<char,int> mp;
        int cc=0;
        for(int j=0;j<i;j++){
            mp[s[j]]++;
        }
        for(int j=i;j<n;j++){
            if(mp[s[j]]>0){
                cc++;
                mp[s[j]]=0;
            }
        }
        ans=max(ans,cc);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N,a,i=0,two=0,zero=0,one=0;
  long long int A[100000];
  scanf("%d",&N);
  while(i<N){
    i++;
    scanf("%ld",&A[i]);
    a=A[i]%4;
    if(a==0){two++;}
    else if(a==1||a==3){zero++;}
    else{one++;}
  }
  if(one==0){zero--;};
  if(two>=zero){printf("Yes\n");}
  else{printf("No\n");}
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl d = vv(n+m, 2, 0, ll);
  re(i, n){
    std::cin >> d[i][0];
    d[i][1] = 1;
  }
  re(i, m)std::cin >> d[i+n][0];

  sort(d.begin(), d.end());
  ll ans = 0;

  ll a = m+1, b = n+1;

  re(i, n+m){
    ans += d[i][0] * (d[i][1]==1?a:b);
    (d[i][1]==1?b:a) = max((ll)0, d[i][1]==1?b-1:a-1);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11136
///////////////////////////////////////////////
//縦 Hcm,横 Wcm　の長方形を出力するプログラム
//H*W個の'#'で長方形を表すこと
///////////////////////////////////////////////
#include<iostream>
using namespace std;

int main(){
	int H,W;
	
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0)break;
		
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cout << "#" ;
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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



int main(){ 
int N; cin >> N;
vector<ll> A(N);
rep(i,N) cin >> A[i];
sort(all(A));
ll x = 1;
bool flag = true;
rep(i,N){
 if(x != 0 && A[i] > 1000000000000000000/x){
	 flag = false;
	 break;
 }
 x *= A[i];
}


if(flag) cout << x << endl;
else cout << -1 << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  pair<long long, int> Ai[N];
  for (int i = 0; i < N; i++) {
    cin >> Ai[i].first;
    Ai[i].second = i + 1;
  }
  sort(Ai, Ai + N);
  long long ans = 0;
  long long dp[N + 1][N + 1];
  for (int x = 0; x <= N; x++) fill(dp[x], dp[x] + N + 1, 0);
  dp[0][0] = 0;
  for (int x = 0; x <= N; x++) {
    for (int y = 0; x + y + 1 <= N; y++) {
      int i;
      long long A;
      tie(A, i) = Ai[N - (x + y + 1)];
      dp[x + 1][y] = max(dp[x + 1][y], dp[x][y] + A * abs(x + 1 - i));
      dp[x][y + 1] = max(dp[x][y + 1], dp[x][y] + A * abs(N - y - i));
    }
    ans = max(ans, dp[x][N - x]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34936
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    tmp = n // 100
    if n - tmp * 100 <= tmp * 5:
        print(1)
        return
    print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    string o;
    string e;

    cin >> o;
    cin >> e;

    int cnt = o.size() + e.size();
    int i = 1;
    int otop=0;
    int etop=0;

    while(cnt != 0){
        if(i % 2 != 0){
            cout << o[otop];
            otop++;
            i++;
        }else{
            cout << e[etop];
            etop++;
            i++;
        }

        cnt--;
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

#define MAX_V 210

int V; // 頂点数
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v) {
    used[v] = true;
    for (int i=0; i<G[v].size(); i++) {
        int u = G[v][i];
        int w = match[u];
        if (w < 0 || (!used[w] && dfs(w))) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching() {
    int res = 0;
    memset(match, -1, sizeof(match));
    for (int v=0; v < V; v++) {
        if (match[v] < 0) {
            memset(used, 0, sizeof(used));
            if (dfs(v)) {
                res++;
            }
        }
    }
    return res;
}

struct point {
    int x;
    int y;
};

int main() {
    int N;
    cin >> N;

    V = N;

    vector<point> red(N), blue(N);
    for (int i=0; i<N; i++) {
        cin >> red[i].x >> red[i].y;
    }
    for (int i=0; i<N; i++) {
        cin >> blue[i].x >> blue[i].y;
    }

    // 辺を作る
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            if (red[i].x < blue[j].x && red[i].y < blue[j].y) {
                add_edge(i, N+j);
            }
        }
    }

    cout << bipartite_matching() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 3001
using namespace std;
int w,h;
int dx[]={0,1,0,-1};//^>v<
int dy[]={-1,0,1,0};
vector<int> X,Y,d;
unordered_map<int,int> x,y;
int mp[N][N];

int compless(vector<int> A,unordered_map<int,int> &M){
  sort(A.begin(),A.end());
  int c=0;
  for(int i=0;i<A.size();i++)if(!M.count(A[i]))M[A[i]]=c++;
  return c;
}

int calc(int y,int x){
  bool used[N][N]={};
  int res=0;
  while(1){
    res++;
    int i=mp[y][x];
    used[y][x]=1;
    while(1){
      y+=dy[i],x+=dx[i];
      if(y<0||x<0||x>=w||y>=h)return res;
      if(mp[y][x]!=-1&&!used[y][x])break;
    }
  }
  assert(0);
}

int main(){
  int n;
  cin>>n;
  X.resize(n),Y.resize(n),d.resize(n);
  for(int i=0;i<n;i++){
    char ch;
    cin>>X[i]>>Y[i]>>ch;
    if(ch=='^')d[i]=0;
    if(ch=='>')d[i]=1;
    if(ch=='v')d[i]=2;
    if(ch=='<')d[i]=3;
  }
  h=compless(Y,y);
  w=compless(X,x);
  
  memset(mp,-1,sizeof(mp));
  for(int i=0;i<X.size();i++)mp[y[Y[i]]][x[X[i]]]=d[i];
  int ans=1;
  for(int i=0;i<n;i++)ans=max(ans,calc(y[Y[i]],x[X[i]]));
  cout <<ans<<endl;

  return 0;
}

Measured memory_bytes: 47272
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
	string s;
	string ans="";
	cin >> s;
	for(int i=0;i<s.size();i=i+2){
		ans+=s[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
 public static void main(String[] args) throws IOException {
   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
   int a = Integer.parseInt(reader.readLine());
   long result = a + a * a + a * a * a;
   System.out.println(result);
 }
}


Measured memory_bytes: 32544
#include <iostream>
#include <memory>

class Casher
{
private:
	const int price;
public:
	Casher() = default;
	Casher(const int& price) :price(price) {}

	int calc()
	{
		return (price % 1000) ? 1000 - (price % 1000) : 0;
	}
};

int main(void)
{
	int price = 0;
	std::cin >> price;

	std::shared_ptr<Casher> casher(new Casher(price));
	std::cout << casher->calc() << std::endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;


void solve(long long N, std::vector<long long> X){
    vector<pair<long long, int>> Xi(N);
    vector<long long> ans(N);
    for(int i=0; i<N; i++)Xi[i] = make_pair(X[i], i);
    sort(Xi.begin(), Xi.end());
    for(int i=0; i<N; i++)ans[Xi[i].second] = (i<=N/2-1 ? Xi[N/2].first : Xi[N/2-1].first);
    for(auto a: ans)cout << a << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

int f[45];

int fib(int n)
{
	if(n==0 || n==1) return f[n]=1;
	if(f[n]!=-1) return f[n];
	return f[n]=fib(n-1)+fib(n-2);;
}

int main()
{
	int n;
	
	cin >> n;
	for(int i=0;i<=44;i++) f[i]=-1;
	cout << fib(n) << endl;
	return 0;
}

Measured memory_bytes: 3084
package main

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

var (
	D int
	c [26]int
	s [365][26]int
)

func main() {
	readVariables()
	for row := 0; row < D; row++ {
		fmt.Println(maxGreed(row))
	}
}

func maxGreed(row int) int {
	max := 0
	result := 0
	for i, v := range s[row] {
		if v > max {
			result = i
			max = v
		}
	}
	return result + 1
}

func readVariables() {
	D = nextInt()
	for i := 0; i < 26; i++ {
		c[i] = nextInt()
	}
	for i := 0; i < D; i++ {
		for j := 0; j < 26; j++ {
			s[i][j] = nextInt()
		}
	}
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 1980
<?php
	fscanf(STDIN, "%d", $n);
	$count = strlen($n);
	$sn = 0;
	for($i=0;$i<$count;$i++)
	{
		$sn += substr($n, $i, 1);	
	}
	if($n%$sn==0){
		echo "Yes";
	}else{
		echo "No";
	}
?>

Measured memory_bytes: 3828
def main():
    import collections
    import sys
    input = sys.stdin.readline
    n = int(input())
    d = list(map(int, input().split()))
    c = collections.Counter(d)
    ans = 1
    tmp = -1
    if d[0] != 0 or c[0] > 1:
        print(0)
        exit()
    for i in range(2, n):
        if i - 1 in c.keys():
            ans *= c[i - 1] ** c[i]
            ans %= 998244353
        else:
            tmp = i
            break
    if tmp >= 0:
        for j in range(tmp, n):
            if j in c.keys():
                print(0)
                exit()
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
sim > struct rge
{
        c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
        ~debug()
        {
                cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
        ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
                *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
}
#else
        sim dor(const c &)
        {
                ris;
        }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

const ll MOD = 1e9 + 7;

void solve()
{
        ll a, b; cin >> a >> b;
        if (abs(a - b) >= 2)
        {
                cout << 0 << endl;
                return;
        }
        ll res = 1;
        for (int i = 1; i <= a; ++i)
        {
                res = res * i % MOD;
        }
        for (int i = 1; i <= b; ++i)
        {
                res = res * i % MOD;
        }
        if (abs(a - b) == 0)
                res = res * 2 % MOD;
        cout << res % MOD;
}

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


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int INF = 1001001001;
const int MOD = 1000000007;

// auto MOD int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination MOD prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  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;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

int modPow(long long a, long long n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main() {

    int N;
    cin >> N;
    
    vector<int> A;

    rep(i,N) {
        int a;
        cin >> a;
        if (i==0) {
            A.push_back(a);
        }
        else if (A.back()!=a) {
            A.push_back(a);
        }
    }

    int l = A.size();

    ll dp[l] = {};
    dp[0] = 1;
    map<int,int> place;
    place[A[0]] = 0;
    rep(i,l-1) {
        if (place.count(A[i+1])) {
            int idx = place[A[i+1]];
            dp[i+1] = dp[idx] + dp[i];
            //cout << i << " " << idx << " " << dp[i+1] << endl;
        }
        else {
            dp[i+1] = dp[i];
        }
        if (A[i]!=A[i+1]) {
            place[A[i+1]] = i+1;
        }
        dp[i+1] %= MOD;
    }

    cout << dp[l-1] << endl;



}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

int a, b, c, d, e;
int f(int t) {
	int ret = 0;
	if (t < 0)ret += -t*c, t = 0;
	if (t == 0)ret += d;
	ret += (100 - t)*e;
	return ret;
}

signed main() {
	cin >> a >> b >> c >> d >> e;
	cout << (f(a)-f(b)) << endl;
	return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int cnt[4] = {0,0,0,0};
  string str;
  while(getline(cin, str)) {
    int i;
    for(i = 0; i < str.size() && str[i] != ','; ++i);
    str = str.substr(i+1);
    int id;
    if(str == "A") id = 0;
    else if(str == "B") id = 1;
    else if(str == "AB") id = 2;
    else id = 3;
    ++cnt[id];
  }
  for(int i = 0; i < 4; ++i) cout << cnt[i] << endl;
  return 0;
}

Measured memory_bytes: 0
import itertools
from sys import stdin
input = stdin.readline


def main():
  H, W, K = list(map(int, input().split()))
  map_ = [input()[:-1] for _ in range(H)]
  # print(map_)
  hseq = range(H)
  wseq = range(W)
  hcomb = []
  wcomb = []
  for i in range(H):
    hcomb.extend(list(itertools.combinations(hseq, i)))
  for i in range(W):
    wcomb.extend(list(itertools.combinations(wseq, i)))

  # print(hcomb)
  # print(wcomb)
  num_comb = 0
  for i in range(len(hcomb)):
    for j in range(len(wcomb)):
      cnt = 0
      # print(hcomb[i], wcomb[j])
      if not(len(hcomb[i]) or len(wcomb[j])):
        for hh in range(H):
          for ww in range(W):
            if map_[hh][ww] == '#':
              cnt += 1

      if not len(hcomb[i]):
        # print('h')
        for hh in range(H):
          for ww in wcomb[j]:
            if map_[hh][ww] == '#':
              cnt += 1

      elif not len(wcomb[j]):
        # print('w')
        for hh in hcomb[i]:
          for ww in range(W):
            if map_[hh][ww] == '#':
              cnt += 1

      else:
        for hh in hcomb[i]:
          for ww in wcomb[j]:
            if map_[hh][ww] == '#':
              cnt += 1
      if cnt == K:
        # print(i, j)
        num_comb += 1

  print(num_comb)


if(__name__ == '__main__'):
  main()

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll res = 0;
    REPS(i,n){
      	int d = n / i;
        res += i * d * (d+1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline
n = int(input())
edges = [[]for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((c, b))
    edges[b].append((c, a))
INF = float('inf')


def dfs(init_v):
    dist = [INF]*n
    dist[init_v] = 0
    tasks = [(0, init_v)]
    while tasks:
        d, v = tasks.pop()
        for d2, v2 in edges[v]:
            if dist[v2] <= dist[v]+d2:
                continue
            dist[v2] = dist[v]+d2
            tasks.append((dist[v2], v2))
    return dist


q, k = map(int, input().split())
dist = dfs(k-1)
for _ in range(q):
    x, y = map(lambda x: int(x)-1, input().split())
    print(dist[x]+dist[y])

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


int main() {
    vector<vector<int>>data(3,vector<int>(3));
    rep(i,3){
        rep(j,3)cin>>data[i][j];
    }
    vector<int>b(3);
     b[0]=data[0][0];
     b[1]=data[0][1];
     b[2]=data[0][2];
     vector<int>a(3);
     a[0]=0;
     a[1]=data[1][1]-b[1];
     a[2]=data[2][2]-b[2];

    rep(i,3){
        rep(j,3){
            if(data[i][j]!=a[i]+b[j]){
                cout<<"No"<<endl;
                return 0;
        }
    }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
while True:
  d, w,h =list(map(int, input().split()))
  if d ==0 and w==0 and h==0:
    break
  m = min(d*d+w*w, d*d+h*h, w*w+h*h)
  
  for i in range(int(input())):
    r = int(input())
    if (2*r)**2 >m:
      print("OK")
    else:
      print("NA")
  


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a == "SUN")
    cout << 7 << endl;
  else if(a == "MON")
    cout << 6 << endl;
  else if(a == "TUE")
    cout << 5 << endl;
  else if(a == "WED")
    cout << 4 << endl;
  else if(a == "THU")
    cout << 3 << endl;
  else if(a == "FRI")
    cout << 2 << endl;
  else if(a == "SAT")
    cout << 1 << endl;
  }


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};

void solve() {
  int w, h;
  while (cin >> w >> h, w) {
    int sx, sy, gx, gy, n;
    cin >> sx >> sy >> gx >> gy >> n;
    sx--, sy--, gx--, gy--;
    vvi v(h, vi(w));
    rep(i, n) {
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      x--;
      y--;
      rep(i, 2 + d * 2) rep(j, 4 - d * 2) v[y + i][x + j] = c;
    }
    int roadColor = v[sy][sx];
    function<bool(int, int)> dfs = [&](int i, int j) {
      if (i < 0 || j < 0 || i >= h || j >= w || v[i][j] != roadColor) return false;
      if (i == gy && j == gx) return true;
      v[i][j] = -1;
      bool b  = false;
      rep(k, 4) b |= dfs(i + di[k], j + dj[k]);
      return b;
    };
    cout << (dfs(sy, sx) ? "OK" : "NG") << endl;
  }
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

int lg2(int x) {
    int ans = 0;
    while(x > 0 ) {
        x /= 2;
        ans++;
    }
    return ans;
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    int x = b / a;
    int ans = lg2(x);
    cout << ans << "\n";
}


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

string S;
int num_char[26];

int main() {
	// your code goes here
	for(int i = 0; i < 26; i++){
		num_char[i] = 0;
	}
	cin >> S;
	for(int i = 0; i < S.length(); i++){
		num_char[S[i] - 'a']++;
	}
	bool def = true;
	for(int i = 0; i < 26; i++){
		if(num_char[i] >= 2) def = false;
	}
	cout << (def ? "yes" : "no") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll a[2*MAX];
ld A[2*MAX];
ll n,k;
int main(){FAST;
  dofloat;
cin>>n>>k;
for(ll i=1;i<=n;++i){
  cin>>a[i];
}
ld temp = 0;
ld ans = 0;
for(ll i=1;i<=k;++i){
  temp+=(ld)(a[i]+1)/2;
}
ans = max(ans,temp);
for(ll i=k+1;i<=n;++i){
  temp-=(ld)(a[i-k]+1)/2;
  temp+=(ld)(a[i]+1)/2;
  ans = max(ans,temp);
}
cout<<ans;
return 0;
}

Measured memory_bytes: 2944