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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<double, double> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
const lint mod = MOD;
class mint{
    public:
        long long x;

    constexpr mint(long long _x = 0) : x((_x%mod+mod)%mod) {}
    constexpr mint operator-() const{
        return mint(-x);
    }
    constexpr mint& operator+=(const mint& a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a){
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const{
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const{
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const{
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long x) const{
        if(!x) return 1;
        mint a = pow(x>>1);
        a *= a;
        if(x&1) a *= *this;
        return a; 
    }
    constexpr mint inv() const{
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a){
        return (*this) *= a.inv();
    }
    constexpr mint& operator/(const mint& a) const{
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x; return os;
    }
};

map<int, mint> mp;

int main(){
    int n; cin >> n;
    for(int l = 2; l <= n; l++){
        int m = l;
        for(int x = 2; x * x <= m; x++){
            while(m % x == 0){
                mp[x] += 1; m /= x;
            }
        }
        if(m != 1) mp[m] += 1;
    }
    mint ans = 1;
    for(auto p : mp){
        ans *= (p.se + 1);
    }
    out(ans);
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
 
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)%2)printf("IMPOSSIBLE\n");
	else printf("%d\n",(a+b)/2);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define __V vector
#define all(x) x.begin(), x.end()
#define mod 998244353ll
//using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
//#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//#endif
}
//-1 -1 1 3 -1
typedef long long ll;
typedef double ld;
typedef pair<ll, ll> pi;
typedef map<int, int> mii;
typedef __V <ll> vi;
typedef __V <pi> vpi;
typedef __V <pi> vvi;
typedef __V< __V <pi>> vvpi;
int n, t;
list<int> ans;
int main() {
	doin();
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> t, t--;
		if(t > ans.size())
			return cout << "-1", 0;
		else if (t == ans.size()) {
			ans.pb(t+1);
			continue;
		}
		list<int>::iterator it = ans.begin();
	    advance(it, t);
	    ans.insert(it, t+1);
	}
	for(list<int>::iterator it = ans.begin(); it != ans.end(); it++)
		cout << *it << "\n";
}


Measured memory_bytes: 256
from bisect import bisect_left
def main():
  a,b,q=map(int,input().split())
  s=[int(input()) for i in range(a)]
  t=[int(input()) for i in range(b)]
  x=[int(input()) for i in range(q)]
  inf=10**11
  minf=-10**11
  s=[minf]+s+[inf]
  t=[minf]+t+[inf]
  for i in range(q):
    ns=bisect_left(s,x[i])
    nt=bisect_left(t,x[i])
    ans=float('inf')
    for j in [s[ns],s[ns-1]]:
      for k in [t[nt],t[nt-1]]:
        ans=min(ans,min(abs(x[i]-j),abs(x[i]-k))+abs(max(j,k)-min(j,k)))
    print(ans)
if __name__=='__main__':
  main()

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

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

	vector<int> d( N );
	for( int i = 0; i < N; ++i ) {
		cin >> d.at( i );
	}

	sort( d.begin(), d.end() );

	int m = N/2;
	cout << d.at(m) - d.at(m-1) << endl;
}


Measured memory_bytes: 640
#include<stdio.h>

#define MAX 1000000007

int main(){
    int a[1000]={0};
    int flag;
    for(int i=2;i<=1000;i++){
        flag=0;
        for(int j=2;j<i;j++){
            if(i%j==0){
                flag++;
                break;
            }
        }
        if(flag==0){
            a[i]=i;
        }
    }

    int n;
    scanf("%d",&n);

    int b[1000]={0};
    for(int i=1;i<=n;i++){
        for(int j=0;j<1000;j++){
            if(a[j]==0){
                continue;
            }
            if(i%a[j]==0){
                int temp=i;
                while(1){
                    temp/=a[j];
                    b[j]++;
                    if(temp%a[j]!=0){
                        break;
                    }
                }
            }
        }
    }
    long long int sum=1;
    for(int i=0;i<1000;i++){
        sum*=(b[i]+1);
        sum%=MAX;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int flag = 0;
    rep(1, i, N)
    {
        if (s.at(i) != '9')
        {
            flag = 1;
        }
    }
    if (flag)
    {
        cout << (s.at(0) - '1') + 9 * (N - 1) << endl;
    }
    else
    {
        cout << (s.at(0) - '0') + 9 * (N - 1) << endl;
    }
}

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

int main() {
	string s;
	int sum;
	while (1) {
		sum = 0;
		cin >> s;
		for (int i = 0; i < s.length();i++) {
			sum += s[i] - '0';
		}
		if (!sum) break;
		cout << sum << endl;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll n, m;
  cin >> n >> m;
  ll ans = n * m;
  if(n <= 1 && m <= 1) ans = 1;
  else if(n <= 1 || m <= 1) ans -= 2;
  else ans = ans - n * 2 - m * 2 + 4;

  cout << ans  << endl;
}


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

int main(){
    int n,t,a,c;
    cin>>n>>t>>a;
    double h,m=1000;
    for(int i=0;i<n;i++){
        cin>>h;
        if(m>abs(a-t+h*0.006)){
            m=abs(a-t+h*0.006);
            c=i+1;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define xx first
#define yy second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const int N=3e5+10;
const int M=1e6+10;

int main(){
	LL n,ans=0;
	scanf("%lld",&n);
	ans=n/500*1000;
	n%=500;
	ans+=n/5*5;
	printf("%lld\n",ans);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int r;
	string ans = "AGC";
	cin >> r;
	if (r < 1200)ans = "ABC";
	else if (r < 2800)ans = "ARC";
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

typedef vector<vector<int>> matrix;

matrix zeros(int n, int m) {
	return matrix(n, vector<int>(m));
}

matrix id(int n) {
	matrix ret = zeros(n, n);
	for (int i = 0; i < n; i++)
		ret[i][i] = 1;
	return ret;
}

matrix add(matrix a, const matrix& b) {
	int n = a.size(), m = a[0].size();
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			a[i][j] = (a[i][j] + b[i][j]) % mod;
	return a;
}

matrix mul(const matrix& a, const matrix& b) {
	int n = a.size(), m = a[0].size(), k = b[0].size();
	matrix ret = zeros(n, k);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < k; j++)
			for (int p = 0; p < m; p++)
				ret[i][j] = (ret[i][j] + (long long) a[i][p] * b[p][j]) % mod;
	return ret;
}

matrix power(matrix a, int p) {
	matrix res = id(a.size());
	while(p > 0) {
		if(p & 1)
			res = mul(res, a);
		a = mul(a, a);
		p >>= 1;
	}
	return res;
}


signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	matrix v(n, vi(n));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> v[i][j];
		}
	}
	matrix ans(n, vi(n));
	for(int i = 0; i < n; i++) {
		ans[i][i] = 1;
	}
	ans = mul(ans, power(v, k));
	int res = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			res = (res + ans[i][j]) % mod;
		}
	}
	cout << res;

	return 0;
}

Measured memory_bytes: 3764
#%%
n = int(input())
a, b, c = [0] * n, [0] * n, [0] * n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

x, y, z = [0] * n, [0] * n, [0] * n
x[0], y[0], z[0] = a[0], b[0], c[0]
for i in range(1, n):
    x[i] = max(y[i-1]+a[i], z[i-1]+a[i])
    y[i] = max(x[i-1]+b[i], z[i-1]+b[i])
    z[i] = max(y[i-1]+c[i], x[i-1]+c[i])

ans = max(x[n-1], y[n-1], z[n-1])
print(ans)

Measured memory_bytes: 53280
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
int mod = 1e9+7;
int_fast64_t modpow(int_fast64_t a, int p){
    if (p == 0) return 1;
    if (p%2 == 0) {
        int_fast64_t half = modpow(a, p/2);
        return half * half % mod;
    }
    else {
        return a * modpow(a, p-1) % mod;
    }
}
int_fast64_t cmb(int n, int r) {
    r = min(r, n-r);
    int_fast64_t tmpM = 1, tmpD = 1;
    for (int i = 0; i<r; i++) {
        tmpM *= n-i;
        tmpD *= i+1;
        tmpM %= mod;
        tmpD %= mod;
    }
    return tmpM * modpow(tmpD, mod-2) % mod;
}
map<int_fast64_t, int> PF;
void primef(int_fast64_t n) {
    int_fast64_t tmp = n;
    for (int i = 2; i*i <= n; i++) {
        while (tmp%i == 0) {
                PF[i]++;
                tmp /= i;
        }
    }
    if (tmp != 1) PF[tmp]++;
}
void Main(){
    int N = read(), M = read();
    int_fast64_t ans = 1;
    primef(M);
    for (auto pf:PF) {
        ans *= cmb(pf.second+N-1, pf.second);
        ans %= mod;
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
H, W = map(int, input().split())
grid = []
for h in range(H):
  S = input()
  tmp = []
  for s in S:
    tmp.append(s)
  grid.append(tmp)


dp = [[0]*W for _ in range(H)]
dp[H-1][W-1] = 1

for h in reversed(range(H)):
  for w in reversed(range(W)):
    if (h+1) <= (H-1):
      dp[h][w] += dp[h+1][w]
    if (w+1) <= (W-1):
      dp[h][w] += dp[h][w+1]
    if grid[h][w] == "#":
      dp[h][w] = 0
    
      
print(dp[0][0] % (10**9 + 7))

Measured memory_bytes: 246620
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

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

    int h, n;
    cin >> h >> n;
    vs32 a(n), b(n);
    rep (i, n) cin >> a[i] >> b[i];

    int dp[h + 1];
    rep (i, h + 1) dp[i] = 1e9;
    dp[0] = 0;

    rep (j, h + 1)
    {
        rep (i, n)
        {
            dp[j] = MIN(dp[j], dp[MAX(0, j - a[i])] + b[i]);
        }
    }

    cout << dp[h] << "\n";
    return 0;
}



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

using namespace std;

int main(void) {
  int S, tmp, i;
  bool isBad = false;
  cin >> S;
  
  for(i = 0; i < 3; i++) {
    tmp = S%10;
    S = S/10;
    if(tmp == S%10) {
      isBad = true;
    }
  }

  if(isBad) {
  	cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
# coding=utf-8
 
###
### for atcorder program
###
 
import sys
import math
 
# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338
 
    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []
 
        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist
 
    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)
 
    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)
 
    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
 
mymath = mymath()
 
### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()
 
output = output()
 
### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]
 
#R = float(input())
#A.append(list(map(int,input().split())))
 
#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]
 
#abc list
#abc = [chr(ord('a') + i) for i in range(26)]
 
### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")  

def get_input():
  N = []
  while True:
    try:
      N.append(input())
      #N.append(int(input()))
    except EOFError:
      break
  return N


while(True):
  M, N_min, N_max = [int(x) for x in input().split()]
  P = []

  if M == 0 and N_min == 0 and N_max == 0:
    break

  for i in range(M):
    P.append(int(input()))

  G_max = 0
  I = None

  for i in range(N_min-1, N_max):
    G = P[i] - P[i+1]
    if G >= G_max:
      G_max = G
      I = i+1
    
  print(I)


Measured memory_bytes: 5704
#include <iostream>
#include <string>
#define int long long
using namespace std;

int n;
string s;
int cnt[26];

signed main() {
	int i;
	
	cin >> n >> s;
	for (i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	
	int ans = 1;
	int mod = 1000000007;
	for (i = 0; i < 26; i++) {
		ans *= (cnt[i] + 1);
		ans %= mod;
	}
	ans = (ans + mod - 1) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define maxn 100001
#define maxa 2000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define pb push_back
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define repr(i, a, n) for(ll i = n-1; i >= a; i--)
#define meme(a, b) memset(a, b, sizeof(a))

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
// power and modulo inverse
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}
// factorial
ll fact[maxa], finv[maxa];
void calf(){
    fact[0] = finv[0] = 1;
    for(ll i = 1; i < maxa; i++){fact[i] = (fact[i-1]*i) %MOD;finv[i] = (finv[i-1]*power(i))%MOD;}
}
// nCr
ll ncr(ll N, ll R){ if(R > N) return 0; return (fact[N]*((finv[R]*finv[N-R])%MOD))%MOD;}

void solve(){
    ll n, f = 0;
    cin >> n;
    map<string, ll> mp;
    ll c = 0;
    for(ll i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
        c = max(c, mp[s]);
    } //cout << c << " ";
    vector<string> v;
    for(auto it = mp.begin(); it != mp.end(); it++){
        if(it->sd == c){
            v.pb(it->ft);
        }
    }
    sort(v.begin(), v.end());
    for(auto x: v) cout << x  << endl;

}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 25584
local n=io.read("n")
for i=1,3500 do
    for j=1,3500 do
        local k=n*i*j/(4*i*j-n*j-n*i)
        if math.fmod(k,1)==0 and k>=0 then
            print(i.." "..j.." "..string.format("%d",k))
            return
        end
    end
end

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

int prime[100001], cou[100001];

void solve(int n)
{
	prime[1] = 0;
	cou[1] = 0;
	cou[2] = 0;

	for (int i = 2; i <= n; i++)
	{
		prime[i] = 1;
		cou[i] = 0;
	}

	for (int i = 2; i <= n / 2; i++)
	{
		for (int j = 2; j*i <= n; j++)
		{
			if (prime[i*j] == 1)
			{
				prime[i*j] = 0;
			}
		}
	}

	for (int i = 3; i <= n; i++)
	{
		if (prime[i] == 1 && prime[(i + 1) / 2] == 1)
		{
			cou[i] = cou[i - 1] + 1;
		}
		else
		{
			cou[i] = cou[i - 1];
		}
	}
}

int main()
{
	int q, l, r;

	cin >> q;

	solve(100000);

	for (int i = 1; i <= q; i++)
	{
		cin >> l >> r;
		cout << cou[r] - cou[l - 1] << endl;
	}
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b= sc.next();
		char c=b.charAt(0);
		switch(c){
			case 'A': System.out.println('T'); break;
			case 'T': System.out.println('A'); break;
			case 'C': System.out.println('G'); break;
			case 'G': System.out.println('C'); break;
			default: return;
		}
	}
}

Measured memory_bytes: 21844
Imports System
Imports System.Linq

Module Program
    Sub Main(args As String())

        Dim N As Integer = Console.ReadLine()

        Dim o As Integer = N \ 1000
        Dim p As Integer = (o + 1) * 1000
        Dim q As Integer = p - N
        If q = 1000 Then
            Console.WriteLine(0)
            Exit Sub
        End If

        Console.WriteLine(q)

    End Sub
End Module


Measured memory_bytes: 28308
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class UnionFind {
    public:
    int n;
    vector<int> par, rank, size;  //親, 深さ, その木の要素数

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    //根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int p = find(par[x]);
            size[x] = size[p];
            return par[x] = p;
        }
    }

    //xとyの属する集合の併合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        
        size[x] += size[y];
        size[y] = size[x];
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //同じ集合に属するか否か
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m, k, a, b;
    cin >> n >> m >> k;
    vector<int> friends(n, 0);
    UnionFind uf = UnionFind(n);
    for(int i=0;i<m;++i) {
        cin >> a >> b;
        --a; --b;
        ++friends[a];
        ++friends[b];
        uf.unite(a, b);
    }

    vector<int> ans(n, 0);
    for(int i=0;i<n;++i) {
        ans[i] = uf.size[uf.find(i)] - 1 - friends[i];
    }

    vector<Pii> block(k);
    for(int i=0;i<k;++i) {
        cin >> block[i].first >> block[i].second;
        --block[i].first;
        --block[i].second;
        if(uf.is_same(block[i].first, block[i].second)) {
            --ans[block[i].first];
            --ans[block[i].second];
        }
    }

    cout << ans[0];
    for(int i=1;i<n;++i) {
        cout << " " << ans[i];
    }
    cout << endl;


}


Measured memory_bytes: 3820
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF = 1 << 28;

int main() {
	int n, m;
	
	while ( cin >> n >> m, n | m ) {
		VVI L( n, VI( n, INF ) ),
			S( n, VI( n, INF ) );
		
		for ( int i = 0; i < m; ++i ) {
			int x, y, t;
			char s;
			cin >> x >> y >> t >> s;
			
			switch ( s ) {
			case 'L':
				L[x - 1][y - 1] = L[y - 1][x - 1] = min( t, L[x - 1][y - 1] );
				break;
			case 'S':
				S[x - 1][y - 1] = S[y - 1][x - 1] = min( t, S[x - 1][y - 1] );
				break;
			}
		}
		
		int r;
		cin >> r;
		
		VI Z( r, 0 );
		
		for ( int i = 0; i < r; ++i ) {
			cin >> Z[i];
			--Z[i];
		}

		for ( int i = 0; i < n; ++i ) {
			L[i][i] = S[i][i] = 0;
		}

		for ( int k = 0; k < n; ++k ) {
			for ( int i = 0; i < n; ++i ) {
				for ( int j = 0; j < n; ++j ) {
					L[i][j] = min( L[i][j], L[i][k] + L[k][j] );
					S[i][j] = min( S[i][j], S[i][k] + S[k][j] );
				}
			}
		}

		VVI d( r, VI( n, INF ) );
		d[0][Z[0]] = 0;
		for ( int i = 0; i + 1 < r; ++i ) {
			int from = Z[i], to = Z[i + 1];
			//d[i + 1][to] = min( d[i + 1][to], d[i][from] + S[from][to] );
			for ( int j = 0; j < n; ++j ) {
				//d[i + 1][to] = min( d[i + 1][to], d[i][j] + L[from][j] + S[j][to] );
				d[i + 1][j] = min( d[i + 1][j], d[i][j] + L[from][to] );
				//d[i + 1][j] = min( d[i + 1][j], d[i][from] + S[from][j] + L[j][to] );
				for ( int k = 0; k < n; ++k ) {
					d[i + 1][k] = min( d[i + 1][k], d[i][j] + L[from][j] + S[j][k] + L[k][to] );
				}
			}
		}

		int ans = INF;
		for ( int i = 0; i < n; ++i ) {
			ans = min( ans, d[r - 1][i] );
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2324
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
    }
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

struct LineSeg: public pair<Point, Point> {
    LineSeg() {}
    LineSeg(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

struct Circle {
    Point p;
    double r;
    Circle() {}
    Circle(const Point &p, const double r): p(p), r(r) {}
};

enum CCWiseState {
    ONLINE_FRONT=-2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK,
};

CCWiseState ccwise(Point a, Point b, Point c) {
    b -= a; c -= a;

    if (cross_prod(b, c) > 0) {
        return COUNTER_CLOCKWISE;
    } else if (cross_prod(b, c) < 0) {
        return CLOCKWISE;
    } else if (dot_prod(b, c) < 0) {
        return ONLINE_BACK;
    } else if (norm(b) < norm(c)) {
        return ONLINE_FRONT;
    } else {
        return ON_SEGMENT;
    }
}

bool testcase_ends() {
    double x, y;
    if (scanf("%lf %lf", &x, &y) == EOF)
        return 1;

    Point A(x, y);
    scanf("%lf %lf", &x, &y);
    Point B(x, y);
    scanf("%lf %lf", &x, &y);
    Point C(x, y);

    scanf("%lf %lf", &x, &y);
    Point P(x, y);

    CCWiseState tmp=ccwise(A, P, B);
    if (tmp != ccwise(B, P, C)) {
        return !printf("NO\n");
    } else if (tmp != ccwise(C, P, A)) {
        return !printf("NO\n");
    }

    printf("YES\n");
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

Measured memory_bytes: 2732
#!/usr/bin/env python3
import sys

def solve(K: int):
    p = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(p[K-1])

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		sc.close();

		//if(N < 1000) {
		//	System.out.println("ABC" + String.format("%03d", N));
		//}else {
		//	System.out.println("ABD" + String.format("%03d", N - 999));
		//}

		if(N < 1000) {
			System.out.println("ABC");
		}else {
			System.out.println("ABD");
		}
	}
}

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

using namespace std;
#define int long long

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

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

//-----CODE------//

void solve(void)
{
  int N,L;
  cin>>N>>L;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  int check = 0;
  int index = -1;
  for (int i = 0; i < N-1; i++)
  {
    if(vec[i] + vec[i+1] >= L)
    {
      check = 1;
      index = i;
    }
  }
  if(check)
  {
    cout<<"Possible"<<endl;
    for (int i = 0; i < N-1; i++)
    {
      if(i == index)break;
      cout<<i+1<<endl;
    }
    for (int i = N-2; i >= 0; i--) 
    {
      if(i == index)break;
      cout<<i+1<<endl;
    }
    cout<<index+1<<endl;
    
  }
  else
  {
    cout<<"Impossible"<<endl;
  }
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

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

  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main ()
{
  int res = 0;
  char w[ 16 ], *p;
 
  scanf ( "%s", w );
  for ( p = w; *p != '\0'; ++p )
  {
    *p = tolower ( *p );
  }
 
  for ( ; ; )
  {
    char t[ 1024 ], *p;
 
    scanf ( " %s", t );
    if ( !strcmp ( t, "END_OF_TEXT" ) ) break ;
 
    for ( p = t; *p != '\0'; ++p )
    {
      *p = tolower ( *p );
    }
    res += !( strcmp ( t, w ) );
  }
 
  printf ( "%d\n", res );
 
  return ( 0 );
}

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

typedef long long ll;
ll zeller(ll y, ll m, ll d){
    if (m <= 2){
        y--;
        m += 12;
    }
    return (365 * y) + (y / 4) - (y / 100) + (y / 400) + (306 * (m + 1)) / 10 + d - 429;
}

int main(int argc, char ** argv) {
    int y, m, d;
    ll z1 = zeller(1868, 9, 8);
    ll z2 = zeller(1912, 7, 30);
    ll z3 = zeller(1926, 12, 25);
    ll z4 = zeller(1989, 1, 8);
    while (~scanf("%d%d%d", &y, &m, &d)){
        ll z = zeller(y, m, d);
        int idx = -1;
        char gen[][10] = {
            "heisei",
            "showa",
            "taisho",
            "meiji"
        };
        int zg = -1;
        if (z >= z4) idx = 0, zg = y - 1989 + 1;
        else if (z >= z3) idx = 1, zg = y - 1926 + 1;
        else if (z >= z2) idx = 2, zg = y - 1912 + 1;
        else if (z >= z1) idx = 3, zg = y - 1868 + 1;
        if (zg != -1) printf("%s %d %d %d\n", gen[idx], zg, m, d);
        else printf("pre-meiji\n");
    }
}

Measured memory_bytes: 1180
#include<iostream>
#include<cstdio>

const int maxn = 100000+7;
using namespace std;

int n,a[maxn],b[maxn],cnt=0;
int lastbig,lastsmall;

int main()
{
	scanf("%d",&n);
	int temp;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&temp);
		if(temp==a[i-1]){--n;--i;}
		else a[i]=temp;
	}
	int last=a[1];
	for(int i=2;i<=n;++i)
	{	
		if(lastbig)
		{
			if(a[i]<last && !lastsmall){
				++cnt;lastbig=lastsmall=0;
			}
		}
		else if(lastsmall)
		{
			if(a[i]>last && !lastbig){
				++cnt;lastbig=lastsmall=0;
			}
		}
		else if(!lastbig && !lastsmall)
		{
			if(a[i]>last)lastbig=1;
			else if(a[i]<last)lastsmall=1;
		}
		last=a[i];
	}
	printf("%d\n",cnt+1);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<unordered_map>

#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int c=0;
	int ca=0;
	REP(i,n) {
		if(s[i]=='a') {
			if(c<a+b) {
				++c;
				cout<<"Yes"<<endl;
			} else {
				cout<<"No"<<endl;
			}
		}
		else if(s[i]=='b') {
			if(c<a+b&&ca<b) {
				++c;
				++ca;
				cout<<"Yes"<<endl;
			} else {
				cout<<"No"<<endl;
			}
		} else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 848
#include <stdio.h>
#include <math.h>
int main()
{
    int n, a;
    long int ans[10010] = {};
    scanf("%d", &n);
    int maxx = (int)sqrt(n - 2) - 1;
    int t;
    for (int x = 1; x <= maxx; x++)
    {
        for (int y = 1; y < x; y++)
        {
            for (int z = 1; z < y; z++)
            {
                t = x * x + y * y + z * z + x * y + y * z + z * x;
                if (t <= n)
                {
                    ans[t] += 6;
                }
            }
            //case:y==z
            t = x * x + 2 * x * y + 3 * y * y;
            if (t <= n)
            {
                ans[t] += 3;
            }
        }
        //case:x==y
        for (int z = 1; z < x; z++)
        {
            t = 3 * x * x + z * z + 2 * z * x;
            if (t <= n)
            {
                ans[t] += 3;
            }
        }
        //case:x==y==z
        t = 6 * x * x;
        if (t <= n)
        {
            ans[t]++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%ld\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 2236
def check(ii):
    j=0
    for i in range(ii,ii+len(t)):
        if s[i]!="?" and s[i]!=t[j]:
            return False
        j+=1
    return True

s=input()
t=input()
flag=False
for i in range(len(s)-len(t),-1,-1):
    if check(i):
        res=s[:i]+t+s[i+len(t):]
        print(res.replace("?","a"))
        flag=True
        break
if not flag:
    print("UNRESTORABLE")


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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

//#define DEBUG

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

const int N = 1e5;
bool arr[N];

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int s;
	cin >> s;
	arr[s] = 1;
	int idx = 2;
	while(true){
		if(s%2)
			s = 3*s+1;
		else
			s /= 2;
		if(arr[s]){
			cout << idx;
			return 0;
		}
		arr[s] = 1;
		++idx;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main(){
    IOS;
    long long n,k;
    cin >> n >> k;
    cout<<min(n%k,abs((n%k)-k));
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

//Combination MOD
const ll MOD = INF + 7;
vector<ll> fac(300000);
vector<ll> fac_inv(300000);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;

    ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
    return tmp * fac[a] % MOD;
}

int main(){
    int n, k;
    cin >> n >> k;
    fac[0] = 1;
    fac_inv[0] = 1;

    for(ll i = 0; i < 300000; i++){
        fac[i + 1] = fac[i] * (i + 1) % MOD;
        fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
    }

    int l = n - k;
    rep(i, k){
        ll res = comb(k - 1, i) % MOD * comb(2 + l + i - 1, l) % MOD;
        cout << res << endl;
        l--;
    }
}



Measured memory_bytes: 4992
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int h,w;

int c[10][10];
int a[10];


int main(){
	cin>>h>>w;
	REP(i,10)
		REP(j,10)
			cin>>c[i][j];
		
	
	REP(i,h)
		REP(j,w){
			int t;
			cin>>t;
			if(t>=0){
				a[t]++;
			}
		}
		
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			for(int k=0;k<10;k++){
				c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
			}
		}
	}
	
	ll ans=0;
	REP(i,10)
		ans+=(ll)a[i]*c[i][1];
		
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {                                                                    long long i, n, sum = 1;                                                    
                                                                                
    scanf("%lld", &n);                                                          
                                                                                
    for (i = 1; i <= n; i++) {                                                          sum *= i;                                                               
    }                                                                           
    printf("%lld\n", sum);                                                          return 0;                                                                   
}

Measured memory_bytes: 596
#include <stdio.h>
int arr[1000];
int main(void) {
	int N, i, j, k, num;
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", arr + i);
	for (i = 0; i < N; i++) {
		num = arr[i];
		for (j = 0; j < i && arr[j] < arr[i]; j++);
		for (k = i; k > j; k--) arr[k] = arr[k - 1];
		arr[j] = num;
		printf("%d", *arr);
		for (j = 1; j < N; j++) {
			printf(" %d", arr[j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1820
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    if(a%2 != b%2){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    cout << (a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();
    if (N < 10) {
      R += 100 * (10-N);
    }
    System.out.println(R);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
const int maxn=(1<<18)+10;
int n,a[maxn],m;
int f1[maxn],f2[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	m=1<<n;
	for (int i=0;i<m;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<m;i++)
		for (int j=i;j>=0;j=(j-1)&i) {
			if (a[j]>f1[i])
				f2[i]=f1[i],f1[i]=a[j];
			else f2[i]=max(f2[i],a[j]);
			if (j==0) break;
		}
	int s=0;
	for (int i=1;i<m;i++) {
		s=max(s,f1[i]+f2[i]);
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 6144
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()
B = reads()

if sum(A) < sum(B):
  print(-1); exit()

failed = [B[i] - A[i] for i in range(N) if B[i] - A[i] > 0]
succ = [A[i] - B[i] for i in range(N) if A[i] - B[i] > 0]

ans = len(failed)
rem = sum(failed)
succ.sort()
while rem > 0:
  rem -= succ.pop()
  ans += 1
print(ans)

Measured memory_bytes: 81584
using System;

class Reverse
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        string[] s = Console.ReadLine().Split();

        int[] a = new int[n];

        for(int i = 0; i < s.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }

        Array.Reverse(a);

        for (int i = 0; i < s.Length; i++)
        {
            if(i == s.Length - 1)
            {
                Console.Write("{0}", a[i]);

            }
            else
            {
                Console.Write("{0} ", a[i]);
            }
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 9208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class SearchIsland
    {
        struct Position { internal int x, y; }

        readonly int[] moveX = new int[] { -1, 0, 1, 0 };
        readonly int[] moveY = new int[] { 0, -1, 0, 1 };

        char[][] map;

        public void MakeMap(string[] source)
        {
            map = new char[12][];

            for (int i = 0; i < 12; i++) map[i] = source[i].ToCharArray();
        }

        public int Count()
        {
            int count = 0;

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    if (map[i][j] == '1')
                    {
                        CheckIsland(i, j);
                        count++;
                    }
                }
            }
            return count;
        }

        private void CheckIsland(int i, int j)
        {
            Stack<Position> stk = new Stack<Position>();

            Position willPush;
            willPush.x = j;
            willPush.y = i;
            stk.Push(willPush);

            while (stk.Count > 0)
            {
                Position temp = stk.Pop();
                int posX = temp.x;
                int posY = temp.y;

                map[posY][posX] = '0';

                for (int n = 0; n < 4; n++)
                {
                    willPush.x = posX + moveX[n];
                    willPush.y = posY + moveY[n];

                    if (!isValid(willPush.x, willPush.y)) continue;

                    if (map[willPush.y][willPush.x] == '1')
                    {
                        stk.Push(willPush);
                    }
                }
            }
        }

        private bool isValid(int x, int y)
        {
            if (x < 0 || x > 11) return false;
            if (y < 0 || y > 11) return false;
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            SearchIsland SI = new SearchIsland();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] map = new string[12];
                map[0] = input;

                for (int i = 1; i < 12; i++) map[i] = Console.ReadLine();

                SI.MakeMap(map);

                sb.AppendLine(SI.Count().ToString());

                Console.ReadLine();
            }
            Console.Write(sb);
        }
    }
}

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

int main() {
  
  int a;
  int b;

  cin >> a;
  cin >> b;
  if ((a*b)%2 ==0){
  cout << "Even" << endl;
  }
  else{
  cout << "Odd" << endl;
  }
}

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

#define MAX_N 1000001
#define INF 987654321
using namespace std;
typedef long long lld;
typedef unsigned long long llu;

int main(){

	int n;
	cin>>n;

	int sum=0,ans=0;
	for (int i = 0; i < n; ++i)
	{
		int k;
		cin>>k;

		if(i>0){
			ans+=k*sum;
		}

		sum+=k;

	}

	cout<<ans;

	return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if(A >= 13){
    cout << B << endl;
  } else if (A >= 6){
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256