akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
main()
{
	int tate, yoko, i, j;



	while(1){
		scanf("%d %d", &tate, &yoko);
		if(tate == 0 && yoko == 0){
			break;
		}

		for(i = 0; i < tate; i++){
			for(j = 0; j < yoko; j++){
				if( (i > 0 && i < tate-1) && (j > 0 && j < yoko-1) ){
					printf(".");
				}else{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
typedef long long ll;

ll n;
ll a, c;
ll b, d;
char str[200005];

_Bool f(ll s, ll t);
_Bool g(ll s, ll t);

int main()
{
    scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
    scanf("%s", str + 1);

    if (c < d) {
        if (f(a, c + 1) &&
            f(b, d + 1)) {
            puts("Yes");
        }
        else {
            puts("No");
        }
    }
    else {
        if (f(a, c + 1) &&
            f(b, d + 1) &&
            g(b, d + 1)) {
            puts("Yes");
        }
        else {
            puts("No");
        }
    }

    return 0;
}

_Bool f(ll s, ll t)
{
    for (ll i = s; i < t - 1; i++) {
        if (str[i] == '#' &&
            str[i + 1] == '#') {
            return 0;
        }

        if (str[i] == '#' &&
            str[i - 1] == '#') {
            return 0;
        }
    }

    return 1;
}

_Bool g(ll s, ll t)
{
    for (ll i = s; i < t; i++) {
        if (str[i] == '#') continue;

        if (str[i - 1] == '.' &&
            str[i] == '.' &&
            str[i + 1] == '.') return 1;
    }
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    map<ll, int> mp;
    vector<ll> v;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
        if (mp[a] == 2) v.push_back(a);
        if (mp[a] == 4) v.push_back(a);
    }
    sort(all(v), greater<ll>());
    if (sz(v) < 2)
        cout << 0 << endl;
    else
        cout << v[0] * v[1] << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int n;
int a[110000];
int L;
int k;
int f[110000][38];
int main() 
{
//	freopen("string.in","r",stdin);
//	freopen("string.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
    cin>>L>>k;
    for(int i=1;i<=n;i++)
    {
    	int sum=upper_bound(a+1,a+1+n,a[i]+L)-a-1;
    	if(a[i]+L>=a[n])
    	{
    		f[i][0]=n;
    	}
    	else 
    	{
    		f[i][0]=sum;
    	}
    }
	for(int i=1;i<=30;i++)
	{
		for(int j=1;j<=n;j++)
		{
			f[j][i]=f[f[j][i-1]][i-1];
		}
	}
//    for(int i=1;i<=k;i++)
//    {
//    	cin>>x>>y;
//    }
	while(k--)
	{
		int x;
		int y;
		cin>>x>>y;
		if(y<x)
		swap(x,y);
		long long ans=0;
        for(int i=30;i>=0;i--)
        {
            if(f[x][i]<y)
            {
                ans+=1ll<<i;
                x=f[x][i];
            }
        }
        printf("%lld\n",ans+1);
	}
    return 0;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	int K = 0;
	rep(i, 100000) {
		K += A;
		if (K % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		if(N==1) {
			System.out.println(0);
			return;
		}
		if(N==2) {
			System.out.println(2);
			return;
		}

		long A = (long) 1;
		long B = (long) 2;
		long C = (long) 1;
		long limit = (long) Math.pow(10,9) + 7;

        for(int i = 0; i < N; i++) {
			A *= 10;
			if(A > limit) {
				A = A%limit;
			}
		}
		for(int i = 0; i < N; i++) {
			B *= 9;
			if(B > limit) {
				B = B%limit;
			}
		}
		for(int i = 0; i < N; i++) {
			C *= 8;
			if(C > limit) {
				C = C%limit;
			}
		}
		
		long result = A - B + C;
      
      	if(result > limit) {
			result = result%limit;
		}
      	if(result < 0) {
			result = result + limit;
		}

		System.out.println(result);
		return;
	}

}


Measured memory_bytes: 35772
#include<bits/stdc++.h>
using namespace std;
/*ans code*/
typedef long long ll;
const ll INF = 1e9; 
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);//cin,cout同期切る
  ios::sync_with_stdio(false);//iostream,stdio同期切る
  
  ll n,sum,ans=INF;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  REP(i,-100,101){//-100から100まで(a-i)**2して加算,総和を比較
    sum = 0;
    rep(j,n){
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans, sum);
  }
  cout << ans << "\n";
  return 0;
}
/*my code*/
/*int main(){
  vector<int> v(104);
  int n=0;
  int ans_s=0;
  int sum=0;
  cin >> n;
  rep(i,n){ cin >> v.at(i);sum+=v.at(i); }
  int mean_num = round(sum/n);
  cout << mean_num << endl;
  rep(i,n){ ans_s += (v.at(i)-mean_num)*(v.at(i)-mean_num);}
  cout << ans_s << endl;
}*/ 


Measured memory_bytes: 256
val MOD = 1000000007

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toLong() }

    val aaSum = aa.sum()

    var ans = 0L
    var sum = 0L

    for (i in 0 until n-1) {
        sum += aa[i]
        ans += (aa[i] * ((aaSum - sum)%MOD)) % MOD
        ans %= MOD
    }

    println(ans)
}

Measured memory_bytes: 64996
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
MATCHES = [[(0,0) for _ in range(N-1)] for _ in range(N)]

for i in range(N):
    lis = LI()
    for j in range(N-1):
        if i+1 < lis[j]:
            MATCHES[i][j] = (i+1, lis[j])
        else:
            MATCHES[i][j] = (lis[j], i+1)

CONT = True
IDXS=[0]*N
days = 0
ST=set()

next_check = range(N)
while CONT:
    cont = False
    _next_check = []
    for i in next_check:
        if IDXS[i] < N-1:
            pair = MATCHES[i][IDXS[i]]
            p, q = pair
            if pair in ST:
                ST.remove(pair)
                # print("{}: {}".format(days, pair))
                if IDXS[i] < N-1:
                    IDXS[p-1] += 1
                    IDXS[q-1] += 1
                    cont = True
                    _next_check.append(p-1)
                    _next_check.append(q-1)
            else:
                ST.add(pair)
    next_check = _next_check
    CONT = cont
    days += cont

# print(IDXS)
if sum(IDXS) == N*(N-1):
    print(days)
else:
    print(-1)


Measured memory_bytes: 82524
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,a,b;
    cin>>n>>a>>b;
    int c=a+b;
    int kaisuu=n/c;
    int ans=kaisuu*a;
    int memo=n-kaisuu*c;
    if(memo>=a){
        ans+=a;
    }
    else{
        ans+=memo;
    }
    cout<<ans<<endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int r= sc.nextInt();
		int K = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i=0;i<10;i++){
			x=x*r-K;
			System.out.println(x);
		}

	}
}


Measured memory_bytes: 21204
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    string s, t; cin >> s >> t;
    ll n = sz(s);
    ll c = 0;
    rep(i, 0, n){
        if(s[i] != t[i]){
            c++;
        }
    }
    prt(c);
}




Measured memory_bytes: 3860
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void a_sharing_cookies(void) {
	int a, b;
	cin >> a >> b;

	if (a % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if (b % 3 == 0) {
		cout << "Possible" << endl;
	}
	else if ((a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
}

int main()
{
    a_sharing_cookies();
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[110000][2];
const int mod = 1000000007;
signed main(){
    string s;cin>> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n)rep(j,2){
        if(s[i] == '0'){
            dp[i+1][j] += dp[i][j];
            if(j == 1)dp[i+1][j] += dp[i][j]*2;
            dp[i+1][j] %= mod;
        }
        else if(s[i] == '1'){
            dp[i+1][1] += dp[i][j];
            dp[i+1][j] += dp[i][j]*2;
            dp[i+1][j] %= mod;
            dp[i+1][1] %= mod;
        }
    }
    cout << (dp[n][0] + dp[n][1])%mod << endl;
    return 0;
}

Measured memory_bytes: 5276
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

ll solve(int N) {

  static ll dp[2][1<<16]; zero(dp);
  ll res = 0;

  rep(i, N) {
    int M; ll L; scanf("%d%lld",&M,&L);

    int bit = 0;
    rep(_, M) {
      int s, t; scanf("%d%d",&s,&t); s -= 6, t -= 6;
      bit |= ((1<<t)-1) - ((1<<s)-1);
    }

    rep(S, 1<<16) {
      maximize(dp[(i+1)&1][S], dp[i&1][S]);
      if((S ^ bit) == (S + bit)) {
        int nS = S ^ bit;
        maximize(dp[(i+1)&1][nS], dp[i&1][S] + L);
        maximize(res, dp[(i+1)&1][nS]);
      }
    }
  }
  return res;
}

int main() {

  for(int N; ~scanf("%d", &N) && N;) {
    printf("%lld\n", solve(N));
  }
  
  return 0;
}

Measured memory_bytes: 4200
import java.util.*;

class Solver {
  int[] x;
  long[][][] cache;
  Solver(int[] x) {
    this.x = x;
    this.cache = new long[64][64][4096];
    for (int i = 0; i < 64; i++) {
      for (int j = 0; j < 64; j++) {
        for (int k = 0; k < 4096; k++) {
          cache[i][j][k] = -1;
        }
      }
    }
  }

  long count(int index, int rest, int target) {
    if (cache[index][rest][target] >= 0) {
      return cache[index][rest][target];
    }
    if (rest == 0 && target > 0) {
      cache[index][rest][target] = 0;
      return cache[index][rest][target];
    }
    if (rest == 0 && target == 0) {
      cache[index][rest][target] = 1;
      return cache[index][rest][target];
    }
    if (x.length - index < rest) {
      cache[index][rest][target] = 0;
      return cache[index][rest][target];
    }
    cache[index][rest][target] = 0;
    for (int i = index; i < x.length; i++) {
      if (target - x[i] < 0) {
        continue;
      }
      cache[index][rest][target] += count(i+1, rest-1, target-x[i]);
    }
    return cache[index][rest][target];
  }

  long solve(int a) {
    long sum = 0;
    for (int i = 1; i <= x.length; i++) {
      sum += count(0, i, a*i);
    }
    return sum;
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int a = s.nextInt();
    int[] x = new int[n];
    for (int i = 0; i < n; i++) {
      x[i] = s.nextInt();
    }
    Solver solver = new Solver(x);
    System.out.println(solver.solve(a));
  }
}


Measured memory_bytes: 148732
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.ReadInt;
            var k = IO.ReadInt;

            var ans = 1;
            for (int i = 0; i < n; i++)
            {
                if (ans <= k)
                    ans *= 2;
                else
                    ans += k;
            }
            WriteLine(ans);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 13140
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

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


	int N, K;
	cin >> N >> K;

	int A[100000];
	rep(i, N) cin >> A[i];
	sort(A, A + N);

	ll kotae = 0;
	for (int i = K - 1; i < N; i++) {
		kotae += (ll)f.comb(i, K - 1) * A[i] % mod;
	}
	kotae %= mod;
	for (int i = N - K; i >= 0; i--) {
		kotae -= (ll)f.comb(N - i - 1, K - 1) * A[i] % mod;
	}
	kotae %= mod;

	co((kotae + mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <math.h>

#define ABS(X) \
  ( (X) < 0 ? -(X) : (X) )

double
getArea (
  jmp_buf co
  )
{
  double res = 0.;
  int remainder = 360;
  int n;

  scanf ( "%d", &n );
  if ( n == 0 ) longjmp ( co, 1 );

  n -= 1;
  while ( n-- )
  {
    int th;

    scanf ( "%d", &th );
    res += sin ( th * M_PI / 180. );
    remainder -= th;
  }
  res += sin ( remainder * M_PI / 180. );

  return ( res );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  jmp_buf cont;

  if ( setjmp ( cont ) == 0 )
  for ( ; ; )
  {
    double s1, s2;

    s1 = getArea ( cont );
    s2 = getArea ( cont );

    if ( ABS( s1 - s2 ) < 1e-6 )  puts ( "0" );
    else if ( s1 >  s2 )          puts ( "1" );
    else                          puts ( "2" );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
#define FOR(i,a,b) for(LL i=(a);i<(LL)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define FF first
#define SS second
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr> PQ;
const ut INF=1LL<<60;
const LL p=3+1e6;
const int SIZE=505;

int H,W;
int maps[SIZE][SIZE];
int main(){
	cin >> H >> W;
	REP(i,H){
		string s;
		cin >> s;
		REP(j,s.size()){
			maps[i][j]=s[j]=='#';
		}
	}
	FOR(i,0,H){
		REP(j,W){
			if(i!=H-1&&(maps[i][j] || i==0 || (j%2==1))){
				cout << '#';
			}
			else{
				cout << '.';
			}
		}
		cout << endl;
	}
	cout << endl;
	FOR(i,0,H){
		REP(j,W){
			if(i!=0 &&(maps[i][j] || i==H-1 || (j%2==0))){
				cout << '#';
			}
			else{
				cout << '.';
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    long long int w,h,x,y;
    cin >> w >> h >> x >> y;
    double square;
    square = (double)w*h/2;

    bool flag;
    if((w%2==0 && x==w/2) && (h%2==0 && y==h/2))
        flag=true;
    else
        flag=false;

    printf("%lf ",square);
    if(flag)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var k, x int 
  fmt.Scan(&k, &x)
  l := maxInt(-1e6, x - (k - 1))
  r := minInt(1e6, x + (k - 1))
  for i := l; i < r + 1; i++ {
    fmt.Print(i)
    tail := " "
    if i == r {tail = "\n"}
    fmt.Print(tail)
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int n,x;cin >> n >> x;
    int ret=0;
    int mi=1e5;
    for(int i=0;i<n;i++){
        int m;cin >> m;
        x-=m;
        ret++;
        mi=min(mi,m);
    }
    p(ret+x/mi)
}

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

int main() {
  vector<string> vec(26);
  string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  string S;
  
  cin >> N;
  cin >> S;
  
  for (int i=0;i<S.size();i++){
    bool flg = true;
    for (int j=0;j<26&&flg==true;j++){
      if (S.at(i)==alp.at(j)){
        if (j + N >=26){
          S.at(i) = alp.at(j + N - 26);
          flg = false;
        }
        else{
          S.at(i) = alp.at(j + N);
          flg = false;
        }
      }
    }
  }
  cout << S << endl;
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
kasanari = Counter(a).most_common()[0][0]
mod = 10**9+7
"""
2 3 1 4 5 6 1 7 8 9
Y Y C C C C C X X X
k個選ぶ. 全部 nCk-3Ck
"""
basho = []
for cnt, i in enumerate(a):
	if i == kasanari:
		basho.append(cnt)

def cmb(n, r, mod):
	if (r < 0) or (n < r):
		return 0
	r = min(r, n-r)
	return fact[n]*factinv[r]*factinv[n-r]%mod

N = 2*10**5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+1):
	fact.append((fact[-1]*i)%mod)
	inv.append((-inv[mod%i]*(mod//i))%mod)
	factinv.append((factinv[-1]*inv[-1])%mod)

for i in range(1, n+2):
	print((cmb(n+1, i, mod)-cmb(n-basho[1]+basho[0], i-1, mod))%mod)

Measured memory_bytes: 40592
# https://atcoder.jp/contests/abc061/tasks/abc061_b



N, M = gets.split.map(&:to_i)

hash = Hash.new(0)
M.times do
  a, b = gets.split.map(&:to_i)
  hash[a] += 1
  hash[b] += 1
end

(1..N).each do |i|
  puts hash[i]
end


Measured memory_bytes: 1788
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    r,g,b,n=parseMap(split(readline()))
    ans=0
    for i in 0:n
        for j in 0:n
            if 0<=n-i*r-j*g && (n-i*r-j*g)%b==0
                ans+=1
            end
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 166988
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;

use std::cmp;
use std::collections::BTreeMap;

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<isize>();
    let mut ans = 0;
    let mut map = BTreeMap::new();

    for z in v {
        let p = map.entry(z).or_insert(0);
        *p += 1;
    }

    for (i, x) in &map {
        let mut ans_buf = 0;
        if map.contains_key(&(i - 1)) {
            ans_buf += map[&(i - 1)];
        }
        if map.contains_key(&(i + 1)) {
            ans_buf += map[&(i + 1)];
        }
        ans_buf += *x;
        ans = cmp::max(ans, ans_buf);
    }
    p(ans);
}

Measured memory_bytes: 6396
#include<cstdio>
#include<cmath>
int main(void){
	
	int i,j,n,c=0,b;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0;i<n-1;i++){
		for(j=0;j<n-1;j++){
			if(a[j]>a[j+1]){
				c++;
				b=a[j];
				a[j]=a[j+1];
				a[j+1]=b;
			}
		}
	}

	for(i=0;i<n-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n-1]);
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
#define N 500
#define ll long long
const ll mod = 1e9+7 ; 

ll n , m ;
ll a[ N ] , b[ N ] ;
ll sum[ N ][ N ] , l[ N ][ N ] ;
ll f[ N ][ N ] ;
int main() {
    scanf( "%lld%lld" , &n ,&m ) ;
    for( int i = 1 ; i <= n ; i ++ ) {
        scanf( "%lld" , &a[ i ] ) ;
    }
    for( int i = 1 ; i <= n ; i ++ ) {
        scanf( "%lld" , &b[ i ] ) ;
    }
    for( int i = 1 ; i < N ; i ++ ) {
        l[ i ][ 0 ] = 1 ;
        for( int j = 1 ; j < N ; j ++ ) {
            l[ i ][ j ] = l[ i ][ j - 1 ] * i  ;
            l[ i ][ j ] %= mod ;
        }
    }
    for( int i = 1 ; i < N ; i ++ ){
        for( int j = 0 ; j < N ; j ++ ) {
            sum[ i ][ j ] += sum[ i - 1 ][ j ] + l[ i ][ j ] ;
            sum[ i ][ j ] %= mod ;
        }
    } 
    f[ 0 ][ 0 ] = 1 ;
    for( int i = 1 ; i <= n ; i ++ ) {
        for( int j = 0 ; j <= m ; j ++ ) {
            for( int k = 0 ; k <= j ; k ++ ) {
                f[ i ][ j ] = ( f[ i ][ j ] % mod + ( 1ll * f[ i - 1 ][ j - k ] *( ( sum[ b[ i ] ][ k ] - sum[ a[ i ] - 1 ][ k ] ) % mod )  + mod ) % mod + mod ) % mod  ;
            }
        } 
    } 
    printf( "%lld\n" , f[ n ][ m ] ) ;
    return 0 ;
} 


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
//#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (register int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (register int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
long long n,m,i,j,s,c,x,ans;
int main()
{
	cin>>n;
	rep(i,n){
		cin>>x>>c;
		s+=x*c;ans+=c;
	}
	ans--;
	cout<<ans+(s-1)/9<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int my_re(int64_t x)
{
  if(x%26==0)
    return 26;
  else
    return x%26;
}
int main()
{
  int64_t n,p;
  cin>>n;
  p=n;
  vector<int64_t> a;
  while(p!=0)
  {
    a.push_back(my_re(p));
    p=(p-my_re(p))/26;
  }
  reverse(a.begin(),a.end());
  for(int i=0;i<a.size();i++)
  {
    a.at(i)+=96;
    cout<<(char)a.at(i);
  }
}

Measured memory_bytes: 3596
def cin():
	return map(int,input().split())

def cina():
  return list(map(int,input().split()))

a,b = cin()
a = list(str(a))
x = []
for i in a:
    x.append(int(i))
c = cina()
d = {0,1,2,3,4,5,6,7,8,9}
e = d.difference(c)
s = ""
index = -1
test = 0
no = 0
for i in range(len(x)):
    check = False
    for j in c:
        if x[i]==j:
            check = True
    if check:
        for j in e:
            if j>x[i]:
                if test==0:
                    x[i] = j
                    index = i
                test += 1
                break
    else:
        no += 1

if no==len(x):
    for i in x:
        s += str(i)
elif test==0:
    q = e.difference({0})
    g = list(q)
    g.sort()
    s += str(g[0])
    ap = ""
    if 0 in e:
        ap = '0'*len(a)
    else:
        ap = str(g[0])*len(a)
    s += ap
else:
    w = list(e)
    for i in range(0,index+1):
        s += str(x[i])
    ap = str(w[0])*(len(x)-index-1)
    s += ap

print(s)



# if len(f)==0:
#     q = e.difference({0})
#     g = list(q)
#     g.sort()
#     s = ""
#     s += str(g[0])
#     ap = ""
#     if 0 in e:
#         ap = '0'*len(a)
#     else:
#         ap = str(g[0])*len(a)
#     s += ap

# s = ""
# check = False
# for i in a:
#   replace = False
#   rep = -1
#   for j in range(len(c)):
#     if int(i)==c[j]:
#       replace = True
#       break
#   if replace:
#     for k in e:
#       if k>int(i):
#         rep = k
#         break
#   else:
#     rep = i  
#   if rep == -1 and not check:
#   	check = True
#   s += str(rep)
# if check:
#   f = e.difference({0})
#   g = list(f)
#   g.sort()
#   s = ""
#   s += str(g[0])
#   ap = ""
#   if 0 in e:
#     ap = '0'*len(a)
#   else:
#     ap = str(g[0])*len(a)
#   s += ap
# else:

  
# print(s)


Measured memory_bytes: 3064
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();
		int n4 = sc.nextInt();

		int[] cnt = new int[10];
		cnt[n1]++;
		cnt[n2]++;
		cnt[n3]++;
		cnt[n4]++;
		
		if (cnt[1] == 1 && cnt[9] == 1 && cnt[7] == 1 && cnt[4] == 1) {
			pr.println("YES");
		} else {
			pr.println("NO");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c; cin >> a >> b >> c;
  int k; cin >> k;
  int cnt = 0;
  while(b <= a) {
    cnt++;
    b *= 2;
  }
  while(c <= b) {
    cnt++;
    c *= 2;
  }
  cout << (cnt<=k ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3608
from functools import reduce
from itertools import combinations
import copy

N = int(input())
S = {key: 0 for key in 'MARCH'}
for _ in range(N):
  s = input()
  if s[0] in S:
    S[s[0]] += 1

newS = copy.deepcopy(S)
keys = []
for key, value in S.items():
  if value == 0: del newS[key]
  else: keys.append(key)

if len(newS) < 3:
  print(0)
  exit()
  
ans = 0
for cmb in combinations(keys,3):
  ans += reduce(lambda x,y: x*y, [newS[idx] for idx in cmb])
print(ans)

Measured memory_bytes: 43864
using System;
  
namespace Aizu
{
    class OnlineJudge
    {
        const int Max = 1000000;
        static void Main()
        {
            var p = new int[Max];
            int c = p[2] = 1;
            for(int i=3; i < Max; i += 2) {
                if(p[i] == 0) {
                    ++c;
                    if(i <= 1000) {
                        int s;
                        for(int l = i; ; l += (l & 1) + 1) {
                            if((s = i * l) >= Max) {
                                break;
                            }
                            p[s] = -1;
                        }
                    }
                }
                p[i] = c;
            }
            string n;
            while((n = Console.ReadLine()) != null) {
                int v = int.Parse(n);
                if(v != 2 && (v & 1) == 0) {
                    --v;
                }
                Console.WriteLine(p[v]);
            }
        }
    }
}

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define first fi
#define second se
#define REP(i,n) for(int i=0;i<n;++i)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Q queue
#define V vector

void m1(){
  string s,t; scan2(s,t);
  int res = 0;
  for(int i=0;i<s.length();++i){
  	if(s[i] != t[i]) ++res;
  }
  print(res);
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
int main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

Measured memory_bytes: 3776
using System;
using System.Linq;
class ASOi{
static void Main(){
while(true){
int a=int.Parse(Console.ReadLine());
if(a==0){break;}int sum=0;
 
while(a!=1){
if(a%2==0){a=a/2;}
else {a=a*3+1;}
sum++;
}
Console.WriteLine(sum);
 
 
 
}
 
 
 
}
}

Measured memory_bytes: 9008
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn clear_all(monsters: &[i64], a: i64, b: i64, n: i64) -> bool {
    let num: i64 = monsters
        .iter()
        .filter(|&v| v - n * b > 0)
        .map(|v| ((v - n * b) + (a - b) - 1) / (a - b))
        .sum();
    num <= n
}

fn main() {
    let (n, a, b) = scan!(i64, i64, i64);
    let monsters = scan!(i64;n);

    let mut left = 0;
    let mut right = 1_000_000_000;
    while left < right - 1 {
        let mid = (left + right) / 2;
        if clear_all(&monsters, a, b, mid) {
            right = mid;
        } else {
            left = mid;
        }
    }
    println!("{}", right);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n){
    for(int i = 0; n > i; i++)par[i] = i;
  }

  int root(int n){
    if(par[n] == n)return n;
    return par[n] = root(par[n]);
  }

  void unite(int a,int b){
    int ra = root(a);
    int rb = root(b);
    if(ra==rb)return;
    par[ra] = rb;
  }

  bool same(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
	int n,m;cin>>n>>m;
	vector<int> Z(n);
	UnionFind A(n);
	for(int i = 0; n > i; i++){
		cin>>Z[i];
	}
	for(int i = 0; m > i; i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		A.unite(x,y);
	}
	map<int,map<int,int> > B;
	for(int i = 0; n > i; i++){
		B[A.root(i)][i]++;
		B[A.root(i)][Z[i]-1]++;
	}
	int ans = 0;
	for(auto x:B){
		for(auto y:x.second){
			if(y.second==2)ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
#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;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const int INF=1000;

int main(){
  ll k;
  cin>>k;
  int sum=0;
  rep1(i,k){
    rep1(j,k){
      rep1(l,k){
        int a=max(max(i,j),l);
        int b=min(min(i,j),l);
        int c=(i+j+l)-(a+b);
        int now=1;
        while(now!=0){
          now=a%b;
          a=b;
          b=now;
          }
        
        now=1;
        int d=max(c,a);
        int e=min(c,a);
        while(now!=0){
          now=d%e;
          d=e;
          e=now;
        }
        sum+=int(d);
        
      }
    }
  }
  cout <<sum<<endl;
  
}

Measured memory_bytes: 3564
#include <cassert>
#include "limits.h"
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename H,typename... T>
void debug_out(H head,T... tail){
  std::cerr<<" "<<head;
  debug_out(tail...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long,long long>;

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

  ll n,k;
  std::cin>>n>>k;

  std::vector<ll> cnt;

  for(ll i=1;i*i<=n;i++){
    cnt.push_back(i);
    if(n/i!=i){
      cnt.push_back(n/i);
    }
  }

  std::sort(all(cnt));

  ll m=cnt.size();

  for(ll i=m-1;i>0;i--){
    cnt[i]-=cnt[i-1];
  }

  std::vector<std::vector<ll>> dp(k,std::vector<ll>(m));

  rep(i,0,m)dp[0][i]=cnt[i];

  rep(i,1,k){
    ll sum=0;
    for(ll j=m-1;j>=0;j--){
      sum=(sum+dp[i-1][m-1-j])%MOD;
      dp[i][j]=cnt[j]*sum%MOD;
    }
  }

  ll ans=0;
  rep(i,0,m)ans=(ans+dp[k-1][i])%MOD;

  std::cout<<ans<<"\n";

  return 0;
}

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

int main(){
    bool isfirst=true;
    while(1){
        int pay;
        cin >> pay;
        if(pay==0) break;
        if(!isfirst) cout << endl;
        
        int mon[4];
        int val[4]={10,50,100,500};
        int c=0;
        for(int i=0; i<4; i++){
            cin >> mon[i];
            c += mon[i]*val[i];
        }
        c -= pay;

        for(int i=3; i>=0; i--){
            mon[i] -= c/val[i];
            c -= (c/val[i])*val[i];
        }
        for(int i=0; i<4; i++){
            if(mon[i]>0){
                cout << val[i] << " " << mon[i] << endl;
            }
        }
        isfirst = false;
    }
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

struct UnionFind{ //// sorry, i'm unko
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
};

int n;
int X[111],Y[111];
int A[5],B[5];
vector<int> xps,yps;
int x[111],y[111],a[5],b[5];
bool wal[111][111][111][111];
int dd[]={-1,0,1,0,-1};

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    int x1=INF,y1=INF,x2=-INF,y2=-INF;
    rep(i,n)cin>>X[i]>>Y[i];
    rep(i,4){
      cin>>A[i]>>B[i];
      minch(x1,A[i]); maxch(x2,A[i]);
      minch(y1,B[i]); maxch(y2,B[i]);
    }

    xps.clear();
    xps.pb(-114514);
    rep(i,n)xps.pb(X[i]);
    rep(i,4){
      xps.pb(A[i]);
    }
    sort(all(xps));
    uni(xps);
    rep(i,n){
      x[i]=lower_bound(all(xps),X[i])-xps.begin();
    }
    x1=lower_bound(all(xps),x1)-xps.begin();
    x2=lower_bound(all(xps),x2)-xps.begin();

    yps.clear();
    yps.pb(-114514);
    rep(i,n)yps.pb(Y[i]);
    rep(i,4)yps.pb(B[i]);
    sort(all(yps));
    uni(yps);
    rep(i,n){
      y[i]=lower_bound(all(yps),Y[i])-yps.begin();
    }
    y1=lower_bound(all(yps),y1)-yps.begin();
    y2=lower_bound(all(yps),y2)-yps.begin();

    //dbg(x1); dbg(x2); dbg(y1); dbg(y2);

    memset(wal,0,sizeof(wal));
    rep(i,n){
      if(y[i]==y[(i+1)%n]){
        repl(k,min(x[i],x[(i+1)%n]),max(x[i],x[(i+1)%n])){
          wal[y[i]][k][y[i]-1][k]=true;
          wal[y[i]-1][k][y[i]][k]=true;
        }
      }else{
        repl(k,min(y[i],y[(i+1)%n]),max(y[i],y[(i+1)%n])){
          wal[k][x[i]][k][x[i]-1]=true;
          wal[k][x[i]-1][k][x[i]]=true;
        }
      }
    }

    UnionFind uf(111*111);
    rep(i,111)rep(j,111){
      rep(d,4){
        int ni=i+dd[d],nj=j+dd[d+1];
        if(ni>=0&&ni<111&&nj>=0&&nj<111&&!wal[i][j][ni][nj]){
          uf.unite(i*111+j,ni*111+nj);
        }
      }
    }

    ll res=0;
    rep(i,110)rep(j,110){
      if(i>=y1&&i+1<=y2&&j>=x1&&j+1<=x2)continue;
      if(!uf.same(0,i*111+j)){
        res+=(yps[i+1]-yps[i])*(xps[j+1]-xps[j]);
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

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

int main(){
    ll N; cin>>N;
    if(N%2!=0){
        cout<<0<<endl;
    }
    else{
        ll sum=0;
        while(N>=10){
            N=N/5;
            sum=sum+N/2;
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 256