akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int n,m,k;
        cin>>n>>m>>k;
        string s[n];
        fori(i,n) cin>>s[i];
        int ans = 0;
        int num = 0;
        fori(i,n)
            fori(j,m) num += s[i][j] == '#';
        for(int i = 0; i< (1<<n); i++) {
            for(int j = 0; j< (1<<m); j++) {
                set<pair<int,int>> u;
                for(int p = 0; p <n; p++) {
                    for(int q =0; q<m; q++) {
                        if(((i>>p) & 1 ) || ((j>>q)&1)) {
                            if(s[p][q] == '#') u.insert({p,q});
                        }
                    }
                }
                if(num-u.size() == k) ans++;
            }
        }
        cout<<ans;
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
int main(){
	int m,n,t;
	double c;
	scanf("%d%d%d",&m,&n,&t);
	if(m<n) m=n;
	c=1.0*t/m;
	if(floor(c)==ceil(c)) printf("%d",(int)c);
	else printf("%d",(int)c+1);
	
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int H,W,i,j;
	for(;;){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC126B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();

            var front = int.Parse(input.Substring(0, 2));
            var end = int.Parse(input.Substring(2, 2));

            if ((front > 12 || front == 0) && (end <= 12 && end >= 1))
            {
                Console.WriteLine("YYMM");
            }
            else if ((end > 12 || end == 0) && (front <= 12 && front >= 1))
            {
                Console.WriteLine("MMYY");
            }
            else if ((end <= 12 && end >= 1) && (front <= 12 && front >= 1))
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<' '<<x<<' '<<y;
  return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[3];
  scanf("%s",s);
  int i;
  if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[0]){
    for(i=0;i<3;i++){
      if(s[i]=='a' || s[i]=='b' || s[i]=='c'){
        if(i==2){
        puts("Yes");
        }
      }
      else{
        if(i==2){
        puts("No");
        }
      }
    }
  }
  else{
    puts("No");
  }
    return 0;
  }

Measured memory_bytes: 128
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int n;
    scan(n);

    auto a = new int[](n), b = new int[](n);
    auto c = new int[](n), d = new int[](n);

    foreach (i ; 0 .. n) {
        scan(a[i], b[i]);
    }

    foreach (i ; 0 .. n) {
        scan(c[i], d[i]);
    }

    auto adj = new Edge[][](2*n + 2, 0);

    void addEdge(int u, int v) {
        adj[u] ~= Edge(v, 1, adj[v].length.to!int);
        adj[v] ~= Edge(u, 0, adj[u].length.to!int - 1);
    }

    foreach (i ; 0 .. n) {
        addEdge(0, i + 1);
        addEdge(n + i + 1, 2*n + 1);
    }

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            if (a[i] < c[j] && b[i] < d[j]) {
                addEdge(i + 1, n + j + 1);
            }
        }
    }

    int ans = FordFulkerson(adj, 0, 2*n + 1);

    writeln(ans);
}



import std.typecons;
alias Edge = Tuple!(int, "to", int, "cap", int, "rev");
immutable inf = 10^^9 + 7;

int FordFulkerson(Edge[][] adj, int s, int t) {
    int n = adj.length.to!int;
    auto visited = new bool[](n);

    int dfs(int u, int f) {
        if (u == t) {return f;}

        visited[u] = 1;

        foreach (ref e ; adj[u]) {
            if (!visited[e.to] && e.cap > 0) {
                int d = dfs(e.to, min(f, e.cap));

                if (d > 0) {
                    e.cap -= d;
                    adj[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }

        return 0;
    }

    int F;

    while (true) {
        visited[] = 0;
        int f = dfs(0, inf);
        if (!f) break;
        F += f;
    }

    return F;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv( maxN+5, 1 );
vcL fac( maxN+5, 1 );

void ADD(lli &x, lli y) {
	x += y;
	if ( x >= mod ) x -= mod;
	if ( x < 0 ) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = ( x%mod + mod ) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if ( e&1 ) MUL( ans, b );
		MUL( b, b );
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow( n, mod-2 );
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod-mod/i) * inv[ mod%i ] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[ i-1 ] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if ( a < b ) return 0;

	MUL( ans, inv[ fac[ a-b ] ] );
	MUL( ans, inv[ fac[b] ] );
	MUL( ans, fac[a] );

	return ans;
}

lli Lucas(lli n, lli m) {
	if ( m == 0 ) return 1;
	return cm( n%mod, m%mod ) * Lucas( n/mod, m/mod ) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas( n, m );
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	char s[4];
	cin >> s;
	
	sort( &s[0], &s[0]+4 );
	
	if ( s[0] == s[1] and s[2] == s[3] and s[0] != s[2] ) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 3328
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

import heapq

N,M = II()
A = III()

a = [(-x,x) for x in A]
heapq.heapify(a)

for _ in range(M):
    y = heapq.heappop(a)
    heapq.heappush(a,(y[0]/2, y[1]/2))

ans = 0
for i in range(N):
    ans += math.floor(a[i][1])

print(ans)

Measured memory_bytes: 99328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = new string[n];
            for (var i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
            }

            var minCharCount = new int['z' - 'a' + 1];
            for (var i = 0; i < 'z' - 'a' + 1; i++)
            {
                minCharCount[i] = int.MaxValue;
            }

            for (var i = 0; i < n; i++)
            {
                var charCount = new int['z' - 'a' + 1];
                for (var j = 0; j < s[i].Length; j++)
                {
                    charCount[s[i][j] - 'a']++;
                }

                for (var j = 0; j < 'z' - 'a' + 1; j++)
                {
                    minCharCount[j] = Math.Min(minCharCount[j], charCount[j]);
                }
            }

            var answer = "";
            for (var i = 0; i < 'z' - 'a' + 1; i++)
            {
                for (var j = 0; j < minCharCount[i]; j++)
                {
                    answer += (char)('a' + i);
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
/* 二つの整数x,yの最大公約数を求める関数(x>=y)*/
int gcdf(int vx,int vy)
{
 return (!vy) ? vx : gcdf(vy,vx%vy);
}

/* 二つの整数x,yの最大公約数を求める関数(大きいほうを自動的に取り出すようにする。 */
int gcd(int vx,int vy)
{
 return (vx>vy) ? gcdf(vx,vy) : gcdf(vy,vx);
}

int main()
{
 int a,b;
 while(scanf("%d %d",&a,&b)!=EOF){
          printf("%d %d\n",gcd(a,b),(a/gcd(a,b))*b);
         }
return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int max = 0, cnt = 0, prev_h = 0;
    for (int i = 0; i < n ; i++) {
        int h;
        cin >> h;
        if (h <= prev_h) cnt++;
        else {
            if (cnt > max) max = cnt;
            cnt = 0;
        }
        prev_h = h;
    }
    if (cnt > max) max = cnt;
    cout << max << endl;
    
    return 0;
}


Measured memory_bytes: 256
while True:
    H, W = list(map(int, input().split()))
    if H == 0 and W == 0:
        break
    for height in range(H):
        for wide in range(W):
            if height == 0 or height == H-1 or wide == 0 or wide == W-1:
                print('#', end='')
            else:
                print('.', end='')
        print('')
    print('')

Measured memory_bytes: 8940
#include<stdio.h>
int main()
{
    int n,x=1,a=0;
    int i = 1;
    scanf("%d",&n);

    do{
        x = i;
        if (x % 3 == 0){
            printf(" %d",i);
            a = 1;
        }
        if (a==0){
            do{
                if (x % 10 == 3){
                	printf(" %d",i);
                    break;
                }
                x /= 10;

            } while (x);
        }
        else{
            a = 0;
        }
    } while (++i<=n);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2044
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Time {

    final int h;
    final int m;
    final int s;

    Time( int h, int m, int s ) {
	this.h = h;
	this.m = m;
	this.s = s;
    }

    Time( int s ) {
	this.h = s / 3600;
	s %= 3600;
	this.m = s / 60;
	s %= 60;
	this.s = s;
    }

    public int toSec() {
	return 3600 * h + 60 * m + s;
    }

    public String toString() {
	return String.format( "%02d:%02d:%02d", h, m, s );
    }
}

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int h = stdin.nextInt();
	    final int m = stdin.nextInt();
	    final int s = stdin.nextInt();

	    if ( h == -1 && m == -1 && s == -1 ) {
		break;
	    }
	    
	    Time t = new Time( h, m, s );
	    int rest = 7200 - t.toSec();
	    int rest3 = rest * 3;
	    System.out.println( new Time( rest ) );
	    System.out.println( new Time( rest3 ) );	    	    
	}	
    }
}

Measured memory_bytes: 18332
// TLEになる
#include <bits/stdc++.h>
using namespace std;

const long long INF = 10000000000000007;
const int MAX_A = 51;
const int MAX_N = 51;

struct edge{ 
    int to; int a; long long b; 
    edge(int _to, int _a, long long _b): to(_to), a(_a), b(_b) {} 
};



typedef pair<int,int> P;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<edge>> G(N);
    vector<long long> C(N), D(N);
    long long SumA = 0;
    for(int i = 0; i < M; ++i) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(edge(v, a, b));
        G[v].push_back(edge(u, a, b));
        SumA += a;
    }
    for(int i = 0; i < N; ++i) {
        cin >> C[i] >> D[i];
    }

    // 各町ごとに、銀貨の枚数が0 ~ Amax×(N-1)
    vector<vector<long long>> State(N, vector<long long>(SumA + 1, INF));
    priority_queue<P, vector<P>, greater<P> > que;

    // que.second = K -> i = K/(Amax*(N-1) + 1), j = K%(Amax*(N-1) + 1)
    int Row_size = SumA + 1;
    S = min((long long)S, SumA); // 銀貨をAmax*(N-1)枚になるまで捨てる
    State[0][S] = 0;
    que.push(P(0, Row_size*0 + S));
    while(!que.empty()){
        P q = que.top(); que.pop();
        int City = q.second/Row_size; 
        long long Money = q.second - City*Row_size;
        if(State[City][Money] < q.first) continue;
        for(int i = 0; i < G[City].size(); ++i) {
            edge e = G[City][i];
            // 購入するときの遷移 (多分ここでTLEになってそう)
            for(int j = 1; ; ++j) { 
                // j := 交換する金貨
                // 消費する時間は j*D[City]
                // 得られる銀貨は j*C[City]
                long long nM = min(SumA, Money + C[City]*j);
                if(State[City][nM] > State[City][Money] + D[City]*j) {
                    State[City][nM] = State[City][Money] + D[City]*j;
                    que.push(P(State[City][nM], City*Row_size + nM));
                }
                else { break; /*この処理でTLE回避した*/} // 基本的に、同じ頂点に対して、お金を増やす遷移をして、ある程度お金を増やしたら効果はなくなると考えられる
                if(nM >= SumA) break;
            }
            // 移動するときの遷移
            long long nM = Money - e.a;
            if(nM < 0) continue;
            if(State[e.to][nM] > State[City][Money] + e.b) {
                State[e.to][nM] = State[City][Money] + e.b;
                que.push(P(State[e.to][nM], e.to*Row_size + nM));
            }
        }
    }
    for(int i = 1; i < N; ++i) {
        auto &p = State[i];
        cout << *min_element(p.begin(), p.end()) << endl;
    }
    return 0;
}

Measured memory_bytes: 20656
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<int> p(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &p[i]);
                p[i] --;
        }
        vector<vector<int>> g(n);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        vector<bool> used(n, false);
        vector<int> found1;
        set<int> found2;
        function<void (int)> dfs = [&](int u) {
                found1.push_back(u);
                found2.insert(p[u]);
                used[u] = true;
                for (auto v : g[u]) if (!used[v]) {
                        dfs(v);
                }
        };
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                found1.clear();
                found2.clear();
                if (!used[i]) {
                        dfs(i);
                }
                for (int i = 0; i < (int) found1.size(); i ++) {
                        ans += found2.count(found1[i]);
                }
        }
        printf("%d\n", ans);
        return 0;
}



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

typedef pair<int,int> P;

int main ()
{
    int n, m;
    while (cin >> n >> m, n || m) {
        vector<pair<int,P> > data(m);
        vector<bool> v(n+1, false);
        v[1] = true;

        for (int i = 0; i < m; i++) {
            int t;
            cin >> t;
            P p;
            cin >> p.first >> p.second;
            data[i] = pair<int,P>(t,p);
        }

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

        for (int i = 0; i < m; i++) {
            if (v[data[i].second.first]) v[data[i].second.second] = true;
        }

        int res = 0;
        for (auto i : v) {
            if (i) res++;
        }

        cout << res << endl;
    }

    return 0;
}

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

int main(){
  int a, b;
  int r;
  string op;
  while (true) {
    cin >> a >> op >> b;
    
    if (op=="+") r = a+b;
    if (op=="-") r = a-b;
    if (op=="*") r = a*b;
    if (op=="/") r = a/b;
    if (op=="?") break;
    
    cout << r << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int H, W;
	cin >> H >> W;
	vector<vector<int> > A(H, vector<int>(W));
	vector<vector<int> > B(H, vector<int>(W));
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			cin >> A[h][w];
		}
	}
	B = A;
	int cnt = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (h + 1 < H) {
				if (A[h][w] & 1) {
					A[h][w]--;
					A[h + 1][w] += 1;
					++cnt;
				}
			}
			else {
				if (w + 1 < W) {
					if (A[h][w] & 1) {
						A[h][w]--;
						A[h][w + 1]++;
						++cnt;
					}
				}
			}
		}
	}
	/*
	int cnt = 0;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (A[h][w] % 2 == 0) {
				++cnt;
			}
		}
	}
	cout << cnt << endl;
	*/
	cout << cnt << endl;
	for (int h = 0; h < H; ++h) {
		for (int w = 0; w < W; ++w) {
			if (h + 1 < H) {
				if (B[h][w] & 1) {
					B[h][w]--;
					B[h + 1][w] += 1;
					cout << h + 1 << " " << w + 1 << " ";
					cout << h + 1 + 1 << " " << w + 1 << endl;
				}
			}
			else {
				if (w + 1 < W) {
					if (B[h][w] & 1) {
						B[h][w]--;
						B[h][w + 1]++;
						cout << h + 1 << " " << w + 1 << " ";
						cout << h + 1 << " " << w + 1 + 1 << endl;
					}
				}
			}
		}
	}
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 4096
function Main(input){
  inp = input.split('\n');
  N = parseInt(inp[0]);
  A = inp[1].split(' ').map((i) => { return parseInt(i); });
//  N = 3;
//  A = [3, 2, 1];

  result = true;
  count = 0;
  do {
    
    // is All Even Number
    for (i = 0; i < N; i++) {
      if (A[i]%2 != 0) {
        result = false;
        break;
      }
      A[i] = A[i]/2;
    }
    
    if (result) count++;
  } while (result);

  console.log(count);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
def isEvenString(s):
  if s[0:len(s)//2]==s[len(s)//2:]:
    return True
  return False

s=input()
for z in range(2,len(s)+1,2):
  if isEvenString(s[0:len(s)-z]):
    ans=len(s)-z
    break

print(ans)

Measured memory_bytes: 3060
N = int(input())
ans = 0
max_ans = 0
cont_flg = 0
for _ in range(N):
  D = list(map(int, input().split()))
  if D[0] == D[1]:
    ans += 1
    max_ans = max(max_ans, ans)
  if D[0] != D[1]:
    cont_flg = 1
    ans = 0
if max_ans >= 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62456
#include <stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int array[N];
    for(int i=0;i<N;i++)
        scanf("%d",&array[i]);
    
    int change=0;
    int flg=1;
    int cp;

    while(flg){
        flg=0;
        for(int i=0;i<N-1;i++){
            if(array[i]>array[i+1]){
                cp=array[i];
                array[i]=array[i+1];
                array[i+1]=cp;
                change++;
                flg=1;
            }
        }
    }

    for(int i=0;i<N;i++){
        if(i==0)
            printf("%d",array[i]);
        else
            printf(" %d",array[i]);
    }
    printf("\n");
    printf("%d\n",change);
}


Measured memory_bytes: 2100
import sys

info = input().split(" ")
N = int(info[0])
K = int(info[1])
Q = int(info[2])
  
ns = []
for i in range(N):
  ns.append(K - Q)

for i in range(Q):
  s = int(input())
  s = s - 1
  ns[s] = ns[s] + 1
      
  
for p in ns:
  if p <= 0:
    print("No")
  else:
    print("Yes")


Measured memory_bytes: 7848
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

int w,h;
char in[100][100];
bool vis[2][100][100];
int solve(){
  priority_queue<pair<PI,PI> > q;
  memset(vis,0,sizeof(vis));
  rep(i,h)rep(j,w){
    cin>>in[i][j];
    if(in[i][j]=='S'){
      q.push(mp(mp(0,0),mp(i,j)));
      q.push(mp(mp(0,1),mp(i,j)));
    }
  }

  while(!q.empty()){
    pair<PI,PI> cv=q.top();q.pop();
    int fo=cv.F.S;
    int cc=-cv.F.F;
    int cx=cv.S.F;
    int cy=cv.S.S;
    if(vis[fo][cx][cy])continue;
    vis[fo][cx][cy]=true;
    if(in[cx][cy]=='T')return cc;
    for(int i=-2;i<=2;++i)
      for(int j=1;j<=3-abs(i);++j){
        int nx=cx+i;
        int ny=cy+(fo*2-1)*j;
        if(min(nx,ny)<0 || nx>=h || ny>=w ||
           vis[!fo][nx][ny] || in[nx][ny]=='X')continue;
        int nc=cc;
        if(isdigit(in[nx][ny]))nc+=in[nx][ny]-'0';
        q.push(mp(mp(-nc,!fo),
                  mp(nx,ny)));
      }
  }
  return -1;  
}


main(){
  while(cin>>w>>h,h)
    cout<<solve()<<endl;
}

Measured memory_bytes: 996
#include<stdio.h>
#include<string.h>

int main(void){
    int a, b, c;
    char *p = "NO";

    scanf("%d %d %d", &a, &b, &c);
    for(int i = 1; i < b; i++){
        if(a*i % b == c){
            p = "YES";
            break;
        }
    }

    printf("%s", p);
    
    return 0;
}

Measured memory_bytes: 1736
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


nums = fetch_int_input()
echo_result = ["win", "bust"]

print(echo_result[sum(nums) > 21])

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

int n;
vector<vector<int>> G;

int dfs(int v, int p) {
    vector<int> vec;
    for(auto& nv: G[v]) {
        if(nv == p) continue;
        int r = dfs(nv, v);
        ++r;
        vec.push_back(r);
    }
    sort(all(vec));
    reverse(all(vec));
    int res = 0;
    int j = 0;
    for(auto& rec: vec) {
        chmax(res, rec + j);
        ++j;
    }
    return res;
}

void solve() {
	cin >> n;
    G.assign(n + 1, vector<int>());
    rep(i, n - 1) {
        int a; cin >> a; --a;
        G[i + 1].push_back(a);
        G[a].push_back(i + 1);
    }
    cout << dfs(0, -1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 15104
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()

class UnionFind(object):
    """UnionFind (経路圧縮、ランクあり)"""
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n

    def union(self, n1, n2):
        r1 = self.root(n1)
        r2 = self.root(n2)
        if r1 != r2:
            if self.rank[r1] < self.rank[r2]:
                self.parent[r1] = r2
            else:
                self.parent[r2] = r1
                if self.rank[r1] == self.rank[r2]:
                    self.rank[r1] += 1

    def root(self, node):
        p = self.parent[node]
        if p == node:
            return p
        p = self.root(p)
        self.parent[node] = p
        return p

    def same(self, n1, n2):
        return self.root(n1) == self.root(n2)


def main():
    N, M = MI()
    uf = UnionFind(N)

    for i in range(M):
        x, y, _ = MI()
        uf.union(x-1, y-1)

    return len(set([uf.root(i) for i in range(N)]))


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 17040
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=5005;
struct node
{
    int a,b;
}a[N];
int n;
bool cmp(node a,node b)
{
    return b.a-a.b>a.a-b.b;
}
ll dp[N];
int main()
{
    memset(dp,inf,sizeof(dp));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].a,&a[i].b);
    sort(a+1,a+1+n,cmp);
    dp[0]=0;
    for(int i=1;i<=n;i++)
        for(int j=i-1;j>=0;j--)
        if(dp[j]<=a[i].a)
        dp[j+1]=min(dp[j+1],dp[j]+a[i].b);
    for(int i=n;i>=0;i--)
        if(dp[i]<1e18)
    {
        printf("%d\n",i);return 0;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 44;
const int X[] = {1,0,-1,0,1,-1,1,-1};
const int Y[] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;

int a[N][5], dp[N][5];

int main () {
	boost;
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		for (int j = 0 ; j < 3 ; ++ j) {
			cin >> a[i][j];
		}
	}
	dp[0][0] = a[0][0], dp[0][1] = a[0][1], dp[0][2] = a[0][2];
	for (int i = 0 ; i < n - 1 ; ++ i) {
		for (int j = 0 ; j < 3 ; ++ j) {
			for (int k = 0 ; k < 3 ; ++ k) {
				if (j == k) continue;
				dp[i + 1][k] = max (dp[i + 1][k], dp[i][j] + a[i + 1][k]);
			}
		}
	}
	cout << max ({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}

Measured memory_bytes: 6272
import sys
from bisect import bisect_right
input = sys.stdin.readline
INF = 10**18
a, b, q = map(int, input().split())
S = [-INF] + [ int(input()) for _ in range(a) ] + [INF]
T = [-INF] + [ int(input()) for _ in range(b) ] + [INF]

for i in range(q):
    x = int(input())
    c, d = bisect_right(S, x), bisect_right(T, x)
    ans = INF
    for s in S[c-1:c+1]:
        for t in T[d-1:d+1]:
            ans = min( ans, abs(t-x)+abs(s-t), abs(s-x)+abs(t-s) )
    print(ans)

Measured memory_bytes: 64220
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    vec<string> ans = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
    cout << ans.at(N % 10) << "\n";
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in); 
		int a, b;
		int d, e;
		double f;
		
		a = scan.nextInt();
		b = scan.nextInt();
		
		d = a / b;
		e = a % b;
		f = (double)a / b;
		
	System.out.println(d + " " + e + " " + String.format("%.09f", f));
		
	}

}

Measured memory_bytes: 26396
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

struct SCC
{
	vector<vector<int> > G;
	vector<vector<int> > rG;
	vector<int> vs;
	vector<bool> used;
	vector<int> cmp;
	int sz,newsz;
	SCC(int n):G(n),rG(n),used(n,false),cmp(n){sz = n;}
	
	void add_edge(int from,int to)
	{
		G[from].PB(to);
		rG[to].PB(from);
	}
	
	void dfs(int v)
	{
		used[v] = true;
		REP(i,G[v].size())
		{
			if(!used[G[v][i]])dfs(G[v][i]);
		}
		vs.PB(v);
	}
	
	void rdfs(int v,int k)
	{
		used[v] = false;
		cmp[v] = k;
		REP(i,rG[v].size())
		{
			if(used[rG[v][i]])rdfs(rG[v][i],k);
		}
	}
	
	int reMake()
	{

		vs.clear();
		REP(i,sz)if(!used[i])dfs(i);
		int k = 0;
		for(int i = sz-1;i >= 0;i--)
		{
			if(used[vs[i]])
			{
				rdfs(vs[i],k++);
			}
		}
		return newsz = k;
	}
	
	
	
	void makeList(vector<vector<int> > &v)
	{
		REP(i,sz)
		{
			REP(j,G[i].size())
			{
				if(cmp[i] == cmp[G[i][j]])continue;
				v[cmp[i]].PB(cmp[G[i][j]]);
			}
		}
	}

	void makeReverseList(vector<vector<int> > &v)
	{
		REP(i,sz)
		{
			REP(j,G[i].size())
			{
				if(cmp[i] == cmp[G[i][j]])continue;
				v[cmp[G[i][j]]].PB(cmp[i]);
			}
		}
	}
	
	int scc_node(int n)
	{
		return cmp[n];
	}
};


int main()
{
	int n,m;cin >> n >> m;
	
	SCC scc(n);
	
	REP(i,m)
	{
		int a,b;cin >> a >> b;
		scc.add_edge(a,b);
	}
	
	scc.reMake();
	
	int q;cin >> q;
	
	REP(i,q)
	{
		int a,b;cin >> a >> b;
		if(scc.scc_node(a) == scc.scc_node(b))
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
			
	return 0;
}

Measured memory_bytes: 4376
while True:
    n,r = map(int,input().split())
    if(n==0): break
    cards = list(range(n,0,-1))
    for i in range(r):
        p,c = map(int,input().split())
        cards = cards[p-1:p+c-1] + cards[:p-1] + cards[p+c-1:]
    print(cards[0])



Measured memory_bytes: 5612
import math
import cmath
def dot(a:complex,b:complex):
  return (a.conjugate()*b).real
def cross(a:complex,b:complex):
  return (a.conjugate()*b).imag
p=[]
n=int(input())
for i in range(n):
  x,y=map(float,input().split())
  p.append(complex(x,y))
S=0
for i in range(1,len(p)-1):
  S+=cross(p[i]-p[0],p[i+1]-p[0])
print(abs(S)/2)


Measured memory_bytes: 5728
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,g;
cin>>n>>g;
int sum(0);
for(int i=0; i<g; ++i)
{
int a;
cin>>a;
sum+=a;
}
if(sum<n)
cout<<"No";
else
cout<<"Yes";
}


Measured memory_bytes: 384
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

dp = [[-1]*w for i in range(h)]
if l[0][0] == ".":
    dp[0][0] = 0
else:
    dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            continue

        if i == 0:
            if l[i][j-1] == "." and l[i][j] == "#":
                dp[i][j] = dp[i][j-1]+1
            else:
                dp[i][j] = dp[i][j-1]
        elif j == 0:
            if l[i-1][j] == "." and l[i][j] == "#":
                dp[i][j] = dp[i-1][j]+1
            else:
                dp[i][j] = dp[i-1][j]
        else:
            a = dp[i-1][j]
            b = dp[i][j-1] 
            if l[i-1][j] == "." and l[i][j] == "#":
                a += 1
            if l[i][j-1] == "." and l[i][j] == "#":
                b += 1
            dp[i][j] = min(a,b)
print(dp[-1][-1])
         
            

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

int main () {
  string s;
  cin >> s;
  int ans = 0, N = s.length();
  for (int i=0;i<N;++i)
    if (s[i] != s[N-1-i]) ans++;
  printf("%d\n",ans/2);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
p = list(map(float, input().split()))
dp = [[0] * (N + 1) for _ in range(N)]
#dp[i][j]...i+1番目までのコインを投げて、j枚が表になる確率
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]

for i in range(N - 1):
	for j in range(N):
		dp[i + 1][j + 1] += dp[i][j] * p[i + 1]
		dp[i + 1][j] += dp[i][j] * (1 - p[i + 1])
		
ans = 0

for j in range(N // 2 + 1, N + 1):
	ans += dp[N - 1][j]
	
print(ans)


Measured memory_bytes: 253448
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // number of S
        long N = in.nextLong();
        // number of c
        long M = in.nextLong();
        long result = 0;

        if (N == 0 && M == 0) {
            result = 0;
        } else if (N >= M / 2) {
            result = M / 2;
            N -= M / 2;
            //if (N >= 0) {
            //    result += N / 2;
            //}
        } else {
            // N < M / 2
            result = N;
            M -= 2 * N;
            if (M >= 0) {
                result += M / 4;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21716
n,k = map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

ans = Base_10_to_n(n,k)
print(len(ans))


Measured memory_bytes: 2940
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      int m=Integer.parseInt(line);
      boolean t=false;
      for(int i=0;i<=m;i+=4){
      	for(int j=i;j<=m;j+=7){
        	if(j==m){
            	t=true;
              break;
            }
        }
        if(t)break;
      }
      if(t)System.out.println("Yes");
      else System.out.println("No");
    }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll a[n];
	zep(i, 0, n){
		cin >> a[i];
	}
	
	ll cnt[1000008];
	memset(cnt, 0, sizeof(cnt));
	zep(i, 0, n){
		ll x = a[i];
		for(ll j = 2; j*j <= x; j++){
			ll cntb = 0;
			while(x%j == 0){
				x /= j;
				cntb++;
			}
			cnt[j] = max(cntb, cnt[j]);
		}
		if(x > 1){
			cnt[x] = max(1LL, cnt[x]);
		}
	}
	ll gcd = 1;
	rep(i, 2, 1000000){
		gcd *= powl(i, cnt[i]);
		gcd %= MOD;
	}
	
	ll ans = 0;
	zep(i, 0, n){
		ll buf = gcd*modinv(a[i], MOD);
		buf %= MOD;
		ans += buf;
		ans %= MOD;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll sieve(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  ll n;
  cin >> n;
  const auto &res=sieve(n);
  ll ans=0;
  for(auto p:res) {
    ll temp=p.second;
    for(ll i=1;i<=temp;i++) {
      temp-=i;
      if(temp>=0) {
        ans++;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define NUM 100

int main(){
  int m[NUM+1][NUM+1],n,i,j,k,u,a;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      m[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&a);
      m[u][a]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",m[i][j]);
      if(j+1<=n){
	printf(" ");
      }
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int MAXN = 1e2 + 5;

inline int Abs(int x){ return x<0? -x: x;}

int a[MAXN];

int main(void)
{
	int x,n;
	scanf("%d%d",&x,&n);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	int ans = 0x3f3f3f3f;
	
	for(int i=0; i<=100+1; ++i)
	{
		bool flag = 1;
		for(int j=1; j<=n; ++j)
			if(a[j] == i)
			{
				flag = 0;
				break;
			}
		if(!flag) continue;
		
		if(Abs(x-ans) > Abs(x-i))
			ans = i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1728
#ABC 124, B - great ocean view
n = int(input())
H = [int(el) for el in input().split(' ')]

count = 1
max_h = H[0]
for i in range(1, n):
    if H[i] - max_h >= 0:
        count += 1
        max_h = H[i]

print(count)


Measured memory_bytes: 3060
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b; cin >> a >> b;
    ll c,d; cin >> c >> d;
    ll turn = 0;
    while(1){
        if(~turn & 1){
            c -= b;
        }
        else{
            a -= d;
        }
        if(c <= 0 || a <= 0)break;
        turn ^= 1;
    }

    if(c <= 0){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 3.8 + c[j] * 9;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3728