akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
  int i,j,N;
  int d[100];	// おいしさ
  int ddsum;	// おいしさのサム値
  // 数を取得
  scanf("%d",&N);
  
  // おいしさ配列を取得
  for(i=0;i<N;i++)
  {
    scanf("%d", &d[i]);
  }
  
  // おいしさ配列を掛け算していく。
  for(i=0;i<N-1;i++)
  {
    for(j=i+1;j<N;j++)
    {
      ddsum += d[i]*d[j];
    }
  }

  printf("%d",ddsum);
 
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;
int main(){
    int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
    long long p[100001] = {1000000000};
    long long q[100001] = {1000000000};
    long long r[100001] = {1000000000};
    long long ans = 0;

    for(int i = 1; i <= a; i++)cin >> p[i];
    for(int i = 1; i <= b; i++)cin >> q[i];
    for(int i = 1; i <= c; i++)cin >> r[i];

    sort(p+1, p+a+1, greater<long long>());
    sort(q+1, q+b+1, greater<long long>());
    sort(r+1, r+c+1, greater<long long>());

    int p_tail = x, q_tail = y;
    for(int r_head = 1; r_head <= min(x + y, c); r_head++){
        if(p[p_tail] >= q[q_tail]){
            if(r[r_head] >= q[q_tail]){
                q[q_tail] = r[r_head];
//                cout << q_tail << "+" << r_head << endl;
                q_tail--;
            }
        }else{
            if(r[r_head] >= p[p_tail]){
                p[p_tail] = r[r_head];
//                cout << p_tail << "*" << r_head << endl;
                p_tail--;
            }
        }
    }

//    for(int i = 0; i <= a; i++)cout << p[i] << "/";
//    for(int i = 0; i <= b; i++)cout << q[i] << "/";

    for(int i = 1; i <= x; i++)ans += p[i];
    for(int i = 1; i <= y; i++)ans += q[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		double d = sc.nextDouble();
		double x = Math.PI;
		out.println(d * 2 * x);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

bool ok(string s){
	if(sz(s)&1)return false;
	string t="",g="";
	for(int i=0;i<sz(s)/2;i++){
		t+=s[i];
	}
	for(int i=sz(s)/2;i<sz(s);i++){
		g+=s[i];
	}
	return t==g;
}
int ans;

int main(){
	string s;
	cin>>s;
	string t="";
	for(int i=0;i<sz(s)-1;i++){
		t+=s[i];
		if(ok(t)){
			ans=sz(t);
		}
	}
	cout<<ans;
}





Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    if(a==1&&b==2||a==2&&b==1)
    {
        printf("3\n");
    }
    else if(a==2&&b==3||a==3&&b==2)
    {
        printf("1\n");
    }
    else if(a==1&&b==3||a==3&&b==1)
    {
        printf("2\n");
    }
    return 0;

}


Measured memory_bytes: 128
N=int(input())
DD=[]
for i in range(N):
    DD.append(list(map(int,input().split())))
for i in range(N-2):
    if DD[i][0]==DD[i][1]:
        if DD[i+1][0]==DD[i+1][1]:
            if DD[i+2][0]==DD[i+2][1]:
                print("Yes")
                break
            elif i+2==N-1:
                print("No")
                break
        elif i+1==N-2:
            print("No")
            break
    elif i==N-3:
        print("No")
        break

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

template <typename T> bool next_combination(T first, T last, int k){
    T subset = first + k;
    if (first==last || first==subset || last==subset){
        return false;
    }
    T src = subset;
    while(first != src){
        src--;
        if(*src < *(last-1)){
            T dest = subset;
            while(*src >= *dest){
                dest++;
            }
            iter_swap(src, dest);
            rotate(src+1, dest+1, last);
            rotate(subset, subset+(last-dest)-1, last);
            return true;
        }
    }
    rotate(first, subset, last);
    return false;
}

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

    vector<vector<int>> D(C, vector<int>(C));
    REP(i,C){
        REP(j,C){
            cin >> D[i][j];
        }
    }

    vector<vector<int>> G(C, vector<int>(3, 0));
    REP(i,N){
        REP(j,N){
            int c; cin >> c;
            G[c-1][(i+j+2)%3]++;
        }
    }


    vector<int> P(C);
    REP(i,C) P[i] = i;

    ll ans = INF;

    do{
        vector<int> cs = {P[0], P[1], P[2]};
        do{
            ll sum = 0;
            REP(i,C){
                REP(j,3){
                    sum += D[i][cs[j]] * G[i][j];
                }
            }
            ans = min(ans, sum);


        }while (next_permutation(ALL(cs)));

    }while (next_combination(ALL(P), 3));

    cout << ans << endl;

    return 0;
}

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

#define int long long
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; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
   int a,b,c,k; cin>>a>>b>>c>>k;
   if(a+b>=k){
       cout<<min(a,k)<<endl;
       return 0;
   }
   if(a+b<k){
       cout<<a-(k-a-b)<<endl;
       return 0;
   }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,mp[110]={0},sum1=0,sum2=0;
    cin>>a>>b>>c;
    for(int i=0;i<b;i++)
    {
        cin>>d;
        mp[d]++;
    }
    for(int i=0;i<=c;i++)
    {
        if(mp[i]!=0)
            sum1++;
    }
    for(int i=c;i<=a;i++)
    {
        if(mp[i]!=0)
            sum2++;
    }
    if(sum1>=sum2)printf("%d",sum2);
    else printf("%d",sum1);
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;

int A[20];
int n,m,q;
vector<pair<pii,pii> > Q;
ll Ans = 0;

void Check()
{
    ll Res = 0;
    for(int i=0;i<q;i++)
    {
        int a = Q[i].fr.fr;
        int b = Q[i].fr.sc;
        int c = Q[i].sc.fr;
        int d = Q[i].sc.sc;

        if(A[b]-A[a] == c)
        {
            Res += d;
        }

    }

    Ans = max(Ans,Res);

}

void Solve(int i=0,int Lst=1)
{
    if(i == n)
    {
        Check();
        R;
    }
    for(int j=Lst;j<=m;j++)
    {
        A[i] = j;
        Solve(i+1,j);
    }
}

int main()
{

    SPEED;
    cin >> n >> m >> q;
    int a,b,c,d;
    for(int i=0;i<q;i++)
    {
        cin >> a >> b >> c >> d;
        a--;
        b--;
        Q.pb(mp(mp(a,b),mp(c,d)));
    }

    Solve();

    cout << Ans << endl;

    R 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N, X, M;
    cin >> N >> X >> M;
    vector<int> seen(M, -1);
    long long ans = 0;
    for (long long i = 0, cur = X; i < N; ++i) {
        if (seen[cur] == -1) {
            seen[cur] = i;
        } else {
            // cycle found
            long long cycle = (i - seen[cur]); // seen[cur] ~ i - 1;
            vector<long long> sum(cycle + 1, 0);
            for (long long i = 1, n = cur; i == 1 || n != cur; ++i, n = (n * n) % M) {
                sum[i] = sum[i - 1] + n;
            }
            long long L = N - i; // i ~ N - 1
            ans += sum[cycle] * (L / cycle) + sum[L % cycle];
            cout << ans << '\n';
            return 0;
        }
        ans += cur;
        cur = (cur * cur) % M;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int n;
typedef long long ll;
struct road{
	ll a,b;
	ll sum()const{
		return a-min(a-b,0ll);
	}
	ll _pref()const{
		return min(a-b,0ll);
	}
	bool operator < (const road B)const{
		return a-min(a-b,0ll) < B.a-min(B.a-B.b,0ll);
	}
}s[N];
ll pref[N];
ll basic;

inline ll cal(int x,int y){
	ll ret =0;
	if(y>=x)++y, ret-=s[x].sum();
	ret += pref[y];
	return ret;
}

struct Numb{
	ll integer;
	ll d1,d2;
	bool operator < (const Numb b){
		return integer==b.integer?(long double)d1*b.d2 < (long double)b.d1*d2:integer<b.integer;
	}
};

void print(Numb x){
	ll d1=x.d1+x.d2*x.integer;
	ll d2=x.d2*n;
	ll g=__gcd(d1,d2);
	printf("%lld %lld\n",d1/g,d2/g);
}

int main()
{
	// freopen("1.in","r",stdin);
	cin >> n;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&s[i].a,&s[i].b);
		basic += s[i]._pref();
		// if(s[i]._pref()<0)cout << s[i].a << " " << s[i].b << endl;
	}
	basic = -basic;
	sort(s+1,s+n+1);
	Numb res = (Numb){0,0,1};
	for(int i=1;i<=n;i++)pref[i] = pref[i-1] + s[i].sum();
	for(int i=1;i<=n;i++){
		// cout << s[i].a << " " << s[i].b << ">>>>" << endl;
		int l=0,r=n-1;
		while(l<r){
			int mid = (l+r+1)>>1;
			if(cal(i,mid)<=basic - max(0ll,s[i].a-s[i].b))l=mid;
			else r=mid-1;
		}
		ll _d = basic - cal(i,l)-max(0ll,s[i].a-s[i].b);
		// cout << basic << " " << l << ":" << cal(i,l) << " " << s[i].a << " " << s[i].b << endl;
		Numb cur = (Numb){l,_d,s[i].b};
		// print(cur);
		if(res < cur){
			res=cur;
			// cout << basic << " " << cal(i,l) << endl;
			// for(int j=1;j<=n;j++)cout << s[j].a << "," << s[j].b << " ";puts("");
			// cout << s[i].a << " " << s[i].b << " " << l << endl;
		}
	}
	print(res);
}
/* 
4
6 2
4 5
2 7
3 7
 */

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

using namespace std;
typedef long long ll;

char x[200001];
stack<char> s;


int main(void) {
    cin >> x;
    for(int i=0; x[i]!='\0'; i++) {
        if(x[i] == 'S' || s.empty() || s.top() == 'T') s.push(x[i]);
        else s.pop();
    }

    return !printf("%d\n", s.size());
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
    ll m=100000;
    ll s=0;
    int x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<10*m;
        return 0;
    }
    if(x==1)s+=3*m;
    if(x==2)s+=2*m;
    if(x==3)s+=m;
    if(y==1)s+=3*m;
    if(y==2)s+=2*m;
    if(y==3)s+=m;
    cout<<s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <queue>
#define ll long long
using namespace std;
int n,m,x;
const int maxn=1e5+5;
int b[maxn];

int main()
{
    priority_queue <int> q;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        q.push(x);
    }
    while(m--)
    {
        int x=q.top();
        q.pop();
        x=x/2;
        q.push(x);
    }
    ll ans=0;
    while(!q.empty())
    {
        ans+=q.top();
        q.pop();
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <climits>
#define scanf scanf_s
#define mk make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 998244353, N = 100010;

ll min2(ll v1, ll v2) { if (v1 == -1)return v2; if (v2 == -1)return v1; return min(v1, v2); }
ll pw(ll v1, ll v2, ll mod = 1000000007) {
	ll v3 = 1;
	for (; v2 != 0; v1 = (v1 * v1) % mod, v2 = (v2 >> 1))
		if (v2 & 1)v3 = (v3 * v1) % mod;
	return v3;
}

ll n,ans;

int main() {
	cin >> n;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue; ll i2 = n / i;
		if (i2 - i >= 2)ans += i2 - 1;
	}
	cout << ans << endl;
	return 0;
}



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

int main (void){
  int a[110];
  int n;
  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n;i++){
    if(a[i] % 2 == 0){
      if(a[i] % 3 != 0 && a[i] % 5 != 0){
        cout << "DENIED\n";
        return 0;
      }
    }
  }
  cout << "APPROVED\n";
  return 0;

}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    int sum = 700;
    if(s[0]=='o'){ sum+=100; }
    if(s[1]=='o'){ sum+=100; }
    if(s[2]=='o'){ sum+=100; }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, M = map(int, input().split())
AB = [[] for _ in range(M+1)]
for _ in range(N):
  a, b = map(int, input().split())
  if a <= M:
    AB[a].append(b) # 消化日数に対しての価値
  
#heapq.heapify(a)  # listを優先度付きキューに

q = []
ans = 0
for B in AB:
  for b in B: # 日数：価値
    heappush(q, -b) # 最大値のため、マイナスをかける
  if q:
    ans -= heappop(q) # マイナスの値を戻す
print(ans)    
    


Measured memory_bytes: 18376
fun main(args: Array<String>) {
    val (H, W, A, B) = readLine()!!.split(" ").map {s -> s.toInt()}

    val res = Array<Array<Int>>(H) { i -> Array(W) { j -> when {
            j < A && i < B -> 0
            j >= A && i < B -> 1
            j < A -> 1
            else -> 0
        }
    } }

    for (r in res) {
        println(r.joinToString(""))
    }
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0; i<N; i++) cin >> l.at(i);
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans=0;
  for(int i=0; i<K; i++){
    ans+=l.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

H, K, = map(int, input().split())
# N = int(input())
L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

ans = 0
for v in L:
    if v >= K:
        ans += 1

print(ans)

Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
 int n,x;
 cin>>n>>x;
 int sum=0;
 vector<int> m(n);
 for(int i=0;i<n;i++){
     cin>>m.at(i);
     sum+=m.at(i);
 }
 x-=sum;
 sort(m.begin(),m.end());
 cout<<n+x/m.at(0)<<endl;
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

const long long MOD = 1000000007;

using LL = long long;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVLL = vector<VLL>;

template <typename T>
void add(T &a, T b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
}

int main()
{
  IOS;

  int N;
  cin >> N;
  string s;
  cin >> s;

  VVLL dp(N, VLL(N));
  for (int i = 0; i < N; i++)
    dp[0][i] = 1;

  for (int i = 1; i < N; i++)
  {
    if (s[i - 1] == '<')
    {
      for (int j = 0; j < N - i; j++)
      {
        dp[i][j] = dp[i - 1][j];
        if (j > 0)
          add(dp[i][j], dp[i][j - 1]);
      }
    }
    else
    {
      for (int j = N - i - 1; j >= 0; j--)
      {
        dp[i][j] = dp[i][j + 1];
        add(dp[i][j], dp[i - 1][j + 1]);
      }
    }
  }

  cout << dp[N - 1][0] << endl;

  return 0;
}


Measured memory_bytes: 73660
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, q = map(int, input().split())
d = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)
d2 = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    d2[p-1] += x

ans = [0] * n

from collections import deque

def dfs(cur, pre, point):
    stack = deque([[cur, pre, point]])
    while stack:
        cur, pre, point = stack.pop()
        point += d2[cur]
        ans[cur] = point
        for e in d[cur]:
            if e != pre:
                stack.append([e, cur, point])

dfs(0, -1, 0)
print(" ".join(map(str, ans)))


Measured memory_bytes: 128376
#include <stdio.h>

int main()
{
    int a;
    int b;
    int answer=0;
    scanf("%d %d",&a,&b);
    if(a==b) {
        answer = a*2;
    }
    else if (a > b -1) {
        answer = a+(a-1);
    }
    else {
        answer = b+(b-1);
    }
    printf("%d\n",answer);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    vi a(n);
    int count = 0;
    rep(i, n){
        cin >> a.at(i);
        rep(j, d){
            if(j*a.at(i)+1<=d)
            count++;
        }
    }
    cout << count+x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/maxflow>
using namespace atcoder;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m; cin >> n >> m;
  mf_graph<int> mf_G(n * m + 2);
  vector<string> a(n);
  vector<vector<char>> ans(n, vector<char>(m, '.'));
  rep (i, n) cin >> a[i];

  rep (i, n) {
    rep (j, m) {
      if (a[i][j] == '#') {
        ans[i][j] = '#';
        continue;
      }
      if ((i+j) % 2 == 0) {
        mf_G.add_edge(n*m, i*m+j, 1);
        vector<pair<int, int>> D = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
        for (auto [di, dj] : D) {
          if (i+di < 0 || i+di >= n) continue;
          if (j+dj < 0 || j+dj >= m) continue;
          if (a[i+di][j+dj] == '#') continue;
          mf_G.add_edge(i*m+j, (i+di)*m+(j+dj), 1);
        }
      } else {
        mf_G.add_edge(i*m+j, n*m+1, 1);
      }
    }
  }

  cout << mf_G.flow(n*m, n*m+1) << '\n';
  for (auto edge : mf_G.edges()) {
    if (edge.from == n*m || edge.to == n*m+1) continue;
    if (edge.flow == 1) {
      pair<int, int> from = {edge.from/m, edge.from%m};
      pair<int, int> to = {edge.to/m, edge.to%m};
      pair<int, int> diff = {from.first-to.first, from.second-to.second};
      char from_c, to_c;
      if (diff == make_pair(1, 0)) {
        to_c = 'v';
        from_c = '^';
      } else if (diff == make_pair(-1, 0)) {
        to_c = '^';
        from_c = 'v';
      } else if (diff == make_pair(0, 1)) {
        to_c = '>';
        from_c = '<';
      } else if (diff == make_pair(0, -1)) {
        to_c = '<';
        from_c = '>';
      }
      ans[from.first][from.second] = from_c;
      ans[to.first][to.second] = to_c;
    }
  }

  rep (i, n) {
    rep (j, m) {
      cout << ans[i][j];
    }
    cout << '\n';
  }
  
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
        if (A[i] > i
            || (i > 0 && A[i] > A[i - 1] + 1)) {
            cout << "-1\n";
            return 0;
        }
    }

    long long cost = 0;

    int at = n - 1;
    for (;at >= 0;) {
        int prev = at - 1;
        while (prev >= 0 && A[prev] + 1 == A[prev + 1]) {
            prev--;
        }
        prev++;

        // From [prev to at], we have a triangle.
        assert (prev == 0 || A[prev - 1] >= A[prev]);

        cost += (at - prev);

        // Adaugam costul de a il forma pe primul.
        cost += A[prev];

        at = prev - 1;
    }

    cout << cost << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define FREE 100
#define NOT_FREE 200
#define N 8

int col[20],row[20],dpos[20],dneg[20];
int ans[20];

void printBoard(){
	for(int i = 0;i < 8;i++){
		for(int j = 0;j < 8;j++){
			if(row[i] == j){
				cout << "Q";
			}
			else{
				cout << ".";
			}
		}
		cout << endl;
	}
}

void putQueen(int i){
	//cout << i << endl;
	if(i == 8){
		printBoard();
		return;
	}

	if(ans[i] == FREE){
		for(int j = 0;j < N;j++){
			if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
				continue;
			}
			row[i] = j;
			col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
			putQueen(i+1);
			col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
		}
	}
	else{
		int j = ans[i];
		if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
		}
		else{
			row[i] = j;
			col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
			putQueen(i+1);
			col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
		}
	}
}

int main(){
	for(int i = 0;i < 20;i++){
		col[i] = dpos[i] = dneg[i] = ans[i] = FREE;
	}

	int k,r,c;
	cin >> k;
	for(int i = 0;i < k;i++){
		cin >> r >> c;
		ans[r] = c;
		//col[c] = dpos[r+c] = dneg[r-c+N-1] = NOT_FREE;
	}

	putQueen(0);

	return 0;
}


Measured memory_bytes: 3112
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <stack>
#define SIZE 1000005
#define MOD 1000000007

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

ll inv[SIZE],fac[SIZE],finv[SIZE];
ll rt[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
	rt[0]=1;
	for(int i=1;i<SIZE;i++) rt[i]=rt[i-1]*3LL%MOD;
}
ll C(int a,int b)
{
	if(b==0) return 1;
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	n++,m++,k++;
	ll ret=0;
	ll l=0,r=0;
	for(int L=0;L<=m+k-2;L++)
	{
		ll now=C(L+n-2,n-2)*rt[m+k-L-2]%MOD;
		if(L-k>0)
		{
			l*=2LL;
			l%=MOD;
			l+=C(L-1,k-1);
			if(l>=MOD) l-=MOD;
		}
		else if(L-k==0) l=1;
		if(L==0) r=1;
		else
		{
			r*=2LL;
			r%=MOD;
			if(L>m-1)
			{
				r-=C(L-1,m-1);
				if(r<0) r+=MOD;
			}
		}
		//printf("%d [%d %d] : %lld %lld\n",L,max(0,L-k+1),min(L,m-1),l,r);
		ret+=now*(r-l+MOD)%MOD;
		ret%=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


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

namespace ABC103D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ints = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

            int N = ints[0];
            int M = ints[1];
            int[][] A = new int[M][];

            for (int i = 0; i < M; i++)
            {
                A[i] = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();
            }

            Array.Sort(A, (a, b) => a[1] - b[1]);
            int count = 0;
            int index = 0;
            for (int i = 0; i < M; i++)
            {
                if (index <= A[i][0])
                {
                    index = A[i][1];
                    count++;
                }
            }
            Console.Write(count);
        }
    }
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, D[2];
int col[2][610][610];
vector<pii> vec[2];
vector<pii> g[2][610][610];
int cnt[4];

int main() {
	cin >> N >> D[0] >> D[1];

	rep(t, 2) {
		for (int i = -N*2; i <= N*2; ++i) {
			for (int j = -N*2; j <= N*2; ++j) {
				if (i * i + j * j == D[t]) {
					vec[t].eb(i, j);
				}
			}
		}
		memset(col[t], -1, sizeof(col[t]));
		queue<pii> que;

		rep(i, N * 2) {
			rep(j, N * 2) {
				if (col[t][i][j] != -1) continue;
				col[t][i][j] = 0;
				que.push(mp(i, j));

				while (!que.empty()) {
					pii p = que.front(); que.pop();
					int k = p.fi, l = p.se;
					for (auto v : vec[t]) {
						if (v.fi + k >= 0 && v.fi + k < N * 2 && v.se + l >= 0 && v.se + l < N * 2 && col[t][v.fi + k][v.se + l] == -1) {
							col[t][v.fi + k][v.se + l] = col[t][k][l] ^ 1;
							que.push(mp(v.fi + k, v.se + l));
						}
					}					
				}
			}
		}
	}

	rep(i, N*2) {
		rep(j, N*2) {
			++cnt[col[0][i][j] * 2 + col[1][i][j]];
		}
	}

	int p = -1;
	rep(i, 4) {
		if (cnt[i] >= N * N) {
			p = i;
		}
	}

	int zan = N * N;

	rep(i, N * 2) {
		rep(j, N * 2) {
			if (col[0][i][j] * 2 + col[1][i][j] == p) {
				if (zan) {
					printf("%d %d\n", i, j);
					--zan;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 21504
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:usize,
    }
    println!("{}",if (a*b)%2==0 {"No" }else{"Yes"})
}

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

int main(){
    int n, x, t;
    cin >> n >> x >> t;
    if(n <= x) cout << t << endl;
    else if(n%x == 0) cout << t*n/x << endl;
    else cout << t*(n/x+1) << endl;
}


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

int main() {
    int n; cin >> n;
    vector<string> s(3);
    for(int i = 0; i < 3; ++i) cin >> s[i];
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        set<char> t;
        for(int j = 0; j < 3; ++j) {
            t.insert(s[j][i]);
        }
        if(t.size() == 2u) ans += 1;
        else if(t.size() == 3u) ans += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;

long long ans = 0;

void subBin(string mofu, int dig, long long n)
{
    if (dig == 0){
        if (stoi(mofu.c_str()) <= n and mofu.find("3") != string::npos and mofu.find("5") != string::npos and mofu.find("7") != string::npos){
            ans += 1;
        }
    }
    if (dig > 0) {
        subBin(mofu + "3", dig - 1, n);
        subBin(mofu + "5", dig - 1, n);
        subBin(mofu + "7", dig - 1, n);
    }
}

int main() {
    
    long long n;
    cin >> n;
   int dig = 0;
    long long p = n;
    vector <int> v;
    while(p > 0){
        dig += 1;
        v.push_back(p%10);
        p /= 10;
    }
    reverse(v.begin(),v.end());
    for (int i=1;i<=dig;i++) {
        string mofu = "";
        subBin(mofu, i, n);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
[A,B] = list(map(int,input().split()))
C1 = A*(100/8)
C2 = (A+1)*(100/8)
D1 = B*(100/10)
D2 = (B+1)*(100/10)
flag = 0
for n in range(int(C1//1), int(C2//1)+1):
    if (C1<=n<C2) and (D1<=n<D2):
        print(n)
        flag = 1
        break
if flag==0:
    print(-1)


Measured memory_bytes: 38672
a, b, c, d = [int(i) for i in input().split()]

alice = [0] * 101
bob = [0] * 101

for i in range(a,b):
    alice[i] = 1
    
for i in range(c, d):
    bob[i] = 1

cnt = 0
for i in range(max(b,d)):
    if alice[i] == 1 and bob[i] == 1:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
  
const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e18; 
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, a[N], b[N], c[N];
int main (){
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    for (int i = 1; i <= n; ++i) scanf ("%d", b + i);
    for (int i = 1; i < n; ++i) scanf ("%d", c + i);
    ll ans = 0, last = -1;
    for (int i = 1; i <= n; ++i){
        ans += b[a[i]];
        if (a[i] == last + 1){
            ans += c[last];
        }
        last = a[i];
    } 
    return !printf ("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define _USE_MATH_DEFINES

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

int main() {

	int n, cnt = 0;
	ll ans = 1;
	int a[100];
	string s1, s2;
	cin >> n >> s1 >> s2;

	for (int i = 0; i < s1.length(); i++) {
		if (s1[i] == s1[i + 1]) {
			a[cnt] = 2;
			cnt++;
			i++;
		}
		else {
			a[cnt] = 1;
			cnt++;
		}
	}

	if (a[0] == 1)ans *= 3;
	else ans *= 6;

	for (int i = 1; i < cnt; i++) {
		if (a[i - 1] == 1 && a[i] == 1) {
			ans *= 2;
			ans %= atcoder;
		}
		else if (a[i - 1] == 1 && a[i] == 2) {
			ans *= 2;
			ans %= atcoder;
		}
		else if (a[i - 1] == 2 && a[i] == 1) {
			ans *= 1;
		}
		else {
			ans *= 3;
			ans %= atcoder;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter, defaultdict, deque


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, XY1XY2, C):
    q = deque()
    s = (XY1XY2[0]-1)*W + XY1XY2[1]-1
    go = (XY1XY2[2]-1)*W + XY1XY2[3]-1
    q.append(s)
    d = {s: 0}

    while q:
        u = q.popleft()
        i = u // W
        j = u % W
        e = list()
        for k in range(1, K+1):
            if i - k >= 0 and C[i-k][j] != '@':
                n = (i-k)*W + j
                if n not in d:
                    e.append(n)
                elif d[u] +1 > d[n]:
                    break
            else:
                break
        for k in range(1, K+1):
            if i + k < H and C[i+k][j] != '@':
                n = (i+k)*W + j
                if n not in d:
                    e.append(n)
                elif d[u] + 1 > d[n]:
                    break
            else:
                break
        for k in range(1, K+1):
            if j - k >= 0 and C[i][j-k] != '@':
                n = i*W + j-k
                if n not in d:
                    e.append(n)
                elif d[u] + 1 > d[n]:
                    break
            else:
                break
        for k in range(1, K+1):
            if j + k < W and C[i][j+k] != '@':
                n = i*W + j+k
                if n not in d:
                    e.append(n)
                elif d[u] + 1 > d[n]:
                    break
            else:
                break
        for v in e:
            q.append(v)
            d[v] = d[u] + 1
            if v == go:
                return d[v]

    return -1


def main():
    H, W, K = read_int_n()
    XY1XY2 = read_int_n()

    C = [read_str() for _ in range(H)]
    print(slv(H, W, K, XY1XY2, C))

    # H = 1000
    # W = 1000
    # K = 1000
    # XY1XY2 = [1, 1, H, W]
    # C = [['.'] * W for _ in range(H)]
    # for i in range(1, H, 2):
    #     if ((i + 1) // 2) % 2 == 1:
    #         for j in range(W-1):
    #             C[i][j] = '@'
    #     else:
    #         for j in range(1, W):
    #             C[i][j] = '@'

    # # for r in C:
    # #     print(r)
    # print(slv(H, W, K, XY1XY2, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 166580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    
    if(N%2==0){
        cout << (N*N-2*N)/2 << endl;
        int a = 1;
        int b = N;
        for (int i = 1; i <= N; i++) {
            a = i;
            b = N-i+1;
            for (int j = i; j <= N; j++) {
                if(a != j && b != j) cout << i << " " << j << endl;
            }
            
        }
    }else{
        cout << ((N+1)*(N+1)-2*(N+1))/2-(N-1) << endl;
        
        int a = 0;
        int b = N;
        for (int i = 0; i <= N; i++) {
            a = i;
            b = N-i;
            for (int j = i; j <= N; j++) {
                if(a != j && b != j && i != 0) cout << i << " " << j << endl;
            }
            
        }
    }
    
    return 0;
}



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

int main(){
    int h1,m1,h2,m2;
    cin >> h1;
    cin >> m1;
    cin >> h2;
    cin >> m2;
    ll k; cin >>k;
    ll ans=60*(h2-h1)+(m2-m1);
    ans-=k;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int N,X[1<<17];
long ans=1,mod=1e9+7;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>X[i];
	}
	X[0]=1;
	int t=0;
	for(int i=1;i<N;i++)
	{
		if(X[i-1]+2<=X[i])X[i]=X[i-1]+2;
		ans=ans*(i+1-(t+1)/2)%mod;
		if(X[i-1]+1==X[i])t++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
int ans,max=0,i,j,n,m,a[1010],b[1010],x;
scanf("%d %d\n",&n,&m);
for(i=0;i<1005;i++){
b[i]=0;
}
for(i=1;i<=n;i++){
scanf("%d\n",&a[i]);
}
for(i=0;i<m;i++){
scanf("%d\n",&x);
for(j=1;j<=n;j++){
if(a[j]<=x){
b[j]++;
break;
}
}
}
for(i=0;i<1005;i++){
if(max<b[i]){
max=b[i];
ans=i;
}
}
printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2036
import heapq

n, m = map(int, input().split())
a = []

for i in input().split():
    heapq.heappush(a, -int(i))

for j in range(m):
    highest = heapq.heappop(a)
    heapq.heappush(a, -(-highest // 2))

print(-sum(a))

Measured memory_bytes: 64112
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair<int,int>
// #define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
using namespace std::chrono;

string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
vector<int> prime={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293,
307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,
401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499,
503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691,
701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797,
809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
};

void solve(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int gcdglobal=__gcd(a[0],a[1]);
  rep(i,2,n) gcdglobal=__gcd(gcdglobal,a[i]);

  map<int,int> m1;
  rep(i,0,n){
    rep(kl,0,(int)prime.size()){
      int c=0;
      while(a[i]%prime[kl]==0) a[i]=a[i]/prime[kl],c++;
      if(c>0) m1[prime[kl]]++;
    }
    if(a[i]>1) m1[a[i]]++;
  }

  int mx=1;
  for(auto i:m1) mx=max(mx,i.s);

  if(mx==1) cout<<"pairwise coprime\n";
  else if(gcdglobal==1) cout<<"setwise coprime\n";
  else cout<<"not coprime\n";
}
int main(){
    optimizeIO();
    solve();
}


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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

 
int main() {
  int c,b,a,ans;
  cin >> c >> a >> b;
  ans = c*a/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

ll dp[3300][3300];
ll dp_sum[3300][3300];

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0]=1;
    for(ll i=1;i<n;i++){
        for(ll j=0;j<=i;j++){
            dp_sum[i-1][j]=dp[i-1][j];
            if(j-1>=0) dp_sum[i-1][j]+=dp_sum[i-1][j-1];
            dp_sum[i-1][j]%=mod;
        }
        for(ll j=0;j<=i;j++){
            if(s[i-1]=='<'){
                if(j-1>=0){
                    dp[i][j]=dp_sum[i-1][j-1];
                }
            }
            else{
                dp[i][j]=dp_sum[i-1][i-1];
                if(j-1>=0) dp[i][j]-=dp_sum[i-1][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    ll ans=0;
    rep(i,n){
        ans+=dp[n-1][i];
        ans%=mod;
    }
    if(ans<0) ans+=mod;
    ans%=mod;
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 156288
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int k;
	cin>>k;
	if(k==1||k==2)cout<<"1"<<endl;
	if(k==3||k==5)cout<<"1"<<endl;
	if(k==7||k==11)cout<<"1"<<endl;
	if(k==13||k==15)cout<<"1"<<endl;
	if(k==17||k==19)cout<<"1"<<endl;
	if(k==23||k==29)cout<<"1"<<endl;
	if(k==31)cout<<"1"<<endl;
	if(k==4||k==6)cout<<"2"<<endl;
	if(k==9||k==10)cout<<"2"<<endl;
	if(k==14||k==21)cout<<"2"<<endl;
	if(k==22||k==25)cout<<"2"<<endl;
	if(k==26)cout<<"2"<<endl;
	if(k==8||k==12)cout<<"5"<<endl;
	if(k==18||k==20)cout<<"1"<<endl;
	if(k==27)cout<<"5"<<endl;
	if(k==30||k==28)cout<<"4"<<endl;
	if(k==16)cout<<"14"<<endl;
	if(k==24)cout<<"15"<<endl;
	if(k==32)cout<<"51"<<endl;
	return 0;

}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))

ans = [0] * n

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

for i in reversed(range(n)):
    if li[i] == 1:
        ans[i] = 1
        for j in make_divisors(i+1):
            li[j-1] = (li[j-1] + 1) % 2

print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1,end = ' ')


Measured memory_bytes: 63836
s = input()
nums = []
num = 100000
for i in range(len(s)):
  if i+2>=len(s):
    break  
  nums.append(s[i])
  nums.append(s[i+1])
  nums.append(s[i+2])
  temp = int(''.join(nums))
  nums.clear()
  num = min(abs(temp-753),num)
print(num)

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

typedef pair<int, int> pii;

int N, ans;
int arr[100010];
pii ord[100010];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);

        ord[i] = pii(arr[i], i);
    }

    sort(ord, ord + N);

    for(int i = 0; i < N; i++) arr[ ord[i].second ] = i;
    for(int i = 0; i < N; i += 2) if(arr[i] % 2) ans++;
    cout << ans;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

ll k, a[50];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> k;
  ll b = 49 + k/50, m = k%50;
  cout << 50 << endl;
  FOR(i, 0, m){
    a[i] = b + 50 - (m - 1);
  }
  FOR(i, m, 50){
    a[i] = b - m;
  }
  FOR(i, 0, 49) cout << a[i] << " ";
  cout << a[49] << endl;
}

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

int main(void) {
    string s;
    int i, c;
    while (1) {
        cin >> s;
        if (s == "0") break;
        c = 0;
        for (i = 0; i < s.size(); i++) {
            c += s[i] - '0';
        }
        cout << c << endl;
    }
    return 0;
}

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

int main(void){

	int N;
    double total_money = 0;
    double money_huge[10];
    char money_type[11][10];
	char JPY[] = "JPY";
    int i;
    
    scanf("%d",&N);
    
    for(i = 0;i < N;i++){
    	scanf("%lf ",&money_huge[i]);
        scanf("%s",money_type[i]);
    }
    
    for(i = 0;i < N;i++){
    	if(strcmp(money_type[i],JPY)==0){
        	total_money += money_huge[i];
        }else{
        	total_money += money_huge[i] * 380000.0;
        }
    }

	printf("%f",total_money);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int L,A,B,C,D,x,y,z;
	scanf("%d \n %d \n %d \n %d \n %d",&L,&A,&B,&C,&D);
        if(A%C == 0){
		x = A/C;
	}else{
		x = A/C+1;
	}
	if(B%D == 0){
		y = B/D;
	}else{
		y = B/D+1;
	}
	if(x >=y){
		z = L-x;
	}else{
		z = L-y;
	}
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 596