akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

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

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) puts("hon");
	if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
	if (n == 3) puts("bon");
	return 0;
}


Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
import sys
from heapq import heappush,heappop,heapify

N,M=map(int, sys.stdin.readline().split())

al=[ [] for _ in range(N+1) ]	#隣接リスト

for _ in range(M):
	a,b=map(int, sys.stdin.readline().split())
	al[a].append(b)
	al[b].append(a)

d=[ float("inf") for _ in range(N+1)]
restore=[ None for _ in range(N+1)]

#Dijkstra
def dij(fro):
	d[fro]=0
	hq=[]
	heappush(hq,(0,fro))
	while hq:
		cost,fro=heappop(hq)
		for to in al[fro]:
			alt=d[fro]+1
			if alt<d[to]:
				d[to]=alt
				restore[to]=fro
				heappush(hq, (alt,to))

dij(1)

print "Yes"
for i in range(2,N+1):
	print restore[i]

Measured memory_bytes: 105244
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,d[N],q,x,dis[N],pos[N],f[N];
int main() {
    cin>>n>>dis[0];
    for(int i=1;i<=n;i++) d[i]=gi(),dis[i]=min(dis[i-1],abs(dis[i-1]-d[i]));
    f[n+1]=1;
    for(int i=n;i;i--) f[i]=d[i]<2*f[i+1]?f[i+1]+d[i]:f[i+1];
    cin>>q;
    while(q--) x=gi(),puts(dis[x-1]>=f[x+1]?"YES":"NO");
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

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

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  queue<int> que;
  vector<vi> edge(n+m-1);
  vi in(n,0), ans(n);

  rep(i, n+m-1) {
    int a, b; cin >> a >> b;
    edge[a-1].eb(b-1);
    ++in[b-1];
  }

  rep(i, n) if (in[i] == 0) que.em(i);

  while (!que.empty()) {
    int q = que.front(); que.pop();

    for (auto to : edge[q]) {
      --in[to];
      if (in[to] == 0) {
        ans[to] = q+1;
        que.em(to);
      }
    }
  }

  rep(i, n) cout << ans[i] << endl;

  return (0);
}


Measured memory_bytes: 9508
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b)+min(c,d) << endl;
    return 0;
}

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

#define MAX 100000
int GCD(int ,int);

int main(void){
	
	long long int N,M,G,i,n,m;
	char *S,*T;
  
	scanf("%lld %lld",&N,&M);
  	if(N > MAX || M > MAX){
		return 0;    
    }
	S = (char *)malloc((N+1)*sizeof(char));
	T = (char *)malloc((M+1)*sizeof(char));
	scanf("%s",S);
	scanf("%s",T);

	G = GCD(N,M);
  	n = N/G;
  	m = M/G;

	for(i=0;i<G;i++){
    	if(S[i*n] != T[i*m]){
 			printf("-1\n");       	
			free(S);
			free(T);
			return 0;
        }
    }
  
	printf("%lld\n",(long long int)(N/G*M));

	free(S);
	free(T);
	return 0;
}


int GCD(int a,int b){
	
	int tmp,r;
	
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	r = a % b;
	
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
  	return b;

}


Measured memory_bytes: 352
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
typedef pair<ld,ld> point;

const int N = 16;

ld dist[N][N];
point pt[N];
ld mst[(1<<N)];
ld dp[(1<<N)];
ld tot[N];
ld d(point x, point y)
{
	return sqrt((x.fi-y.fi)*(x.fi-y.fi) + (x.se-y.se)*(x.se-y.se));
}

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int n; 

void calcmst(int mask)
{
	DSU dsu(15);
	vector<pair<ld,ii> > vec;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i==j) continue;
			if((mask&(1<<i))&&(mask&(1<<j)))
			{
				vec.pb(mp(dist[i][j],mp(i,j)));
			}
		}
	}
	sort(vec.begin(),vec.end());
	int cnt = __builtin_popcount(mask) - 1;
	ld ans = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		//cerr<<"VEC : "<<vec[i].fi<<' '<<vec[i].se.fi<<' '<<vec[i].se.se<<'\n';
		if(dsu.sameset(vec[i].se.fi,vec[i].se.se))
		{
			continue;
		}
		cnt--;
		dsu.merge(vec[i].se.fi,vec[i].se.se);
		ans+=vec[i].fi;
	}
	assert(cnt==0);
	mst[mask] = ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin>>pt[i].fi>>pt[i].se>>tot[i];
		dp[(1<<i)] = tot[i];
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			dist[i][j] = d(pt[i],pt[j]);
			//cerr<<i<<' '<<j<<' '<<dist[i][j]<<'\n';
		}
	}
	for(int i = 1; i < (1<<n); i++) calcmst(i);
	mst[0] = 0;
	for(int i = 1; i < (1<<n); i++)
	{
		dp[i] = -mst[i];
		for(int j = 0; j < n; j++)
		{
			if(i&(1<<j)) dp[i]+=tot[j];
		}
		dp[i]/=ld(__builtin_popcount(i));
		//cerr<<i<<' '<<dp[i]<<' '<<mst[i]<<'\n';
		for(int j = i; j > 0; j = ((j-1)&i))
		{
			if(j == i) continue;
			dp[i] = max(dp[i], min(dp[j], dp[(i^j)]));
		}
	}
	cout<<fixed<<setprecision(12)<<dp[(1<<n) - 1]<<'\n';
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int dfs(ll p,ll q,int mi, int a, int num){
    if(num==0)return p==0;
    int ret=0;
    for(int i=mi;i<=a;++i){
        if(q>p*i)continue;
        ret+=dfs(p*i-q,q*i,i,a/i,num-1);
    }
    return ret;
}

void solve(int p){
    int q,a,n;
    cin>>q>>a>>n;
    int ans=0;
    rep(i,n)ans+=dfs(p,q,1,a,i+1);
    cout<<ans<<endl;

}
int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
    return 0;
}


Measured memory_bytes: 3008
from sys import stdin
N = int(stdin.readline().rstrip())
A = [0] * N
B = [0] * N

for i in range(N):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    A[i] = (a, b)

for j in range(N):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    B[j] = (a, b)

A = sorted(A, key=lambda x: (-x[1], x[0]))
B = sorted(B)

ans = 0
for k in B:
    flag = False
    val = 0
    max_v = 0
    for l in A:
        if l[0] < k[0] and l[1] < k[1]:
            if max_v <= l[1]:
                flag = True
                max_v = l[1]
                val = l
    if flag:
        ans += 1
        A.remove(val)
print(ans)

Measured memory_bytes: 3064
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector <int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[N - 1] - a[0] << endl;
}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこの,プロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します

Measured memory_bytes: 256
def main():
    n, c = map(int, input().split())
    cs = []
    ds = []

    cnums = []
    dsums = []

    for i in range(3):
        cnums.append([0]*c)
        dsums.append([0]*c)
    rs = []

    for i in range(c):
        ds.append(list(map(int, input().split())))
    for i in range(n):
        cs.append(list(map(int, input().split())))

    for x in range(n):
        for y in range(n):
            cnums[(x+y)%3][cs[y][x]-1] += 1

    for n in range(3):
        for i in range(c):
            s = 0
            for j in range(c):
                s += ds[j][i]*cnums[n][j]
            dsums[n][i] = s

    for i in range(3):
        mi = float('inf')
        mii = 0
        for n in range(c):
            if dsums[i][n] < mi:
                mi = dsums[i][n]
                mii = n
        for j in range(3):
            if j == i:
                continue
            mj = float('inf')
            mji = 0
            for n in range(c):
                if n == mii:
                    continue
                if dsums[j][n] < mj:
                    mj = dsums[j][n]
                    mji = n
            if (i == 0 and j == 1) or (i == 1 and j == 0):
                k = 2
            elif (i == 1 and j == 2) or (i == 2 and j == 1):
                k = 0
            else:
                k = 1
            mk = float('inf')
            mki = 0
            for n in range(c):
                if n == mii or n == mji:
                    continue
                if dsums[k][n] < mk:
                    mk = dsums[k][n]
                    mki = n
            rs.append(mi+mj+mk)
    print(min(rs))

main()


Measured memory_bytes: 5620
#include<stdio.h>
int main(){
  long long n, d;scanf("%lld %lld", &n, &d);
  
  int cnt=0;
  for(int i=0;i<n;i++) {
    long long a, b;scanf("%lld %lld", &a, &b);
    long long r2 = a*a + b*b;
    if(r2<=d*d){
      cnt++;
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        map<int, int> mp;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            mp[a[i]]++;
        }
        int sum = 0;
        for(auto i : mp){
            sum += (i.ss * (i.ss - 1)) / 2;
        }
        for(int i = 0; i < n; i++){
            cout << sum - mp[a[i]] + 1 << '\n';
        }
    }
}

Measured memory_bytes: 42368
def main():
    S = input()
    cond = '7' in S
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 9032
W, H, N = map(int,input().split())

X = [True]*W
Y = [True]*H

for i in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        for j in range(x):
            X[j] = False
    if a == 2:
        for j in range(x,W):
            X[j] = False
    if a == 3:
        for j in range(y):
            Y[j] = False
    if a == 4:
        for j in range(y,H):
            Y[j] = False

ans = 0
for i in range(W):
    for j in range(H):
        if X[i] and Y[j]:
            ans += 1
            
print(ans)

Measured memory_bytes: 9156
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int a; // 三角形の２辺
    int b; // 三角形の２辺
    int C; // その間の角度

    double s; // 三角形の面積
    double l; // 三角形の周の長さ
    double h; // aを底辺としたときの高さ

    double c;
    double rad; // ラジアン
    double PI = acos(-1); // 円周率
    // cout << PI << endl;

    cin >> a >> b >> C;
    // cout << a << endl;
    // cout << b << endl;
    // cout << C << endl;

    rad = C * PI / 180;
    // cout << rad << endl;
    // cout << ((double)1 / (double)2) * a * b * sin(rad) << endl;
    s = a * b * sin(rad) / 2;

    c = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)));
    // printf("%lf\n", c);
    l = a + b + c;

    h = b * sin(rad);

    printf("%lf\n", s);
    printf("%lf\n", l);
    printf("%lf\n", h);

    return 0;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

vector<vector<int>> F;
vector<vector<ll>> P;
ll N;
ll ans = -INF;
void dfs(string f)
{
  if (f.size() == 10)
  {
    if (f == string(10, '0'))
      return;
    
    ll tmp = 0;
    for (ll i = 0; i < N; i++)
    {
      ll cnt = 0;
      for (ll j = 0; j < 10; j++)
      {
        if (F.at(i).at(j) && f.at(j) == '1')
          cnt++;
      }
      tmp += P.at(i).at(cnt);
    }

    chmax(ans, tmp);
    return;
  }

  dfs(f + "0");
  dfs(f + "1");
}

int main()
{
  cin >> N;
  F.resize(N, vector<int>(10));
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < 10; j++)
    {
      cin >> F.at(i).at(j);
    }
  }
  P.resize(N, vector<ll>(11));
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < 11; j++)
    {
      cin >> P.at(i).at(j);
    }
  }

  dfs("");

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    a=a*3;
    c=a+b;
    printf("%d\n",c/2);
}


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

int main(){
    int n; cin >> n;
    string s[n];
    for(int i = 0; i < n; i++) cin >> s[i];
    int m; cin >> m;
    string t[m];
    for(int i = 0; i < m; i++) cin >> t[i];

    int ans=0;
    for(int i = 0; i < n; i++)
    {
        int tmp=0;
        for(int j = 0; j < n; j++)
        {
            if(s[i]==s[j]) tmp++;
        }
        for(int k = 0; k < m; k++)
        {
            if(s[i]==t[k]) tmp--;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
     
    
    return 0;
}

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

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

   //std::sort(A.begin(),A.end());
   int min = 1000000000;
   int gcd = 0;
   for(int i=1; i<N; ++i){
      int denominator = A[0];
      int numerator = A[i]; 
      while(true){
	 int rest = numerator%denominator;
	 if(rest==0) {
	    gcd = denominator;
	    break;
	 }else{
	    numerator = denominator;
	    denominator = rest;
	 }
      } 
      if(min>gcd) min = gcd;
   }
   std::cout << min << std::endl;

   return 0;
}


Measured memory_bytes: 640
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string s;
  cin >> s;
  // const int64_t L = static_cast<int64_t>(T.length());
  if (s.c_str()[0] >= 'A' && s.c_str()[0] <= 'Z') {
    cout << "A" << endl;
  } else {
    cout << "a" << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool is_triangle(vector<int>& v){
  REP(i, v.size()) if(v[i] != i + 1) return false;
  return true;
}

int main(){
  int N;
  while(cin >> N && N){
    vector<int> b(N);
    REP(i, N) cin >> b[i];
    bool NG = true;;
    REP(iter, 10001){
      if(is_triangle(b)){
        NG = false;
        cout << iter << endl;
        break;
      }
      REP(i, b.size()) b[i]--;
      b.push_back(b.size());
      b.erase(remove(b.begin(), b.end(), 0), b.end());
    }
    if(NG) cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
import java.awt.image.AreaAveragingScaleFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final List<boolean[]> list = new ArrayList<>();
        final boolean[] booleans = new boolean[n];
        createArray(booleans, list, 0, n - 1);
        final List<int[]> indexList = new ArrayList<>();

        for (int i = 0; i < m; i++) {
            final int[] ints = new int[scanner.nextInt()];
            for (int j = 0; j < ints.length; j++) {
                ints[j] = scanner.nextInt() - 1;
            }
            indexList.add(ints);
        }

        for(int i = 0;i<m;i++){
            int zeroOrOne = scanner.nextInt();
            final int[] ints = indexList.get(i);

            for (int i1 = 0; i1 < list.size(); i1++) {
                final boolean[] booleans1 = list.get(i1);
                int counter = 0;
                for (final int anInt : ints) {
                    if (booleans1[anInt]) {
                        counter++;
                    }
                }
                if (counter % 2 != zeroOrOne) {
                    list.remove(i1);
                    i1--;
                }
            }
        }


        System.out.println(list.size());
    }

    private static void createArray(final boolean[] bools, final List<boolean[]> list, final int index, final int last) {
        if (index == last) {
            bools[index] = true;
            list.add(getNewArray(bools));
            bools[index] = false;
            list.add(getNewArray(bools));
            return;
        }

        bools[index] = true;
        createArray(bools, list, index + 1, last);
        bools[index] = false;
        createArray(bools, list, index + 1, last);
    }

    private static boolean[] getNewArray(final boolean[] original) {
        final boolean[] booleans = new boolean[original.length];
        for (int i = 0; i < original.length; i++) {
            booleans[i] = original[i];
        }
        return booleans;
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int z;
		
		for(int i=0; i<9; i++) {
			if(a>b) {
				z=a;
				a=b;
				b=z;
			}
			if(b>c) {
				z=b;
				b=c;
				c=z;
			}
		}
		System.out.println(a+" "+b+" "+c);
	}

}


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

int main(){

    int q;
    cin >> q;
    map<string, int> mp;
    for(int i = 0; i < q; ++i){
        int com;
        string key;
        cin >> com >> key;
        if(com == 0){
            int x;
            cin >> x;
            mp[key] = x;
        }
        else if(com == 1){
            cout << mp[key] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 27808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  vector<int> gate(n + 1, 0);
  for(int i = 0, l, r; i < m; ++i){
    cin >> l >> r;
    l--;
    gate[l]++;
    gate[r]--;
  }
  int ans = 0;
  if(gate[0] == m) ans++;
  for(int i = 1; i < n; ++i){
    gate[i] += gate[i - 1];
    if(gate[i] == m) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<numeric>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 11;
const int inf = (1<<20);

template <class T> int getindex(T &a,map<T,int> & M){
  int index = M.size();
  if (M.find(a) == M.end())M[a]=index;
  return M[a];
}

int g[N][N];
int dp[(1<<N)][N];
void tsp(int n){
  rep(k,n)rep(i,n)rep(j,n)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
  rep(i,(1<<n))rep(j,n)dp[i][j]=inf;
  dp[1<<0][0]=0;
  rep(i,(1<<n)){
    rep(j,n){//visited
      if (((1<<j)&i) == 0)continue;
      rep(k,n){//unvisited
	if ((1<<k)&i)continue;
	int next=(1<<k)|i;
	dp[next][k]=min(dp[next][k],dp[i][j]+g[j][k]);
      }
    }
  }
}

void solve(int n,map<int,int> *c,vector<int> &req){
  int ac=inf,aw=inf;
  rep(i,(1<<n)){
    if ((1&i) == 0)continue;
    int tc=inf,tw=inf;
    vector<int> mini(req.size(),inf);
    rep(j,n){
      if (((1<<j)&i) == 0)continue;
      tw=min(tw,dp[i][j]+g[j][0]);
      rep(k,(int)req.size()){
	if (c[j].find(req[k]) != c[j].end())mini[k]=min(mini[k],c[j][req[k]]);
      }
      tc = accumulate(mini.begin(),mini.end(),0);
    }
    if (tc < ac || (tc == ac && tw < aw))ac=tc,aw=tw;
  }
  if (ac == inf)cout <<"impossible"<<endl;
  else cout << ac <<" " << aw << endl;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n+1){rep(j,n+1)g[i][j]=inf;g[i][i]=0;}
    map<string,int> M;
    map<int,int> c[n+1];
    rep(i,n){
      int num;cin>>num;
      rep(j,num){
	string name;int cost,ind;
	cin>>name>>cost;
	ind=getindex(name,M);
	c[i+1][ind]=cost;
      }
    }

    int req;
    cin>>req;
    vector<int> in(req);
    rep(i,req){
      string tmp;
      cin>>tmp;
      in[i]=getindex(tmp,M);
    }
    
    int m;
    cin>>m;
    rep(i,m){
      int f,t,c;cin>>f>>t>>c;
      g[f][t]=g[t][f]=c;
    }
    tsp(n+1);

    solve(n+1,c,in);
  }
}

Measured memory_bytes: 0
s=input()
n=len(s)
k=0
l=1
r=2
j=s[0]
cnt=1
ans=[]
while r<=n:
  if s[l:r]==j:
    r+=1
  else:
    j=s[l:r]
    ans+=[j]
    l=r
    r+=1
    cnt+=1
print(cnt)

Measured memory_bytes: 86092
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();

        int[] C = new int[N];
        int[][] A = new int[N][M];

        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        sc.close();

        long ans = Integer.MAX_VALUE;

        for (int t = 0; t < (1 << N); t++) {
            int[] target = new int[M];
            int cost = 0;
            for (int i = 0; i < N; i++) {
                if ((t >> i & 1) == 1) {
                    for (int j = 0; j < M; j++) {
                        target[j] += A[i][j];
                    }
                    cost += C[i];
                }
            }

            boolean flg = true;
            for (int j = 0; j < M; j++) {
                if (target[j] < X) {
                    flg = false;
                }
            }
            if (flg) {
                ans = Math.min(ans, cost);
            }
        }
        if (ans == Integer.MAX_VALUE) {
            ans = -1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37568
fun main(args : Array<String>) {
    val (n, p) = readLine()!!.split(" ").map { it.toLong() }
    val factors = factors(p)

    var ans = 1L
    factors.forEach {
        if (it.value >= n) {
            ans *= Math.pow(it.key.toDouble(), (it.value / n).toDouble()).toLong()
        }
    }

    println(ans)
}

fun factors(value: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    val max = Math.sqrt(value.toDouble()).toLong()
    var tmp = value

    for (i in 2..max) {
        while (tmp % i == 0L) {
            tmp /= i
            factors[i] = (factors[i] ?: 0) + 1
        }
    }
    factors[tmp] = 1

    return factors
}

Measured memory_bytes: 38004
//Author: ReseeCher
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
#define ckmax(a,b) (a)=max(a,b)
#define ckmin(a,b) (a)=min(a,b)
#define pb push_back
using namespace std;
const int N=262144;
const int M=55;
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
int nn,n,K,S,T;
LL a[N];
int q[N];
int cnt[N];
LL C[55][55];
void FWT(){
	for(int mid=1;mid<N;mid<<=1)
		for(int l=0;l<N;l+=mid+mid)
			for(int k=l;k<l+mid;++k)
				a[k+mid]+=a[k];
}
LL Sol(int st){
	memset(a,0,sizeof(a));
	F(i,st+1,n)
		a[q[i]^q[st]]++;
	FWT();
	LL an=0;
	int uT=T-(T&S);
	for(int i=uT;i;i=uT&(i-1)){
		int fg=((cnt[uT]-cnt[i])&1)?-1:1;
		an+=fg*C[a[i]][K-1];
	}
	int i=0;
	int fg=((cnt[uT]-cnt[i])&1)?-1:1;
	an+=fg*C[a[i]][K-1];
	return an;
}
int main(){
	//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	F(i,1,N-1)cnt[i]=cnt[i>>1]+(i&1);
	F(i,0,M-1)C[i][0]=1;
	F(i,1,M-1)F(j,1,i)C[i][j]=C[i-1][j-1]+C[i-1][j];
	F(i,0,M-1)F(j,1,M-1)C[i][j]+=C[i][j-1];
	
	nn=R();K=R();S=R();T=R();
	F(i,1,nn){
		int x=R();
		if((x&S)!=S)continue;
		if((x&T)!=x)continue;
		q[++n]=x;
	}
	LL ans=0;
	F(i,1,n)ans+=Sol(i);
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
#define rep(i, n) for(int64_t i = 0; i < n; ++i)
using namespace std;

int main() {
  int a, b, m, M;
  cin >> a >> b;
  M = max(a, b);
  m = min(a, b);
  string s = "";
  rep(i, M) s += to_string(m);
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
  priority_queue<ll> que;
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i]; que.push(a[i]);
  }
  ll sum=0;
  for(int i=0;i<m;i++){
    ll s=que.top();
    que.pop();
    que.push(s>>1);
  }
  for(int i=0;i<n;i++){
    ll s=que.top();
    que.pop();
    sum+=s;
  }
  cout << sum << endl;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=0;
    if(s.find("S")!=string::npos){n++;}
    if(s.find("N")!=string::npos){n--;}
    if(s.find("E")!=string::npos){n+=2;}
    if(s.find("W")!=string::npos){n-=2;}
    cout<<(n==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

//#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int h,w,cost[10][10],ans = 0;
	cin >> h >> w;
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < 10;j++) cin >> cost[i][j];
	}
	for(int k = 0;k < 10;k++){
		for(int i = 0;i < 10;i++){
			for(int j = 0;j < 10;j++) cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
		}
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			int a;
			cin >> a;
			if(a != -1) ans += cost[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import math
N = int(input())
ans = 1
q = [1 for i in range(N + 1)]
for i in range(2,N + 1):
    k = i
    for i2 in range(2,i + 1):
        while k % i2 == 0:
            k /= i2
            q[i2] += 1
            
for i in range(N + 1):
    ans *= q[i]
    ans %= 10 ** 9 + 7

print(ans)

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

using namespace std;

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

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

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

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

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

	if(x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
const int N=2005,mod=1000000007;
int n,m,k,tp,f[2][N],ans;

void inc(int &x,int y)
{
	x=(x+y)%mod;
}

bool check(int p,int q,int i)
{
	int x=p+q,y=i*(k-1)-p+k-q;
	return x<=m && y<=n && x%(k-1)==m%(k-1) && y%(k-1)==n%(k-1);
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	f[0][0]=1;
	rep(i,0,(n+m-1)/(k-1))
	{
		tp^=1,memset(f[tp],0,sizeof(f[tp]));
		rep(j,0,m) if(f[tp^1][j])
		{
			int tmp=f[tp^1][j];
			rep(x,0,k-1) if(j+x<=m) inc(f[tp][j+x],tmp);
			rep(x,1,k-1) if(check(j,x,i)) inc(ans,tmp);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N;
int sum[101];
int w[101];

int main(void) {
    cin>>N;

    for(int i = 0;i < N;i++) {
        cin>>w[i];
        sum[i] = (i == 0 ? w[i] : sum[i-1]+w[i]);
    }

    int ans = 101*190;
    for(int T = 0;T < N;T++) {
        ans = min(ans,abs(sum[N-1]-2*sum[T]));
    }

    cout<<ans<<endl;

    return 0;
}






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

int n,f[100000],q,g[50000];
int x=0;

int main(){
	cin >> n;
	for(int i=0;i<100000;i++){
		for(int j=0;j<100000;j++){}
	}
	for(int i=0;i<n;i++) cin >> f[i];
	cin >> q;
	for(int i=0;i<q;i++) cin >> g[i];
	for(int i=0;i<q;i++){
		for(int j=0;j<n;j++){
			if(g[i]==f[j]){
				x++;
				break;
			}
		}
	}
	cout << x <<endl;
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

struct RollingHash
{
    static constexpr ull MASK30 = (1UL << 30) - 1, MASK31 = (1UL << 31) - 1, MOD = (1UL << 61) - 1;
    static constexpr ull base = 1e9 + 7;
    RollingHash(const string &s) : hashvec{vector<ull>(s.size())}, sz{(int)s.size()}, basevec{vector<ull>(s.size())}
    {
        hashvec[0] = s[0];
        basevec[0] = 1;
        FOR(i, 1, sz)
        {
            hashvec[i] = CalcMod(Multiply(hashvec[i - 1], base) + s[i]);
            basevec[i] = Multiply(basevec[i - 1], base);
        }
    }
    ull hashval(int l, int r)
    {
        ull Hash = (l - 1 >= 0 ? hashvec[r] + MOD - Multiply(hashvec[l - 1], basevec[r - l + 1]) : hashvec[r]);
        Hash = CalcMod(Hash);
        return Hash;
    }
    ull Multiply(ull a, ull b)
    {
        auto au = a >> 31, ad = a & MASK31, bu = b >> 31, bd = b & MASK31;
        auto mid = ad * bu + au * bd, midu = mid >> 30, midd = (mid & MASK30);
        return CalcMod(au * bu * 2 + midu + (midd << 31) + ad * bd);
    }
    ull CalcMod(ull val)
    {
        val = (val & MOD) + (val >> 61);
        if (val > MOD)
            val -= MOD;
        return val;
    }
private:
    vector<ull> hashvec, basevec;
    int sz;
};

int main()
{
    int n;
    string s;
    cin >> n >> s;
    struct RollingHash rh(s);
    int ans = 0;
    auto lam = [&](int len) -> bool {
        unordered_map<ull, set<int>> ma;
        REP(i, n)
        {
            if (i + len < n)
                ma[rh.hashval(i, i + len)].emplace(i);
        }
        for (auto indset: ma)
        {
            if (indset.SE.size())
            {
                int now = *indset.SE.rbegin() - *indset.SE.begin();
                if (now > len)
                    return true;
            }
        }
        return false;
    };
    int st = -1, en = n;
    while (en - st > 1)
    {
        int mid = (en + st) / 2;
        if (!lam(mid))
        {
            en = mid;
        }
        else
        {
            st = mid;
        }
    }
    cout << st + 1 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

	int r, c;
	int i, j;
	int n[100]={0};
	int z, w=0;

	scanf("%d %d", &r, &c); /* ?????°r??¨?????°c?????\??? */

	int x[r][c];

	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			scanf("%d", &x[i][j]);
		}		/* 2?????????????????§????????¨??????????¨????????????????????´?????????? */
	}

	for(i=0; i<r; i++){
		z = 0;
		for(j = 0; j < c; j++){
			printf("%d ", x[i][j]);
				z += x[i][j];
				n[j] += x[i][j];	/* (100+1)??(100+1)???2?¬???????????????\??????????¨???? */
		}
		printf("%d\n", z);	/* (r+1)??(c+1)?????°????????¨????????? */
	}
	for(j=0; j<c; j++){
		printf("%d ", n[j]);
			w += n[j];
	}
	printf("%d\n", w);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000000
#define mod 1000000007
#define mod2 998244353
const int N = 1000010;
int cur[N] , fact[N] , sum[N]  , val , a, b , arr[N] , sum2[N];
int n;


int fastpower(int num,int po){
    if(po == 0)
        return 1;
    int cur = fastpower(num , (po >> 1));
    cur = (long long)cur * cur % mod;
    if(po & 1)
        cur = (long long)cur * num % mod;
    return cur;
}

inline int nck(int n,int k){
    return (long long)fact[n] * fastpower((long long)fact[k] * fact[n - k] % mod , mod - 2) % mod;
}

int main(){
    fact[0] = 1;
    for(int i = 1;i<N;i++){
        fact[i] = (long long)i * fact[i - 1] % mod;
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    for(int val = n - 2;val >= 0;val--){
        a = n - val;
        sum[val] = (long long)fact[n] * fastpower((long long)fact[val] * fact[a] % mod , mod - 2) % mod;
        sum[val] = (long long)sum[val] * fact[a - 1] % mod;
        sum[val] = (long long)sum[val] * fact[val] % mod;
        sum[val] += sum[val + 1];
        sum[val] %= mod;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        cur[i] = fact[n];
        a = i;
        cur[i] += sum[n - 2 - a + 1] - sum[n - 1] % mod;
        cur[i] %= mod;
        cur[i] += mod;
        cur[i] %= mod;
        a = n - i - 1;
        cur[i] += sum[n - 2 - a + 1] - sum[n - 1] % mod;
        cur[i] %= mod;
        cur[i] += mod;
        cur[i] %= mod;
        ans += (long long)cur[i] * arr[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
			System.out.println("Yes");
		else
			System.out.println("No");
		}
}

Measured memory_bytes: 17360
n, m, c = map(int, input().split())
b = list(map(int,input().split()))
a=[list(map(int,list(input().split()))) for i in range(n)]

ans=0
for i in range(n):
    sum = 0
    for j in range(m):
        sum += a[i][j] * b[j]
    sum += c
    if sum > 0:
        ans += 1
print(ans)

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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())

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

  string s;
  string div[] = {"dream","dreamer","erase","eraser"};

  cin >> s;
  reverse(s.begin(),s.end());

  rep(i,4)
  {
    reverse(div[i].begin(),div[i].end());
  }

  bool cc = true;
  for(int i = 0; i < s.size();)
  {
    bool c = false;
    rep(j,4)
    {
      if(
          s.substr(i,div[j].size()) == div[j]
        )
        {
          i += div[j].size();
          c = true;
        }
    }
    if(!c)
    {
      cc = false;
      break;
    }

  }

  if(cc) cout << "YES" << endl;
  else cout  << "NO" << endl;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 512
using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(
                string.Join(" ",
                    Console.ReadLine()
                        .Split(' ')
                        .Select(int.Parse)
                        .OrderByDescending(x => x)
                        .Select(x => x.ToString())
                        .ToArray()
                        ));
        }
    }
}

Measured memory_bytes: 6448
#include<stdio.h>

int main(){
    int x,a,b,t;

    scanf("%d %d %d",&x,&a,&b);

    t=b-a;

    if(t<=0){
        printf("delicious");
    }
    else if(t<=x){
        printf("safe");
    }
    else{
        printf("dangerous");
    }
    return 0;
}

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

int main(){
  const int64_t mod=1e9+7;
  int N,K;
  cin >> N >> K;
  vector<int64_t> sum(N+2);
  sum.at(0)=0;
  for(int i=1;i<=N+1;i++){
    sum.at(i)=i-1+sum.at(i-1);
  }
  int64_t ans=0;
  for(int i=K;i<=N+1;i++){
    ans+=(sum.at(N+1)-sum.at(N+1-i))-(sum.at(i)-sum.at(0))+1;
    ans%=mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4836
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  int C[N - 1];
  int S[N - 1];
  int F[N - 1];
  for (int i = 0; i < N - 1; ++i)
    cin >> C[i] >> S[i] >> F[i];

  for (int i = 0; i < N - 1; ++i) {
    long long t = S[i];
    for (int j = i; j < N - 1; ++j) {
      if (t < S[j]) {
        t = S[j];
      }
      if ((t - S[j]) % F[j] != 0)
        t += F[j] - ((t - S[j]) % F[j]);
      t += C[j];
    }
    cout << t << endl;
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	string s; cin >> s;
	ll ans = 0;
	rep(bit, (1 << (s.size() - 1))) {
		ll a = s[0] - '0';
		rep(i, s.size() - 1) {
			if (bit & (1 << i)) {
				ans += a;
				a = 0;
			}
			a = a * 10 + s[i + 1] - '0';
		}
		ans += a;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=7+1e9,maxn=5+2e3;
typedef long long ll;
ll qpow(ll a,ll p,ll mod){
	ll ans=1,tmp=a;
	while(p){
		if(p&1)
			ans=ans*tmp%inf;
		tmp=tmp*tmp%inf;
		p>>=1;	
	}
	return ans;
}
ll N(ll k){
	ll ans=1;
	for(ll i=2;i<=k;i++)
		ans=ans*i%inf;
	return ans;	
}
ll C(ll m,ll n){
	return N(n)*qpow(N(m)*N(n-m)%inf,inf-2,inf)%inf;
}
int main(){
	ll n,k;
	cin>>n>>k;
	//BLUE:C(i-1,k-1);RED:C(i,n-k+1);T0TAL:C(i,k-1)*C(i,n-k+1)
	//5 3
	//1:C(0,2)*C(1,3)=3;2:C(1,2)*C(2,3)=2*3=6;C(2,2)*C(3,3)=1
	for(ll i=1;i<=k;i++){
		if(i-1>n-k)
			cout<<"0\n";
		else
			cout<<C(i-1,k-1)*C(i,n-k+1)%inf<<endl;	
	}
}

Measured memory_bytes: 384
/*
Author : Vidish Joshi
*/

#include <bits/stdc++.h>
using namespace std;

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define re(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)
#define br "\n"

int main(){
    FIO;
    ll x; cin>>x;
    ll t = 100, ans = 0;
    while(t < x){
        t += (t/100);
        ans++;
    }
    cout<<ans<<br;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N*N,0);
    vector<pair<int,int>> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].first;
        S[i].first--;
        S[i].second=i;
        A[S[i].first]=i+1;
    }
    
    sort(all(S));
    
    bool ok=true;
    int right=0;
    
    for(int i=0;i<N;i++){
        int a=S[i].first,b=S[i].second,cnt=0;
        int start=right;
        for(int j=start;j<a;j++){
            if(cnt>=b) break;
            right++;
            if(A[j]==0){
                A[j]=b+1;
                cnt++;
            }
        }
        if(cnt<b) ok=false;
    }
    
    for(int i=0;i<N;i++){
        int a=S[i].first,b=S[i].second,cnt=0;
        for(int j=a+1;j<N*N;j++){
            if(cnt>=N-b-1) break;
            if(A[j]==0){
                A[j]=b+1;
                cnt++;
            }
        }
    }
    
    for(int i=0;i<N*N;i++){
        if(A[i]==0) ok=false;
    }
    
    if(ok){
        cout<<"Yes"<<endl;
        for(int i=0;i<N*N;i++){
            if(i) cout<<" ";
            cout<<A[i];
        }
        cout<<endl;
    }else cout<<"No"<<endl;
    
}




Measured memory_bytes: 2176
using System;

public class Program {

        public static void Main(string[] args) {

            string[] l = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
            var s = Console.ReadLine();

            for(int i = 0; i < 7; i++) {

                if(s == l[i]) {

                    Console.WriteLine(7 - i);
                    return;

                }

            }

        }

    }

Measured memory_bytes: 11092
def solve():
    A, B, _, K = [int(i) for i in input().split()]
    if abs(A - B) > 10 ** 18:
        print('Unfair')
        exit()
    if K % 2 == 0:
        print(A - B)
    else:
        print(B - A)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 61712