akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n, l;
  cin >> n >> l;

  int ans = 0;
  int mi = INF;
  rep(i,n) {
    ans += l + i;
    if (abs(mi) > abs(l+i)) {
      mi = l+i;
    }
  }

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

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

int main(){ 
  string S;
  Int Q;
  
  vector<int> T(200010), F(200010);
  vector<char> C(200010);
  
  cin >> S >> Q;
  
  bool rev = true;
  string left, right;
  
  rep(i,Q) {
    cin >> T[i];
    if (T[i] == 1) rev = !rev;
    else {
      cin >> F[i] >> C[i];
      if ((rev && F[i] == 2) || (!rev && F[i] == 1)) {
        right = right + C[i];
      }
      else {
        left = left + C[i];
      }
    }
  }
  
  if (rev) {
    reverse(left.begin(),left.end());
    cout << left + S + right << endl;
  }
  else {
    reverse(right.begin(),right.end());
    reverse(S.begin(),S.end());
    cout << right + S + left << endl;
  }

}

Measured memory_bytes: 3376
#pragma warning(disable: 4996)
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <random>
#include <deque>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <utility>
using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a != c) cout << 1;
	else cout << 0;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

typedef pair<int, int> P;
typedef long long ll;

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

const int MAX = 1<<19;

char s1[MAX], s2[MAX];
int n, m, g;

int main()
{
  scanf("%d%d %s %s", &n, &m, s1, s2);

  ll L = lcm(n, m);
  g = __gcd(n, m);
  int mp = m / g, np = n / g;

  int ok=1;
  for (int a=0; ; a++) {
    ll kn = (ll) np * a;
    ll km = (ll) mp * a;
    if (kn >= n || km >= m) break;
    if (s1[kn] != s2[km])
      ok = 0;
  }

  if (!ok) printf("-1\n");
  else printf("%lld\n", L);

  return 0;
}



Measured memory_bytes: 384
s = gets.chomp!.to_s
s_list=s.split("")
s_list.sort!
#p s_list
a = s_list.uniq.size
if a <= 1
  print("No\n")

else
  if s_list[0] == s_list[1] && s_list[2] == s_list[3]
    print("Yes\n")
  else
    print("No\n")
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, m;
    cin >> n >> m;

    ll res;
    if (n == 1 && m == 1) res = 1;
    else if (n == 1 || m == 1) res = n * m - 2;
    else {
        res = n * m - (2 * (n + m) - 4);
    }

    cout << res << endl;

    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<int> a(N, 0);
	for (int i=0; i<N; i++)
		cin >>a.at(i);
	int A=0;
	for (int i=0; i<N; i++)
		if (1==a.at(i)-A)
			A++;
	if(0==A)
		cout <<-1 <<endl;
	else
		cout <<N-A <<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LONG_LONG_MAX;
const int MAX_N = 112345;




int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int H,W,D;
    cin >> H >> W >> D;
    vector<Pii> points(H*W+1);
    repeat(i, H){
        repeat(j, W){
            int A;
            cin >> A;
            points[A] = make_pair(j, i);
        }
    }
    
    vint sum(H*W+10,0);
    repeat(i, H*W-D+1){
        sum[i+D+1] = sum[i+1]
                    +abs(points[i+D+1].first - points[i+1].first)
                    +abs(points[i+D+1].second - points[i+1].second);
    }
    int Q;
    cin >> Q;
    vint ans(Q,0);
    repeat(q, Q){
        int L,R;
        cin >> L >> R;
        ans[q] = sum[R] - sum[L];
    }
    repeat(q, Q){
        cout << ans[q] << endl;
    }
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&(k^'-'))k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
/*void init()
{
}
void solve()
{
}*/
const int MAXN=6000;
int n;
struct node{
	int p,h;
}a[MAXN];
bool cmp(node a,node b){return a.h+a.p<b.h+b.p;}
long long f[MAXN];
int main(){
	read(n);
	memset(f,63,sizeof f);
	f[0]=0;
	Rep(i,1,n)read(a[i].h),read(a[i].p);
	sort(a+1,a+n+1,cmp);
	Rep(i,1,n)
		Repe(j,i,1)
			if(f[j-1]<=a[i].h)f[j]=min(f[j],f[j-1]+a[i].p);
	Rep(i,1,n)if(f[i]>1e18)
	{
		printf("%d\n",i-1);
		return 0;
	}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{   int A,B;
    scanf ("%d %d",&A,&B);
    if (A==B){
    	printf("Draw\n");
	}
	else if (A!=1&&B!=1) {
	if (A>B) {
	  printf ("Alice\n");
	} else if (A<B) {
	  printf ("Bob\n");
	} }
	else if (A==1&&B!=1) { 
    printf ("Alice\n") ;
		
	} else if (B==1&&A!=1) {
	  printf ("Bob\n");
	}  
	  return 0;
} 

Measured memory_bytes: 128
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    ll A;
    cin >> N;
    cin >> A;
    N -= 500 * (N / 500) + A;
    if (N <= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

// using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

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

ll d[5000], dsum[5001];
int main() {
  ll k, querylen;
  cin >> k >> querylen;
  repi(k) cin >> d[i];
  repi(querylen) {
    ll n, x, m;
    cin >> n >> x >> m;
    --n;
    x %= m;
    dsum[0] = 0;
    ll plusforoneloop = 0;
    repj(k) {
      if (d[j] % m) ++plusforoneloop;
      dsum[j + 1] = dsum[j] + d[j] % m;
    }
    ll loopnum = n / k, rest = n % k, xb = loopnum * dsum[(int)k] + x;
    ll res = loopnum * plusforoneloop - xb / m;
    xb %= m;
    // cout << "xb:" << xb << " rest:" << rest << endl;
    repj(rest) {
      ll newxb = (xb + d[j]) % m;
      if (newxb > xb) ++res;
      xb = newxb;
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 3988
main=do
 getLine
 a<-map read.words<$>getLine
 let t=foldl1(\x y->if x*y>10^18 then 10^18+1 else x*y)a
 print$if null[1|b<-a,b==0]then if t>10^18 then -1 else t else 0

Measured memory_bytes: 64156
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

#define INFINITY 2000000000

using namespace std;

int main(){

	int V,E,from,to,dist;

	scanf("%d %d",&V,&E);
	long long int table[V][V];

	for(int i = 0; i < V; i++){
		for(int k = 0; k < V; k++){
			if(i != k){
				table[i][k] = INFINITY;
			}else{
				table[i][k] = 0;
			}
		}
	}

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&dist);
		table[from][to] = dist;
	}

	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			if(table[i][k] == INFINITY)continue;
			for(int j = 0; j < V; j++){
				if(table[k][j] == INFINITY)continue;
				table[i][j] = min(table[i][j],table[i][k]+table[k][j]);
			}
		}
	}

	bool FLG = true;

	for(int i = 0; i < V; i++){
		if(table[i][i] < 0){
			FLG = false;
			break;
		}
	}

	if(!FLG)printf("NEGATIVE CYCLE\n");
	else{
		for(int i = 0; i < V; i++){
			if(table[i][0] == INFINITY)printf("INF");
			else{
				printf("%lld",table[i][0]);
			}

			for(int k = 1;k < V; k++){
				if(table[i][k] == INFINITY)printf(" INF");
				else{
					printf(" %lld",table[i][k]);
				}
			}
			printf("\n");
		}
	}

    return 0;
}



Measured memory_bytes: 2800
A, B = map(int, input().split())
S = input()

fwd = S[0:A]
bwd = S[A+1:]
flag = 0
if fwd.isdigit() == True:
    if S[A] == '-':
        if bwd.isdigit() == True:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,c,d; cin>>a>>b>>c>>d;
    string s = "Balanced";
    if(a+b>c+d)s="Left";
    else if(a+b<c+d)s="Right";
    out(s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const int N = 1e5 + 18;



int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {

        int k;
        cin >> k;

        int i = 0;
        bool ji = false;
        int x = 7;
        for (i = 1; i <= k; i++) {
            x %= k;
            if (x == 0) {
                ji = true;
                break;
            }
            x = x * 10 + 7;
        }

        if (ji) cout << i << endl;
        else cout << -1 << endl;

    }
    return 0;

}



Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
    int m;
    int d;
    int cnt= 0;
    scanf("%d", &m);
    scanf("%d", &d);
    for (int i = 0; i <= m; i++){
        for (int j = 22; j <= d; j++){
            int d_1 = j % 10;
            int d_10 = j / 10;
            if (d_1 >= 2 && (d_1 * d_10) == i) cnt++;
        }  
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	char b, ans;
	scanf("%c", &b);

	switch (b) {
	case 'A':
		ans = 'T';
		break;
	case 'T':
		ans = 'A';
		break;
	case 'C':
		ans = 'G';
		break;
	case 'G':
		ans = 'C';
		break;
	}
	printf("%c\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	string n; cin >> n;
	if (n=="ABC") cout << "ARC" << "\n";
	else cout << "ABC" << "\n";
}


Measured memory_bytes: 3568
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


R =  int(sys.stdin.readline())
G =  int(sys.stdin.readline())

print(math.floor((2 * G) - R))

Measured memory_bytes: 64364
A, B, C, X, Y = map(int,input().split())
ans = 0
mi = min(X, Y); ma = max(X, Y); sub = abs(X - Y);

price = 0
if max(X, Y) == X:
  price = A
else:
  price = B
part_c = 2*C*mi + sub*price

print(min(2*C*ma, part_c, A*X + B*Y))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <list>
#include <vector>
#include <algorithm>

#define rep(i,n) for(ll i = 0;i < n;i++)
#define REP(i,n,k) for(ll i = n;i < k;i++)
#define P(p) cout << (p) << endl;//print
typedef long long ll;
using namespace std;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int a,b;
    string t;
    cin >> a >> b;
    cin >> t;
    rep(i,a){
        if(t[i]=='-'){
            P("No")
            return 0;
        }
    }
    if(t[a]!='-'){
        P("No")
        return 0;

    }
    REP(i,a+1,a+b){
        if(t[i]=='-'){
            P("No")
            return 0;
        }
    }
    P("Yes")
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int e, y;
  cin >> e >> y;
  if(!e){
    if(y < 1912) cout << 'M' << y-1867 << endl;
    else if(y < 1926) cout << 'T' << y-1911 << endl;
    else if(y < 1989) cout << 'S' << y-1925 << endl;
    else cout << 'H' << y-1988 << endl;
  }
  if(e == 1) cout << y+1867 << endl;
  if(e == 2) cout << y+1911 << endl;
  if(e == 3) cout << y+1925 << endl;
  if(e == 4) cout << y+1988 << endl;
}



Measured memory_bytes: 3112
K = int(input())

if K < 11:
    print(K)
    exit()
K -=10
ll_num = [0,1]
while(K>0):
    ll_num[0]+=1
    digit_num = len(ll_num)
    for digit in range(digit_num):
        if ll_num[digit] ==10:
            if digit == digit_num-1:
                ll_num.append(0)
                digit_num +=1
            ll_num[digit+1] +=1
            if ll_num[digit+1] ==10:
                ll_num[digit] = 0
            for i in reversed(range(0,digit+1)):
                ll_num[i] = ll_num[i+1]-1
                if ll_num[i] < 0:
                    ll_num[i] = 0

    for digit in range(digit_num-1):
        if ll_num[digit]>ll_num[digit+1]+1:
            ll_num[digit+1] +=1
            for i in reversed(range(0,digit+1)):
                ll_num[i] = ll_num[i+1]-1
                if ll_num[i] < 0:
                    ll_num[i] = 0
    K -=1
result_str = ""
for num in range(len(ll_num)):
     result_str = str(ll_num[num]) + result_str
print(int(result_str))


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

#define C 100
#define R 100

const int INF = 1<<29;

int main(){
  int j,k,h,n,i,l[R],r[C],m[R][C];

  scanf("%d",&n);
  
  for(i=0;i<n;i++) for(j=0;j<n;j++) m[i][j]=INF;

  for(i=0;i<n;i++){
    scanf("%d%d",&l[i],&r[i]);
    m[i][i]=0;
  }

  for(h=1;h<n;h++){
    for(i=0;i<n-h;i++){
      j=i+h;
      for(k=i;k<j;k++){
	m[i][j]=fmin(m[i][j],m[i][k]+m[k+1][j]+l[i]*r[k]*r[j]);
      }
    }
  }

  printf("%d\n",m[0][n-1]);

  return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N, D, X;
	cin >> N >> D >> X;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int day;
	int cnt = 0;
	rep(i, N) {
		day = 1;
		while (day <= D) {
			cnt++;
			day += A[i];
		}
	}
	cout << X + cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int a[1000000],dp[1000000];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for(int i=1; i<=m; i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(i-a[j]<0)
            {
                break;
            }
            else
            {
                if(dp[i-a[j]]==0)
                {
                    dp[i]=1;
                    break;
                }
            }
        }
    }
    if(dp[m]==1)
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_068
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            var stoppings = new Dictionary<int, bool>();
            var abs = new int[m][];
            for (int i = 0; i < m; i++)
            {
                int[] ab= ReadInts();
                abs[i] = new int[2];
                abs[i][0] = ab[0];
                abs[i][1] = ab[1];
            }
            Array.Sort(abs, (a, b) => a[0] - b[0]);

            for(int i = 0; i < m; i++)
            {
                if (abs[i][0] == 1)
                {
                    stoppings.Add(abs[i][1], true);
                }
                else
                {
                    if (abs[i][1] == n&&stoppings.ContainsKey(abs[i][0]))
                    {
                        Console.WriteLine("POSSIBLE");
                        return;
                    }
                }
            }

            Console.WriteLine("IMPOSSIBLE");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

vector<int> w,v;

int given_dp(int n, int W){
    vector<vector<int>> dp(n+1,vector<int>(W+1));
    for(int i=0;i<=n;++i) dp[i][0] = 0;
    for(int i=0;i<=W;++i) dp[0][i] = 0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=W;++j){
            if(j-w[i-1]<0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
        }
    }
    return dp[n][W];
}

int main(){
    int n,W;
    cin >>n>>W;
    w.assign(n,-1);
    v.assign(n,-1);
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    int ans;
    ans = given_dp(n,W);
    cout << ans << endl;
}


Measured memory_bytes: 6848
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
   int a[100],k;
   int i,j,flag=0;
   scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&k);
   for(i=0;i<5;i++)
   {
       for(j=i+1;j<5;j++)
       {
           if(a[i]-a[j]>k||a[i]-a[j]<-k)
           {
               flag=1;
               //printf("i=%d j=%d",i,j);
               break;
           }

       }
       if(flag==1)break;
   }
   if(flag==0)
    printf("Yay!");
   else
    printf(":(");
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

tree=[[] for i in range(n)]
for i in l:
    tree[i[0]-1].append(i[1]-1)
    tree[i[1]-1].append(i[0]-1)

for i in tree:
    if 0 in i and n-1 in i:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 79544
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(200000);

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    mint ans = c.frac[n];
    n <<= 1;

    rep(i, n) {
        if(s[i] == 'W') {
            cout << 0 << endl;
            return 0;
        }
        if(s[i+1] == 'W') {
            s = s.substr(i);
            n -= i;
            break;
        } else i++;
        if(i == n-1) {
            cout << ans << endl;
            return 0;
        }
    }

    for(int i=n-1; i >= 0; --i) {
        if(s[i] == 'W') {
            cout << 0 << endl;
            return 0;
        }
        if(s[i-1] == 'W') {
            s = s.substr(0, i+1);
            n = i+1;
            break;
        } else i--;
    }

    vi h(n);
    int cou = 0;
    rep(i, n-1) {
        if(s[i] == s[i+1]) {
            h[i+1] = h[i]^1;
        } else {
            h[i+1] = h[i];
        }
        if(h[i+1]) cou++;
    }
    

    if(cou != n/2) {
        cout << 0 << endl;
        return 0;
    }

    cou = 0;
    rep(i, n) {
        if(h[i]) {
            ans *= cou;
            cou--;
        } else cou++;
    }

    cout << ans << endl;
}

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

const int MAXN = 1e5 + 10;
string s;
int n;

bool first_check() {
	if(s[n] == '1' || s[1] == '0') return true;
	for(int i = 1; i <= n/2; i++) {
		if(s[i] != s[n - i]) return true;
	}
	return false;
}

vector<int> adj[MAXN];
void add_edge(int a, int b) {
	adj[a].push_back(b), adj[b].push_back(a);
}
int sub[MAXN];
int dfs(int r, int p) {
	sub[r] = 1;
	for(int c: adj[r]) {
		if(c != p) sub[r] += dfs(c, r);
	}
	return sub[r];
}
string generator() {
	dfs(1, -1);
	string temp(n + 1, '0');
	temp[0] = '$';
	for(int i = 2; i <= n; i++) {
		temp[sub[i]] = '1';
		temp[n - sub[i]] = '1';
	}
	return temp;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s;
	n = s.size();
	s = "$" + s;
	if(first_check()) {
		cout << -1 << endl;
		return 0;
	}
	int curr_root = 2;
	add_edge(1, 2);
	for(int i = 2; i <= n - 1; i++) {
		add_edge(curr_root, i + 1);
		if(s[i] == '1') {
			curr_root = i + 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for(int j: adj[i]) {
			if(j < i) {
				cout << j << ' ' << i << endl;
			}
		}
	}
	// assert(generator() == s);
	return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>

int main(void) {
	int M, D;
	int i, j, kaunto = 0;
	if (scanf("%d%d", &M, &D) != 2) return 1;
	for (i = 1; i <= M; i++) {
		for (j = 10; j <= D && j < 100; j++) {
			int one = j % 10, ten = j / 10;
			if (one >= 2 && ten >= 2 && one * ten == i) kaunto++;
		}
	}
	printf("%d\n", kaunto);
	return 0;
}


Measured memory_bytes: 1696
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n =  sc.nextInt();
	List<String> a = new ArrayList<String>();

	for(int i=0;i<n;i++) {
		a.add(sc.next());
	}

	List<String> b = new ArrayList<String>(new HashSet<>(a));

	int la = a.size();
	int lb = b.size();
	System.out.println(la==lb?"YES":"NO");
  }
}

Measured memory_bytes: 73632
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
D = l()
M = k()
T = l()

d = Counter(D)
t = Counter(T)

for i in t:
    if t[i] > d[i]:
        print("NO")
        sys.exit()

print("YES")


Measured memory_bytes: 59780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll d;
    cin >> d;
    if (d % 9) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    rep(e, 1, 19) {
        ll tmp = 1;
        vector<ll> x(1, 1);
        rep(i, 0, e) x[0] *= 10;
        x[0]--;
        int sz = (e + 1) / 2;
        if (e % 2 == 0) tmp *= 10;
        x.resize(sz);
        ll tp = 10;
        rep(i, 1, sz) {
            x[i] = x[i - 1] / 10;
            x[i] -= x[i] % tp;
            tp *= 10;
        }
        function<ll(ll, ll)> calc = [&](ll a, ll c) {
            if (c == sz) {
                return (ll)(a == 0);
            }
            ll res = 0;
            rep(i, -10, 10) {
                if (x[c] * i <= a && a < x[c] * (i + 1)) {
                    if (i != -10) res += calc(a - x[c] * i, c + 1) * (10LL - abs(i) - (c == 0));
                    if (i != 10) res += calc(a - x[c] * (i + 1), c + 1) * (10LL - abs(i + 1) - (c == 0));
                }
            }
            return res;
        };
        ans += tmp * calc(d, 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;
 

int x;
vector<bool> vec(maxn);
int main(){FAST;
    
    cin >> x;
    vec[1] = 1;
    for(int i = 2 ,a; i <= x; i++){
        a = i * i;
        while(a <= x)
            vec[a] = 1 ,a *= i;
    }
    forn(i ,x ,0)
        if(vec[i])
            return cout << i ,0;


   return 0;
}
 












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

struct set{
  string val;
  double rgb[3];
};

set temp[8];

string name[8] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
void make_temp(){
  for(int i=0;i<8;i++){
    temp[i].val = name[i];
    temp[i].rgb[0] = (i >> 2 & 1 ? 255 : 0);
    temp[i].rgb[1] = (i >> 1 & 1 ? 255 : 0);
    temp[i].rgb[2] = (i & 1 ? 255 : 0);
  }
}

int main(){
  make_temp();

  while(true){
    double num[3];
    double ans = (2 << 10);
    string s,spt[3];
    cin >> s;
    if(s == "0") break;

    s.erase(0,1);
    for(int i=0;i<3;i++){
      for(int j=0;j<2;j++){
	spt[i] += s[0]; s.erase(0,1);
      }

      int a;
      sscanf(spt[i].c_str(),"%x",&a);
      num[i] = a;
    }
    
    string a;
    for(int i=0;i<8;i++){
      double d = sqrt(pow(num[0] - temp[i].rgb[0],2) + pow(num[1] - temp[i].rgb[1],2) + pow(num[2] - temp[i].rgb[2],2));

      if(ans > d){
	a = temp[i].val; ans = d;
      }
    }
    cout << a << endl;
  }

}

Measured memory_bytes: 1268
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const char letters[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
int diff[62];char pw[129],query[129];
int ask(){int x;printf("? %s\n",query);fflush(stdout);return !scanf("%d",&x)?-1:x;}
int main()
{
  int total=0,len=0;
  rep(i,62){rep(j,128){query[j]=letters[i];}query[128]=0;diff[i]=128-ask();total+=diff[i];}
  rep(i,62)
  {
    if(len==0){len=diff[i];rep(j,diff[i])pw[j]=letters[i];}
    else
    {
      for(int k=diff[i],l=0;k>=1;--k)
      {
        int r=len;
        while(l<r)
        {
          int mid=(l+r+1)/2;
          rep(j,mid)query[j]=pw[j];
          rep(j,k)query[mid+j]=letters[i];
          query[mid+k]=0;
          if(ask()==total-mid-k)l=mid;else r=mid-1;
        }
        ++len;rep(j,len-l){pw[len-j]=pw[len-j-1];}
        pw[l]=letters[i];
      }
    }
  }
  pw[len]=0;
  return printf("! %s\n", pw),0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
 
    int main() {
        int64_t A, B, H, M;
        cin >> A >> B >> H >> M;
        double R, L, G, ans, ans2, ans3, ans4;
        R = 30 * H + 0.5 * M;
        L = 6 * M;
        G = R - L;
        ans = abs(G);
        double P = 180.0000000000;
        ans4 = ans / P * 3.14159265358979323846;
        ans2 = A * A + B * B - 2 * A * B * cos(ans4);
        ans3 = sqrt(ans2);
        cout << fixed << setprecision(15) << ans3 << endl;
    }

Measured memory_bytes: 4188
'''
Created on 2020/08/31

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N,M=map(int,pin().split())
  ans=[0]*N
  for _ in [0]*M:
    s,c=map(int,pin().split())
    if s==1 and c==0 and N!=1:
      print(-1)
      return 
    if ans[s-1]!=0 and ans[s-1]!=c:
      print(-1)
      return
    ans[s-1]=c
  if N==3:
    if ans[0]==0:
      if ans[1]==0:
        print(f"{1}{0}{ans[2]}")
      else:
        print(f"{1}{ans[1]}{ans[2]}")
      return
    else:
      print(f"{ans[0]}{ans[1]}{ans[2]}")
      return
  elif N==2:
    if ans[0]==0:
      print(f"{1}{ans[1]}")
    else:
      print(f"{ans[0]}{ans[1]}")
    return
  else:
    print(ans[0])
    return
  return
main()

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

using namespace std;

int ans[1000][1000];

int main(){
        int H, W, N;
        vector <int> a;
        cin>>H>>W>>N;
        for(int i=0;i<N;i++){
                int aa;
                cin>>aa;
                a.push_back(aa);
        }
        int color=0;
        for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                        ans[i][j]=color+1;
                        a[color]--;
                        if(a[color]==0)
                                color++;
                }
        }
        for(int i=0;i<H;i++){
                if(i%2==0){
                        for(int j=0;j<W;j++){
                                if(j>0)
                                        cout<<" ";
                                cout<<ans[i][j];
                        }
                }
                else{
                        for(int j=W-1;j>=0;j--){
                                if(j!=W-1){
                                        cout<<" ";
                                }
                                cout<<ans[i][j];
                        }
                }
                cout<<endl;
        }
        return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

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

int main(void){
    int n,k;
    cin>>n>>k;
    vector<ll>a(n);
    rep(i,n){
        cin>>a[i];
    }
    for(int i=k;i<n;++i){
        if(a[i-k]<a[i]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}
/*
*/

Measured memory_bytes: 4800
#!/usr/bin/env python
# coding: utf-8

# In[2]:


N = int(input())


# In[12]:


def lucas(n):
    mylist = [2,1]
    for i in range(2,n+1):
        mylist.append(mylist[i-1]+mylist[i-2])
    return mylist[n]


# In[14]:


print(lucas(N))


# In[ ]:






Measured memory_bytes: 2940
<?php
    $answer = array(
        0 => 'No',
        1 => 'Yes',
    );
    fscanf(STDIN, '%d %d %d %d %d', $w, $h, $x, $y, $r);
    $isInclude = ($w >= ($x + $r) && ($y + $r) <= $h && min($x, $y) > 0);
    echo $answer[$isInclude], PHP_EOL;

Measured memory_bytes: 6556
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
    ///BISMILLAHIR RAHMANIR RAHIM
#define MAXN 1000000
bool prime[MAXN];
vector<int>v;

int main()
{

   //int t;
  // cin >> t;
   //int ex = 1;
   //while(t --)
   //{
       ll n;
       cin >> n;
       ll res = 0;
       for(int i=1;i<=n-1;i++){
            res += (n-1)/i;
       }
       cout<<res<<endl;

   //}
}


Measured memory_bytes: 3628
#include<stdio.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void){
	int n;
	scanf("%d", &n);
	if(n%2 != 0){
		printf("%d\n", (n+1)/2);
	}else{
		printf("%d", n/2);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>

int main()
{
    using namespace std;

    int H, W;

    while (1)
    {
        cin >> H >> W;

        if (H == 0 && W == 0)
        {
            return 0;
        }

        string odd_elem = "#.";
        string eve_elem = ".#";

        if (W % 2 == 0)
        {
            for (int i = 0; i < H; i++)
            {
                if (i % 2 == 0)
                {
                    for (int i = 0; i < W / 2; i++)
                    {
                        cout << odd_elem;
                    }
                    cout << endl;
                }
                else
                {
                    for (int i = 0; i < W / 2; i++)
                    {
                        cout << eve_elem;
                    }
                    cout << endl;
                }
            }
        }
        else
        {
            for (int i = 0; i < H; i++)
            {
                if (i % 2 == 0)
                {
                    for (int i = 0; i < W / 2; i++)
                    {
                        cout << odd_elem;
                    }
                    cout << odd_elem[0] << endl;
                }
                else
                {
                    for (int i = 0; i < W / 2; i++)
                    {
                        cout << eve_elem;
                    }
                    cout << eve_elem[0] << endl;
                }
            }
        }

        cout << endl;
    }
}


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

int main() {
    std::string s;
    std::cin >> s;
    
    int A[s.size()] = {0}; 

    bool RFlag = true;
    int rcnt = 0, lcnt = 0, pos = 0;
    for (std::size_t i = 0; i < s.size(); ++i) {
        char c = s[i];

        if (RFlag) {
            if (c == 'R') {
                ++rcnt;
            } else {
                pos = i - 1;
                ++lcnt;
                RFlag = false;
            }
        } else {
            if (c == 'L') {
                ++lcnt;
            } else {
                A[pos] = (int)(std::ceil(rcnt / 2.0)) + (int)(lcnt / 2);
                A[pos+1] = (int)(rcnt / 2) + (int)(std::ceil(lcnt / 2.0)); 

                rcnt = 1;
                lcnt = 0;
                RFlag = true;
            }
        }
    }      

    A[pos]   = (int)(std::ceil(rcnt / 2.0)) + (int)(lcnt / 2);
    A[pos+1] = (int)(rcnt / 2) + (int)(std::ceil(lcnt / 2.0)); 
 
    for (std::size_t i = 0; i < s.size(); ++i) {
        std::printf("%d ", A[i]);
    }
    putchar('\n');

    return 0;
}


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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);

#define endl "\n";


#define mod 1000000007
#define loop(i,s,n)  for(ll i=s;i<n;i++)
#define test  ll t; cin>>t; while(t--)
#define p push_back
typedef long long ll;
int main()
{IOS

ll  n,i,j,k,count=0,f=0,sum=0,a,b,c;
cin>>a>>b>>c;

count=abs(a/c);

if(count<=b)
{if(a>=0)
    {a=a-((count)*c);}
    else{a=a+((count)*c);}

    b=b-(count);
    if(b>=1)
    {
        if(b%2!=0)
        {if(a>=0)
        {
            a=a-c;
        }
        else{a=a+c;}

        }


    }}
    else{if(a>=0){a=a-(b*c);}
    else{a=a+(b*c);}}
 cout<<abs(a);










return 0;
}


Measured memory_bytes: 3572
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    double sum = 0;
    for(int i=0; i<n; i++){
        double a; cin>>a;
        sum += 1 / a;
    }

    printf("%.10f\n", 1 / sum);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
using namespace std;



int main(){
	
int n;
while(1){
	cin>>n;
	if(!n)break;
	int p[50]={};;
	for(int i=0;i<n;i++){
		string y;
		cin>>y;
		p[i]=y.size();
	}
	
	for(int i=0;i<n;i++){
		bool a=0,b=0,c=0,d=0,e=0;
		int r=0;
		for(int j=i;j<n;j++){
			r+=p[j];
			if(!a&&r==5)a++;
			if(!a&&r>5)break;
			if(r==12)b++;
			if(!b&&r>12)break;
			if(r==17)c++;
			if(!c&&r>17)break;
			if(r==24)d++;
			if(!d&&r>24)break;
			if(r==31)e++;
			if(!e&&r>31)break;
			if(a&&b&&c&&d&&e){
				cout<<i+1<<endl;
				break;
			}
		}
		if(a&&b&&c&&d&&e){
				
				break;
			}
	}

}

	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; p++) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll n; cin >> n;
    vector<pair<ll, ll> > p = prime_factorize(n);
    ll ans = 0;
    for (auto x : p) {
        ll v = x.second;
        ll cnt = 1;
        bool flag = true;
        while (flag) {
            if (v - cnt >= 0) {
                ans++;
                v = v - cnt;
                cnt++;
            } else {
                flag = false;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3200
from itertools import accumulate
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10**9+7

    accm = list(accumulate(A))

    ans = 0
    for i in range(N-1,0,-1):
        ans += A[i] * accm[i-1] % MOD
        ans %= MOD

    print(ans%MOD)
        

if __name__ == '__main__':
    solve()


Measured memory_bytes: 107196
from collections import deque

n, m = map(int, input().split())

# dist = [-1 for i in range(n)]
prenodes = [-1 for i in range(n)]

G = [[] for i in range(n)]
ab = []
for i in range(m):
    ab.append(list(map(int, input().split())))

for i in range(m):
    G[ab[i][0]-1].append(ab[i][1]-1)
    G[ab[i][1]-1].append(ab[i][0]-1)
# print(G)

# dist[0] = 0
prenodes[0] = 0
que = deque([0])

while len(que) != 0:
    v = que.popleft()

    for vi in G[v]:
        if prenodes[vi] != -1:
            continue
        que.append(vi)
        # dist[vi] = dist[v] + 1
        prenodes[vi] = v

ans = "Yes"
for i in range(n):
    if prenodes[i] == -1:
        ans = "No"
        break

if ans == "No":
    print(ans)
else:
    print(ans)
    for i in range(1, n):
        print(prenodes[i]+1)


Measured memory_bytes: 70200