akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    char trip[2005];
    scanf("%s",trip);
    int s=0,n=0,e=0,w=0;
    for(int i=0;i<strlen(trip);i++){
        if(trip[i]=='S'){
            s++;
        }else if(trip[i]=='N'){
            n++;
        }else if(trip[i]=='E'){
            e++;
        }else if(trip[i]=='W'){
            w++;
        }
    }
    if(s==0 && n!=0){
        printf("No");
        return 0;
    }else if(s!=0 && n==0){
        printf("No");
        return 0;
    }else if(e!=0 && w==0){
        printf("No");
        return 0;
    }else if(w!=0 && e==0){
        printf("No");
        return 0;
    }else{
        printf("Yes");
        return 0;
    }
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define f first
#define s second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int n, m, dc;
int t[maxn];
vector <int> vc[2];
vector <pii> a[maxn];

void dfs(int v) {
    t[v] = 1;
    vc[dc].pb(v);
    ri(0, a[v].size()) {
        if (!t[a[v][i].f]) {
            dfs(a[v][i].f);
            break;
        }
    }
    return;
}

int main() {
//    fin("t.in");
    sync;
    cin >> n >> m;
    fi(1, m) {
        int u, v;
        cin >> u >> v;
        a[u].pb(mp(v, i));
        a[v].pb(mp(u, i));
    }
    clean(t);
    vc[0].clear();
    dc = 0;
    dfs(1);
    dc = 1;
    vc[1].clear();
    dfs(1);
    cout << (int)vc[0].size() + (int)vc[1].size() - 1 << endl;
    ei((int)vc[1].size() - 1, 1) {
        cout << vc[1][i] << " ";
    }
    ri(0, vc[0].size()) {
        cout << vc[0][i] << " ";        
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 9976
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);

//main function
int main() {
    int a = iin(), b = iin();
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a > b) stout("Alice");
    else if (a < b) stout("Bob");
    else stout("Draw");
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 3e3 + 123;
const int PLS = 3e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e16;


string s1, s2, ans = "";
bool vis[N][N];
pair<int, pair<int, int> > dp[N][N];


void rec(int i, int j) {
    if (vis[i][j])
        return;
    vis[i][j] = 1;
    dp[i][j] = {0, {-2, -2}};
    if (s1[i] == s2[j]) {
        rec(i - 1, j - 1);
        dp[i][j] = max(dp[i][j], {dp[i - 1][j - 1].f + 1, {i - 1, j - 1}});
    }
    rec(i, j - 1);
    rec(i - 1, j);
    dp[i][j] = max(dp[i][j], {dp[i][j - 1].f, {i, j - 1}});
    dp[i][j] = max(dp[i][j], {dp[i - 1][j].f, {i - 1, j}});
}


void go(int i, int j) {
    if (dp[i][j].se.f == i - 1 && dp[i][j].se.se == j - 1)
        ans += s1[i];
    if (dp[i][j].se.f < 0)
        return;
    go(dp[i][j].se.f, dp[i][j].se.se);
}


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> s1;
    cin >> s2;
    for (int i = 0; i < s2.size(); i++) {
        if (s1[0] == s2[i])
            dp[0][i] = {1, {-1, i - 1}};
        else if (i != 0)
            dp[0][i] = {dp[0][i - 1].f, {0, i - 1}};
        else
            dp[0][i] = {0, {-2, -2}};
        vis[0][i] = 1;
    }
    for (int i = 0; i < s1.size(); i++) {
        if (s2[0] == s1[i])
            dp[i][0] = {1, {i - 1, -1}};
        else if (i != 0)
            dp[i][0] = {dp[i - 1][0].f, {i - 1, 0}};
        else
            dp[i][0] = {0, {-2, -2}};
        vis[i][0] = 1;
    }
    rec(s1.size() - 1, s2.size() - 1);
    go(s1.size() - 1, s2.size() - 1);
    for (int i = ans.size() - 1; i >= 0; i--)
        cout << ans[i];
}

Measured memory_bytes: 122368
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, i;
	scanf("%lld", &N);
	string S;
	cin >> S;
	vector<int> A(2 * N);
	for(i = 0; i < 2 * N; i++){
		if(S[i] == 'W'){
			A[i] = 0;
		}
		else{
			A[i] = 1;
		}
	}
	vector<int> B(2 * N + 1);
	B[0] = A[0];
	for(i = 1; i < 2 * N; i++){
		B[i] = (A[i - 1] ^ A[i]);
	}
	B[2 * N] = A[2 * N - 1];
	vector<int> C(2 * N);
	for(i = 0; i < 2 * N; i++){
		if(B[i] == 1){
			C[i] = -1;
		}
		else{
			C[i] = 1;
			B[i + 1] ^= 1;
		}
//		printf("C[%lld] = %lld\n", i, C[i]);
	}
	int ans = 1, now = 0;
	for(i = 0; i < 2 * N; i++){
		if(C[i] == -1){
			now++;
		}
		else{
			ans = MOD(ans * now);
			now--;
		}
	}
	if(now != 0){
		printf("0\n");
		return 0;
	}
	int fact = 1;
	for(i = 1; i <= N; i++){
		fact = MOD(fact * i);
	}
	printf("%lld\n", MOD(ans * fact));
	return 0;
}

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

const int MOD=(int)1e9+7;

int main(){
  string S;
  cin >> S;

  long long h=1;
  vector<long long> abc(3,0);
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'){
      abc.at(0)+=h;
      abc.at(0)%=MOD;
    }
    else if(S.at(i)=='B'){
      abc.at(1)+=abc.at(0);
      abc.at(1)%=MOD;
    }
    else if(S.at(i)=='C'){
      abc.at(2)+=abc.at(1);
      abc.at(2)%=MOD;
    }
    else if(S.at(i)=='?'){
      abc.at(2)=abc.at(2)*3+abc.at(1);
      abc.at(1)=abc.at(1)*3+abc.at(0);
      abc.at(0)=abc.at(0)*3+h;
      abc.at(0)%=MOD;
      abc.at(1)%=MOD;
      abc.at(2)%=MOD;
      h*=3;
      h%=MOD;
    }
  }
  cout << abc.at(2) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	int ans = 1;
	int max = -9999999;
	int N;cin >> N;
	vector<string> s(N);
	for (int i = 0;i < N;i++) {
		cin >> s[i];
	}
	int M;cin >> M;
	vector<string> t(M);
	for (int i = 0;i < M;i++) {
		cin >> t[i];
	}
	for (int k = 0;k < N;k++ ) {
		for (int i = k+1;i < N;i++) {
			if (s[k] == s[i]) ans++;
		}
		for (int j = 0;j < M;j++) {
			if (s[k] == t[j]) ans--;
		}
		if (ans > max) max = ans;
		ans = 1;
	}
	if (max >= 0)cout << max << endl;
	else cout << 0 << endl;
}

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



int main()
{
	int n,a[100005]={},s;
	cin>>s;
	for(int i=1;i<=1000000;i++)
	{
		if(a[s]==0)a[s]++;
		else
		{
			cout<<i<<endl;
			return 0;
		}
		if(s%2)s=3*s+1;
		else s/=2;

	}
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4244) // 最悪をします
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

//デバッグ用カッコの有無
#ifdef DEBUG
template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	o << "{"; for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? ", " : "") << v[i]; o << "}"; return o;
}
#endif // DEBUG

template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? " " : "") << v[i]; return o;
}

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int dxp[4] = { 0, 1 }; // x軸方向への変位(正のみ)
int dyp[4] = { 1, 0 }; // y軸方向への変位(負のみ)

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

bool solve() {
	int N, M;
	cin >> N >> M;
	if (N == 0 && M == 0) {
		return false;
	}

	vector<int> C(M), x(N + 1, 0);
	rep(i, M) {
		cin >> C[i];
	}
	REPS(i, N) {
		cin >> x[i];
	}

	vector<vector<int>> dp(N + 1, vector<int>(256, LL_HALFMAX));

	dp[0][128] = 0;

	rep(i, N) {
		rep(j, 256) {
			rep(k, M) {
				int nxt = j + C[k];
				chmax(nxt, 0);
				chmin(nxt, 255);

				int sqCost = abs(x[i + 1] - nxt);
				int cost = sqCost * sqCost;

				chmin(dp[i + 1][nxt], dp[i][j] + cost);
			}
		}
	}

	int ans = LL_HALFMAX;
	rep(i, 256) {
		chmin(ans, dp[N][i]);
	}

	cout << ans << "\n";

	return true;
}

signed main() {
	while(solve()){}
}



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

void swap(int &A, int &B){
  int u = A;
  A = B;
  B = u;
}

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  swap(A,B);
  swap(A,C);
  cout << A << " " << B << " " << C;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, q;
long long num[100000 + 10];
int main(){
	cin >> n;
	long long ans = 0;
	while(n--){
		int x;
		cin >> x;
		num[x]++;
		ans += x;
	}
	cin >> q;
	while(q--){
		int b, c;
		cin >> b >> c;
		ans -= b * num[b];
		ans += c * num[b];
		num[c] += num[b];
		num[b] = 0;
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N+10);
  for (int i=0; i<N; i++) cin >> A[i];
  long long int sum=0;
  
  for (int i=1; i<N; i++){
    if (A[i] < A[i-1]){
      sum += A[i-1] - A[i];
      A[i] = A[i-1];
    }else{
      continue;
    }
  }
  
  cout << sum << endl;
  return 0;
}

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

typedef long long ll;

int main() {

    string s;
    long long a, b;
    cin >> a >> s;

    ll x = (ll)(s[0]-'0');
    ll y = (ll)(s[2]-'0');
    ll z = (ll)(s[3]-'0');

    b = 100*x + 10*y + z;

    cout << (a*b)/100;

    return 0;
}


Measured memory_bytes: 3632
n = int(input())
A = [int(i) for i in input().split()]
print(' '.join([str(i) for i in A]))
for i in range(1, n):
    key = A[i]
    j = i - 1
    while j>=0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
    print(' '.join([str(i) for i in A]))
    


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

int main(){
  int64_t a,b,k,eat;
  cin>> a >> b >> k;
  eat=min(a,k);
  a-=eat; k-=eat;
  eat=min(b,k);
  b-=eat; k-=eat;
  cout<< a <<" "<< b <<endl;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main () {
  int h, w;
  cin >> h >> w;
  vii a(h, vi(w));
  rep (i, h) {
    rep (j, w) {
      cin >> a[i][j];
    }
  }
  vector<pii> idx;
  rep (i, h) {
    if (i % 2 == 0) {
      rep (j, w) {
        idx.push_back(pii(i, j));
      }
    }
    else {
      rrep (j, w) {
        idx.push_back(pii(i, j));
      }
    }
  }
  int cnt = 0;
  vii b;
  rep (k, h * w - 1) {
    int i = idx[k].first, j = idx[k].second;
    int ni = idx[k + 1].first, nj = idx[k + 1].second;
    if (a[i][j] % 2 == 1) {
      a[i][j]--;
      a[ni][nj]++;
      cnt++;
      vi temp = {i + 1, j + 1, ni + 1, nj + 1};
      b.push_back(temp);
    }
  }      
  cout << cnt << endl;
  rep (i, cnt) {
    rep (j, 4) {
      cout << b[i][j];
      if (j != 3) {
        cout << " ";
      }
    }
    cout << endl;
  }
}
            


Measured memory_bytes: 13100
#include <bits/stdc++.h>
#define maxN 52

using namespace std;

//FILE *fin = freopen("b.in", "r", stdin);

/* ----------------------------------------- */
long long k;
/* ----------------------------------------- */
long long a[maxN];

int main()
{
    scanf("%lld", &k);
   int n = 50;
    for (int i = 1; i <= n; ++ i)
        a[i] = (k / n) + i - 1;
    for (int i = 1; i <= k % n; ++ i)
    {
        for (int j = 1; j <= n; ++ j)
            -- a[j];
        a[i] += n + 1;
    }
    printf("%d\n", n);
    for (int i = 1; i <= n; ++ i)
        printf("%lld ", a[i]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)					(a).begin(),(a).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(1000 * 1000 * 1000 * 2)
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
ll getAreaT(ll incHen, ll keepHen)
{
	ll ans = (ll)INF * 10000;
	ll henShort = keepHen / 2;
	ll henLong = keepHen - henShort;
	for (ll i = 1; i < incHen; i++) {
		ll areaS = (incHen - i) * henShort;
		ll areaL = (incHen - i) * henLong;
		ll areaRemain = i * keepHen;
		ll minArea = min(areaS, min(areaL, areaRemain));
		ll maxArea = max(areaS, max(areaL, areaRemain));
		ll diffArea = maxArea - minArea;
		ans = min(ans, diffArea);
	}
	return ans;
}

ll getAreaDiv(ll incHen, ll keepHen)
{
	ll ans;
	ll amari = incHen % 3;
	if (amari == 0) {
		ans = 0;
	} else {
		ans = keepHen;
	}

	return ans;
 }


int main()
{
	ll H, W;
	cin >> H >> W;

	ll ans1 = getAreaT(H, W);
	ll ans2 = getAreaT(W, H);
	ll ans3 = getAreaDiv(H, W);
	ll ans4 = getAreaDiv(W, H);
	ll ans5 = min(ans1, ans2);
	ll ans6 = min(ans3, ans4);
	cout << min(ans5, ans6) << endl;
	return 0;
}



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

int main() {
	ios_base::sync_with_stdio( false );

	int A, B;
	cin >> A >> B;

	if( A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 ) {
		cout << "Possible\n";
	}
	else {
		cout << "Impossible\n";
	}

	return 0;
}


Measured memory_bytes: 256
def fizzbuzz(n):
	if n%15==0: return "FizzBuzz"
	if n%5==0: return "Buzz"
	if n%3==0: return "Fizz"
	return str(n)

while 1:
	try:
		m,n=map(int,raw_input().split())
		if m==0:break
		player=range(1,m+1)
		p=0
		for i in range(n):
			if len(player)==1:
				break
			if fizzbuzz(i+1)!=raw_input():
				del player[p]
				p%=len(player)
			else:
				p=(p+1)%len(player)
		print " ".join(map(str,player))
	except:
		pass

Measured memory_bytes: 4560
#include<iostream>
#include<vector>
#include<set>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  // ここでストリームに obj を書き込みます。
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << "\n";
    cout << *(itr++);
  }
  return os;
}

int main(){
  li h,w,n; cin >>h >>w >>n;
  set<pair<int,int>> st;
  rep(i,n){
    int a,b;  cin >>a >>b; a--;b--;
    st.insert({a,b});
  }
  vector<li> ans(10,0);
  ans[0]=(h-2)*(w-2);
  auto f=
    [&](pair<int,int> p, int i){
      int hh=i/3,ww=i%3;
      pair<int,int> rd={p.first+hh,p.second+ww};
      pair<int,int> lu={rd.first-2,rd.second-2};
      if(df)print(p,i,lu,rd);
      if(rd.first>=h or rd.second>=w) return; 
      if(lu.first<0 or lu.second<0) return;
      int cnt=0;
      rep(j,9){
        if(st.find({lu.first+j/3,lu.second+j%3})!=st.end())cnt++;
      }
      if(df)print("->",cnt);
      ans[cnt]++;
    };
  
  if(df)print(st);
  for(auto p:st){
    rep(i,9){
      f(p,i);
    }
  }
  repa(i,1,10){
    ans[i]/=i;
    ans[0]-=ans[i];
  }
  print(ans);
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  int score[300] = {300000, 200000, 100000};
  int ans = score[X - 1] + score[Y - 1];
  if (ans == 600000) ans += 400000;
  cout << ans << endl;
}

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

void i_sort(int *ary, int len)
{
    for(int k=0;k < len;++k) {
        if (k == len-1) {printf("%d\n", ary[k]);break;}
        printf("%d ", ary[k]);
    }

    for(int i=1;i < len;++i) {
        int key = ary[i];
        int j = i - 1;
        while (j >= 0 && ary[j] > key) {
            ary[j+1] = ary[j];
            --j;
        }
        
        ary[j+1] = key;
        
        for(int k=0;k < len;++k) {
            if (k == len-1) {printf("%d\n", ary[k]);break;}
            printf("%d ", ary[k]);
        }
    }
}

int main()
{
    int n; cin >> n;
    int ary[n];
    for(int i=0;i < n;++i) cin >> ary[i];
    
    i_sort(ary, sizeof(ary)/sizeof(ary[0]));

    return 0;
}

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



int main(){

	int n,m,x;
	cin>>n>>m>>x;
	vector<int> arr(n);
	vector< vector<int> > brr(n);
	for(int i=0;i<n;i++){
		cin>>arr[i];
		for(int j =0;j<m;j++){
			int x;
			cin>>x;
			brr[i].push_back(x);
		}
	}
	int ans = 1e9;
	for(int i=1;i<(1<<n);i++){
		int cost = 0;
		vector<int> crr(m);
		for(int j=0;j<n;j++){
			if(1&(i>>j)){
				cost += arr[j];
				for(int k =0;k<m;k++){
					crr[k] += brr[j][k];
				}
			}
		}
		int flag = 1;
		for(int j=0;j<m;j++){
			if(crr[j] < x)
				flag = 0;
		}
		if(flag == 1)
			ans = min(ans,cost);
	}
	if(ans == 1e9)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
  
  
  
  
	return 0; 
  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
vector<int> F[100001];
int bel=0;
int dist[11][11]={};
//ワーシャルフロイド法
void warshal_froid(int n){
    rep(k,n){//kは中継点
    //すべての中継点kについて、iからkを通ってjに行く距離を調べている
        rep(i,n){
            rep(j,n){
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
}
int main(){
    int h,w;
    cin>>h>>w;
    int c[10][10]={};
    rep(i,10){
        rep(j,10){
            if(i!=j){
                dist[i][j] = 1000000;
            }
        }
    }
    rep(i,10){
        rep(j,10){
            cin>>c[i][j];
            dist[i][j] = c[i][j];
        }
    }
    vector<vector<int>> a(h,vector<int> (w));
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    warshal_froid(10);
    //iからjに変えるのに必要な魔力がc[i][j] => iからjへの距離がc[i][j] -> ワーシャルフロイドで最短距離を求める
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]!=-1){
                ans += dist[a[i][j]][1];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;


char m[12][12];
void dfs(int i, int j) {
    // printf("%d %d\n",i,j);
    m[i][j] = '0';
    if(i < 11 && m[i+1][j] == '1') dfs(i+1,j);
    if(i > 0 && m[i-1][j] == '1') dfs(i-1,j);
    if(j < 11 && m[i][j+1] == '1') dfs(i,j+1);
    if(j > 0 && m[i][j-1] == '1') dfs(i,j-1);
}
 
int main() {
    string s;
    while(cin >> s) {
        if(!s.empty()){
            rep(i,0,12) m[0][i] = s.c_str()[i];
            rep(i,1,12) {
                cin >> s;
                rep(j,0,12) m[i][j] = s.c_str()[j];
            }

            int ans = 0;
            rep(i,0,12) {
                rep(j,0,12) {
                    if(m[i][j] == '1') {
                        ans++;
                        dfs(i,j);
                    }
                }
            }

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

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#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)

int main()
{
    vector<lint> v(3);
    REP(i, 3) { cin >> v[i]; }
    sort(ALL(v));

    cout << v[0]*v[1]/2 <<"\n";

    return 0;
}

Measured memory_bytes: 256
import 'dart:io';

void main() {
  String input = stdin.readLineSync();
  var alphabets = [
    'a',
    'b',
    'c',
    'd',
    'e',
    'f',
    'g',
    'h',
    'i',
    'j',
    'k',
    'l',
    'm',
    'n',
    'o',
    'p',
    'q',
    'r',
    's',
    't',
    'u',
    'v',
    'w',
    'x',
    'y',
    'z'
  ];

  var ALPHABETS = [
    'A',
    'B',
    'C',
    'D',
    'E',
    'F',
    'G',
    'H',
    'I',
    'J',
    'K',
    'L',
    'M',
    'N',
    'O',
    'P',
    'Q',
    'R',
    'S',
    'T',
    'U',
    'V',
    'W',
    'X',
    'Y',
    'Z'
  ];

  
  for(String alphabet in alphabets) {
    if (input == alphabet) {
      print('a');
      break;
    }
  }
  for(String ALPHABET in ALPHABETS) {
    if(input == ALPHABET) {
      print('A');
      break;
    }
  }
}


Measured memory_bytes: 13148
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<vector<lld> > dp(101,vector<lld>(100001,1e18));
int main()
{
     ios;
     lld n,we;
     cin>>n>>we;
     vector<lld> v(n+1),w(n+1);
     rep(i,1,n)
     {
         cin>>w[i]>>v[i];
     }
     lld ans=0;
     dp[0][0]=0;
     rep(i,1,n)
     {
         dp[i]=dp[i-1];
         rep(j,0,100000)
         {
             if(j==0)
                dp[i][j]=0;
             else if(j-v[i]>=0)
             {
                 dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
             }
         }
     }
     rep(i,1,100000)
     {
         if(dp[n][i]<=we)
         {
             ans=i;
         }
     }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int mo = 1e9 + 7;
typedef long long ll;
ll mx(ll x,ll y,ll z){return max(max(x,y),z);}
ll mn(ll x,ll y,ll z){return min(min(x,y),z);}
ll h,w;

void solve()
{
    ll x,y;
    cin>>x>>y;

    ll i,ans=min(x,y);
    if(x%3==0||y%3==0)ans=0;
    else
    {
        for(i=1;i<x;i++)ans=min(mx(i*y,(x-i)*(y/2),(x-i)*((y+1)/2))-mn(i*y,(x-i)*(y/2),(x-i)*((y+1)/2)),ans);
        swap(x,y);
        for(i=1;i<x;i++)ans=min(mx(i*y,(x-i)*(y/2),(x-i)*((y+1)/2))-mn(i*y,(x-i)*(y/2),(x-i)*((y+1)/2)),ans);

    }
    cout<<ans<<endl;
}
main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,A = map(int,input().split())
X = list(map(int,input().split()))

dp = [Counter() for i in range(N+1)]
dp[0][0] = 1

for i,x in enumerate(X):
    for j in range(i,-1,-1):
        for k,v in dp[j].items():
            dp[j+1][k+x] += v

ans = 0
for i in range(1,N+1):
    ans += dp[i][A*i]
print(ans)

Measured memory_bytes: 5492
#include <stdio.h>

int main() {
	int n,n100,n10,n1;
	scanf("%d", &n);
	n100 = n / 100;
	n10 = (n - n100*100) / 10;
	n1 = n % 10;

	if(n100==7||n10==7||n1==7){
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 1732
a,b,c=map(int,input().split())
k = int(input())
count = 0
for i in range(0,k+1):
  if b*2**i > a:
    d = i
    e = b*2**i
    break
else:
  print('No')
for i in range(0, k-d+1):
  if c*2**i > e:
    print('Yes')
    break
else:
  print('No')

Measured memory_bytes: 9184
#include <stdio.h>

#define DIV 1000000007

char S[100008];

int q=0;
long long a=0;
long long ab=0;
long long abc=0;


int main()
{
    scanf("%s", S);

    for (int i = 0; S[i]!='\0'; i++)
    {
        switch(S[i]){
            case 'A':
            a+=3;
            break;
            case 'B':
            ab+=a*3;
            break;
            case 'C':
            abc=abc+ab*3;
            break;
            case '?':
            abc=abc+ab;
            ab+=a;
            a++;
            q++;
            break;
        }
    }
    if(q<3){
        for(int i=0;i<q;i++)abc=abc*3;
        printf("%lld\n",abc/27%DIV);
    }else{
        for(int i=3;i<q;i++)abc=abc*3%DIV;
        printf("%lld\n", abc);
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int H, W, K;

char buf[310][310];
int ans[310][310];
bool checked[310];

bool hasCake(int i) {
  REP(j, W) {
    if(buf[i][j] == '#') return true;
  }
  return false;
}

int main(void) {
  scanf("%d%d%d", &H, &W, &K);
  REP(i, H) {
    scanf("%s", buf[i]);
  }

  int ct = 1;
  REP(i, H) {
    if(hasCake(i)) {
      bool first = true;
      REP(j, W) {
        if(buf[i][j] == '#') {
          if(first) {
            first = false;
          } else {
            ++ct;
          }
          ans[i][j] = ct;
        } else {
          ans[i][j] = ct;
        }
      }
      ++ct;
      checked[i] = true;
    }
  }
  REP(i, H) {
    if(i > 0 && !checked[i] && checked[i-1]) {
      REP(j, W) {
        ans[i][j] = ans[i-1][j];
      }
      checked[i] = true;
    }
  }
  for(int i = H-1; i >= 0; --i) {
    if(i+1 < H && !checked[i] && checked[i+1]) {
      REP(j, W) {
        ans[i][j] = ans[i+1][j];
      }
      checked[i] = true;
    }
  }

  REP(i, H) {
    REP(j, W) {
      printf("%d%c", ans[i][j], j == W-1 ? '\n' : ' ');
    }
  }
  return 0;
}


Measured memory_bytes: 1280
package main

import (
	"fmt"
	"strconv"
)

func nextInt() int {
	var i int
	fmt.Scan(&i)
	return i
}

func main() {
	_ = nextInt()
	w := nextInt()
	n := nextInt()

	var c, hc int
	var l string
	for i := 1; i <= n; i++ {
		a := nextInt()
		s := strconv.Itoa(i)
		for j := 0; j < a; j++ {
			if l == "" {
				l = s
			} else {
				if hc%2 == 0 {
					l += " " + s
				} else {
					l = s + " " + l
				}
			}
			c++
			if c%w == 0 {
				fmt.Println(l)
				l = ""
				hc++
			}
		}
	}
}

Measured memory_bytes: 3968
n, m = map(int, input().split())
a = input().split()
a = [int(x) for x in a]
rem = a[0] % m
diff = {rem: 1}

for i in range(1, len(a)):
    a[i] += a[i - 1]
    rem = a[i] % m
    if rem in diff:
        diff[rem] += 1
    else:
        diff[rem] = 1

print(sum([((r*(r + 1))//2 if x == 0 else (r*(r - 1))//2) for (x, r) in diff.items()]))

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

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

struct State{
  int solve, id, time;
  map<int, int> wrong;
  
  State(): solve(0), id(0), time(0) {}
  
  bool operator< (const State &a) const{
    if(solve == a.solve){
      if(time == a.time){
	return id > a.id;
      }
      else return time < a.time;
    }
    else return solve > a.solve;
  }
};

int main(){
  int M, T, P, R;
  while(cin >> M >> T >> P >> R, M|T|P|R){
    vector<State> res;
    for(int i = 1 ; i <= T ; i++){
      State tmp;
      tmp.id = i;
      res.push_back(tmp);
    }
    
    int m, t, p, ac;
    rep(i, R){
      cin >> m >> t >> p >> ac;
      t--;
      if(ac == 0){
	res[t].solve++;
	res[t].time += m + res[t].wrong[p]*20;
      }
      else{
	res[t].wrong[p]++;
      }
    }
    sort(res.begin(), res.end());
    
    for(int i = 0 ; i < res.size() ; i++){
      cout << res[i].id;
      if(i == res.size()-1){
	cout << endl;
      }
      else if(res[i].solve == res[i+1].solve && res[i].time == res[i+1].time){
	cout << '=';
      }
      else cout << ',';      
    }
  }  
  return 0;
}

Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, m;
	cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	cin >> m;
	VI b(m); rep(i, m)cin >> b[i];

	VI re;
	set_symmetric_difference(all(a), all(b), inserter(re, end(re)));
	for (auto x : re)cout << x << endl;
}


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

const long long mod = 1000000007;

long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

std::vector<long long> fac(1000100), inv(1000100), finv(1000100); //階乗 / 逆元 / inv * fac
void comb_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2;i < 1000100; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

int main()
{
    comb_init();
    int n;
    std::cin >> n;
    std::vector<long long> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    std::map<long long,long long> prime;

    for(int i = 0; i < n; i++){
        int cur = a[i];
        for(int j = 2; j * j <= cur; j++){
            if(cur % j == 0){
                int cnt = 0;
                while(cur % j == 0){
                    cur /= j;
                    cnt++;
                }
                prime[j] = std::max(prime[j],(long long)cnt);
            }
        }
        if(cur > 1){
            prime[cur] = std::max(prime[cur],1LL);
        }
    } 

    long long res = 0;
    long long lcm = 1;
    for(auto i : prime){
        lcm *= pow_mod(i.first,i.second,mod);
        lcm %= mod;
    }
    for(int i = 0; i < n; i++){
        res += lcm * inv[a[i]];
        res %= mod;
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 24448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <queue>
#include <cmath>
#include <cfloat>
#include <set>
#include <map>

// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	map< int, int > mp;
	
	auto primes = [&](int m) {
		for (int p=2; p*p<=m; ++p) {
			if (m%p != 0) continue;
			int num = 0;
			while (m%p == 0) ++num, m /= p;
			mp[p] += num;
		}
		if (m>1) mp[m]++;
	};

	REP(i, n) {
		primes(i+1);
	}

	int _2 = 0, _4 = 0, _14 = 0, _24 = 0, _74 = 0;
	EACH(mi, mp) {
		if (mi.second >= 74) ++_74;
		if (mi.second >= 24) ++_24; 
		if (mi.second >= 14) ++_14;
		if (mi.second >= 4) ++_4;
		if (mi.second >= 2) ++_2;
	}

	int ans = 0;
	ans += _4 * (_4-1) * (_2-2) / 2;
	ans += _14 * (_4-1);
	ans += _24 * (_2-1);
	ans += _74;

	/*
	debug(_2);
	debug(_4);
	debug(_14);
	debug(_24);
	debug(_74);
	debug(ans);
	*/
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string.h>
#include <sstream>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	int n;
	cin >> n;
	int a = 1,b = 1;
	vector<int> ex(n+1);
	ex[0] = 1;
	for(int i = 1;i <= n;i++){
		ex[i] = i * ex[i-1];
	}

	vector<int> p(n),q(n);
	vector<int> tmp(n);

	for(int i = 0;i < n;i++){
		cin >> p[i];
	}
	for(int i = 0;i < n;i++){
		cin >> q[i];
	}

	fill(tmp.begin(),tmp.end(),-1);
	int num;
	for(int i = 0;i < n;i++){
		num = 0;
		for(int j = 0;j < n;j++){
			if((p[i] - 1) == j){
				tmp[(p[i] - 1)] = 1;
				break;
			}
			if(tmp[j] == -1){
				num++;
			}
		}
		a += num * ex[n - i - 1];
	}

	fill(tmp.begin(),tmp.end(),-1);
	for(int i = 0;i < n;i++){
		num = 0;
		for(int j = 0;j < n;j++){
			if((q[i] - 1) == j){
				tmp[(q[i] - 1)] = 1;
				break;
			}
			if(tmp[j] == -1){
				num++;
			}
		}
		b += num * ex[n - i - 1];
	}

	cout << abs(a - b) << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())

l=[[0]*2 for _ in range(n)]

for i in range(n):
        l[i][0],l[i][1]=map(str,input().split())
        l[i][1]=-int(l[i][1])
        l[i].append(i+1)

l.sort()

for j in range(n):
        print(l[j][2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    const double PI  =3.14159265358979323846;
    cin>>n;
     double res=2*PI*n;
    cout.precision(20);
    cout<<res;

}


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


int main()
{
    int i,d,j,k,n,m;
    cin>>d>>n;
    int ans=1;
    for(i=0;i<d;i++) ans=ans*100;
    cout<<(n==100 ? (n+1)*ans:n*ans);

}


Measured memory_bytes: 256
#include <stdio.h>

void bomb(int,int);
int field[10][10];

int main(){
	int i,j,k,n,x,y;
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				scanf("%1d",&field[j][k]);
			}
		}
		scanf("%d",&x);
		scanf("%d",&y);
		bomb(x - 1,y - 1);
		printf("Data %d:\n",i + 1);
		for(j = 0;j < 8;j++){
			for(k = 0;k < 8;k++){
				printf("%d",field[j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

void bomb(int x,int y){
	int i,j;
	field[y][x] = 0;
	for(i = -3;i <= 3;i++) {
		if(x + i >= 0 && x + i <= 7 && field[y][x + i] == 1) bomb(x + i,y);
		if(y + i >= 0 && y + i <= 7 && field[y + i][x] == 1) bomb(x,y + i);
	}
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    int a,n,counter=1;
    cin>>n;
    map<int,int> mp;
    rep(i,n){
        cin>>a;
        mp[a]=counter;
        counter++;
    }
    rep(i,n){
        cout<<mp[i+1]<<" ";
    }
    return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mid ((l+r)/2)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define drep(i,a,b) for(int i=(a);i>=(b);--i)
#define file(a) freopen(#a".in","r",stdin),freopen(#a".out","w",stdout);
const int maxn=2e5+5,mod=1e9+7,inf=0x3f3f3f3f;
int n,m,Q,K,T;
int read(){
    int 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;
}int fa[maxn],siz[maxn];
int sum[maxn];
int find(int x){return (fa[x]==x)?x:fa[x]=find(fa[x]);}
signed main(){
    //file(a);
    n=read();m=read();
    rep(i,1,n)fa[i]=i,siz[i]=1;
    rep(i,1,m){
        int x=read(),y=read();
        int fx=find(x),fy=find(y);
        if(fx==fy)continue;
        if(siz[fx]>siz[fy])swap(fx,fy);
        fa[fx]=fy;siz[fy]+=siz[fx];
    }int ans=0;
    rep(i,1,n)sum[find(fa[i])]++;
    rep(i,1,n)ans=max(ans,sum[i]);
    printf("%d\n",ans);



    return 0;
}


Measured memory_bytes: 5988
#include <iostream>
using namespace std;
int main(){
	
	int n,l[10000],r[10000],ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		ans+=r[i]-l[i]+1;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    ld a, b;
    cin>>a>>b;
    int x=a*b;
    cout<<x;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3828
//
// Created by Sotetsu KOYAMADA on 2020/03/02.
//

#include <iostream>
#include <vector>

int fib(int n, std::vector<int> &dp) {
    if (n == 0) return 1;
    if (n == 1) return 1;
    if (dp[n] != -1) return dp[n];
    return dp[n] = fib(n - 1, dp) + fib(n - 2, dp);
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> dp(n+1, -1);
    std::cout << fib(n, dp) << std::endl;
}


Measured memory_bytes: 3116