akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

ll p10[18];

ll NotFizzBuzz(ll n)
{
    return n - n/3 - n/5 + n/15;
}

ll FizzBuzzLength(ll n)
{
    ll fizz=n/3, buzz=n/5;
    ll ret = fizz*4 + buzz*4;

    int digit=1;
    while(n>p10[digit])
    {
        ret += digit*(NotFizzBuzz(p10[digit]-1) - NotFizzBuzz(p10[digit-1]-1));
        ++digit;
    }
    ret += digit*(NotFizzBuzz(n) - NotFizzBuzz(p10[digit-1]-1));

    return ret;
}

int main()
{
    p10[0]=1;
    for(int i=1; i<18; ++i) p10[i]=p10[i-1]*10;

    ll s;
    cin >>s;

    ll l=0, r=100000000000000000LL;
    while(r-l>1)
    {
        ll m = (l+r)/2;
        if(FizzBuzzLength(m)<s) l=m;
        else r=m;
    }

    ll st_idx = s - FizzBuzzLength(l) - 1;

    string FB="";
    for(ll i=l+1; i<=l+20; ++i)
    {
        if(i%15==0) FB+="FizzBuzz";
        else if(i%3==0) FB+="Fizz";
        else if(i%5==0) FB+="Buzz";
        else FB+=to_string(i);
    }

    cout << FB.substr(st_idx,20) << '\n';
    return 0;
}

Measured memory_bytes: 3200
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


S = str(input())
ret = 0

def solve(i,n,sm):
  if i == len(S)-1:
    return sum(sm+[n*10+int(S[i])])

  ret = 0
  # +を入れる
  ret += solve(i+1, 0, sm+[n*10+int(S[i])])
  # +を入れない
  ret += solve(i+1, n*10+int(S[i]), sm)
  return ret

if __name__ == "__main__":
  print(solve(0,0,[]))




Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
int dp[N];
int h[N];
int main()
{
    int n, k;
    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>h[i];
    dp[1] = 0;
    for (int i=2; i<=n; i++)
    {
        dp[i] = 1e9+7;
        for (int j=1; j<=k && i-j>=1; j++)
            dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A = keyboard.nextInt();
		int B = keyboard.nextInt();
		int T = keyboard.nextInt();
		
			System.out.println((T / A) * B);
			
		keyboard.close();	
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
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 long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s;
	cin>>s;
	while(1){
		s=s.substr(0,s.length()-2);
		if(s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length()/2)){
			cout<<s.length()<<endl;
			return 0;
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(ALL(v));
    double res = v[0];
    for (int i = 1; i < n; i++)
    {
        res = (res + (double)v[i]) / 2.0;
    }
    cout << fixed;
    cout << setprecision(10) << res << endl;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    lines = stdin.readlines()
    A = tuple(map(int, lines[1].split()))
    B = tuple(map(int, lines[2].split()))
    pre = A[0]
    ans = 0
    for a, b in zip(A[1:], B):
        tmp1 = min(pre, b)
        b -= tmp1
        tmp2 = min(a, b)
        ans += tmp1 + tmp2
        pre = a - tmp2
    print(ans)
    return


main()


Measured memory_bytes: 20324
import java.util.Scanner;
 
class Main{
      public static void main(String[] args){
                  Scanner in = new Scanner(System.in);
                  int w = in.nextInt();
                  int h = in.nextInt();
                  int x = in.nextInt();
                  int y = in.nextInt();
                  int r = in.nextInt();

                  if(x+r <= w && 0 <= x-r && 0 <= y-r && y+r <= h){                           
                       System.out.println("Yes");
                  }else{
                       System.out.println("No");
                  } 
     } 
}

Measured memory_bytes: 26180
MOD = 998244353

A, B, C, D = map(int, input().split())

dp = [[0] * (D-B+1) for _ in range(C-A+1)]
dp[0][0] = 1
for i in range(1, C-A+1):
    dp[i][0] = dp[i-1][0] * B
    dp[i][0] %= MOD
for i in range(1, D-B+1):
    dp[0][i] = dp[0][i-1] * A
    dp[0][i] %= MOD

for a in range(A, C):
    for b in range(B, D):
        dp[a-A+1][b-B+1] = dp[a-A][b-B+1] * (b+1) + dp[a-A+1][b-B] * (a+1) - dp[a-A][b-B] * a * b
        dp[a-A+1][b-B+1] %= MOD

print(dp[C-A][D-B])

Measured memory_bytes: 133896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)

int main() {
  ll K, A, B;cin >> K >> A >> B;
  ll c = 0;
  if (B - A >= K) cout << "OK" << endl;
  else if (K == 1) cout << "OK" << endl;
  else {
    FOR(i,A,B+1) {
      if (i % K == 0) {
        cout << "OK" << endl;
        break;
      }
      else c++;
    }
    if (c == B - A + 1)cout << "NG" << endl;
  }
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c; 
	if(a==b && a!=c){
		cout<<"Yes"<<endl;
	}
	else if(a==c && a!=b){
		cout<<"Yes"<<endl;
	}
	else if(b==c && b!=a){
		cout<<"Yes"<<endl;
	}
	else if(a==b && b==c){
		cout<<"No"<<endl;
	}
	else if(a!=b && b!=c && a!=c){
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])-1] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])-1] == True and collect[int(Alist[j][0])-1] == False:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)


Measured memory_bytes: 33708
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[q];
		int[] p = new int[n];
		int count = 0;
		for (int i = 0; i < q; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			p[i] = k - q;
		}
		for (int i = 0; i < q; i++) {
			int j = a[i] - 1;
			p[j]++;
		}
		for (int i = 0; i < n; i++) {
			if (p[i] > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 61156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define mod 1000000007;
#define my_mod 2019;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int num[n];
    rep(i,n) cin >> num[i];
    sort(num,num+n);
    bool ans = false;
    rep(i,n-1){
        if(num[i] == num[i+1]) ans = true;
    }
    ans ? cout << "NO" << endl : cout << "YES" << endl;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  map<string, bool> m;
  for(int i = 0; i < N; i++){
    string s;
    cin >> s;
    m[s] = true;
  }
  cout << m.size() << endl;
}


Measured memory_bytes: 19204
N, Y = map(int, input().split())
ans = [-1,-1,-1]
flag=False
for i in range(N+1):
    if i * 10000 > Y: break
    for j in range(N-i+1):
        if (i*10000 + j*5000 + (N-i-j)*1000) == Y:
            ans = [i,j,N-i-j]
            flag =True
            break
    if flag:
        break
print('{} {} {}'.format(*ans))

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, a, b) for (int i = (a); i < (int)(b); i++)
#define PYMOD(A, M) ((((A) % (M)) + (M)) % (M))
using ll = long long;

using namespace std;

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

    int l;
    cin >> l;

    int n = 0;
    for (int i = 31; i >= 0; i--) {
        if ((l >> i) & 1) {
            n = i + 1;
            break;
        }
    }

    vector<int> u, v, w;

    for (int i = 1; i < n; i++) {
        {
            u.pb(i);
            v.pb(i + 1);
            w.pb(1 << (n - i - 1));
        }
        {
            u.pb(i);
            v.pb(i + 1);
            w.pb(0);
        }
    }

    for (int i = 0; i < n - 1; i++) {
        if ((l >> i) & 1) {
            u.pb(1);
            v.pb(n - i);
            w.pb(l & ~((1 << (i + 1)) - 1));
        }
    }

    cout << n << " " << u.size() << endl;
    forn(i, u.size())
        cout << u[i] << " " << v[i] << " " << w[i] << endl;

    return 0;
}


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

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

using namespace std;

const int maxn=1000010;

bool isprime[maxn];

void init(void){
	rep(i,maxn) isprime[i]=true;
	isprime[0]=isprime[1]=false;

	for(int i=2;i*i<=maxn;i++){
		if(isprime[i])
			for(int j=2*i;j<=maxn;j+=i)
				isprime[j]=false;
	}
	return ;
}

int main(void){
	init();
	int a,d,n;
	while(cin >> a >> d >> n,a|d|n){
		int cnt=0;
		while(1){
			if(isprime[a])
				cnt++;
			if(cnt==n)
				break;
			a+=d;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[N], b[N];
    int suma = 0, sumb = 0;
    rep(i, N) {
        cin >> a[i];
        suma += a[i];
    }
    rep(i, N) {
        cin >> b[i];
        sumb += b[i];
    }
    ll x = 0, y = 0;
    rep(i, N) {
        if (a[i] < b[i]) x += (b[i] - a[i]) / 2;
        else if (a[i] > b[i]) y += a[i] - b[i];
    }
    //dump(suma); dump(sumb);
    //dump(x); dump(y);

    if (x >= y) cout << "Yes" << endl;
    else cout << "No" << endl;
    


    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	int m = n;
	int M = 1e9 + 7;
	rep(i, m) {
		int b;
		cin >> b;
		a[b]++;
	}
	int count = 0;
	
	m /= 2;
	rep(i, m) {
		if (a[n - i * 2 - 1] == 2) {
			count += 2;
		}
	}
	if (n % 2 != 0) {
		if (a[0] == 1) {
			count++;
		}
	}

	if (count == n) {
		ll ans = 1;
		rep(i, m) {
			ans *= 2;
			ans %= M;
		}
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (A + B >= K)
    cout << min(A, K) << endl;
  else
    cout << A - min(C, (K - A - B)) << endl;
}


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

int main() {
    ll N;
    cin >> N;
    vector<pair<ll, ll>> jobs(N);
    ll a, b;
    rep(i, N) {
        cin >> a >> b;
        jobs[i] = make_pair(b, a);
    }
    sort(jobs.rbegin(), jobs.rend());
    ll now = jobs[0].first;
    for (pair<ll, ll> job : jobs) {
        if (now > job.first) now = job.first;
        now -= job.second;
    }
    if (now < 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String Sp = sc.next();
        String T = sc.next();

        System.out.println(solve(Sp, T));

        sc.close();
    }

    static String solve(String Sp, String T) {
        for (int i = Sp.length() - T.length(); i >= 0; --i) {
            int i_ = i;
            if (IntStream.range(0, T.length())
                    .allMatch(j -> Sp.charAt(i_ + j) == '?' || Sp.charAt(i_ + j) == T.charAt(j))) {
                return String.format("%s%s%s", Sp.substring(0, i), T, Sp.substring(i + T.length())).replace('?', 'a');
            }
        }

        return "UNRESTORABLE";
    }
}

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	int a[2][4];
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 4; j++){
			cin >> a[i][j];
		}
	}
	int aa = 0,bb = 0 ;
	for(int i = 0; i < 4; i++){
		aa += a[0][i];
		bb += a[1][i];
	}
	if(aa > bb)cout << aa << endl;
	else cout << bb << endl;


	return 0;
}




Measured memory_bytes: 3092
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		string s;
		int len, k = -1;
		cin >> s >> k;
		if (k <= 0) return 0;
		len = (int)s.length();
		vector<int> r(len), w(len);
		for (int i = 0; i < len; ++i) {
			r[i] = s[i] - '0';
		}
		int ans = 0;
		for (int i = 0; i < len; ++i) {
			for (int a = 1; a <= 9; ++a) {
				if (i == 0 && a > r[0]) break;
				bool x = i == 0 && a == r[0];
				w[i] = a;
				if (k >= 2) {
					for (int j = i + 1; j < len; ++j) {
						for (int b = 1; b <= 9; ++b) {
							if (x) w[j] = b;
							if (k >= 3) {
								for (int k = j + 1; k < len; ++k) {
									for (int c = 1; c <= 9; ++c) {
										if (x) {
											w[k] = c;
											ans += w <= r;
										} else {
											++ans;
										}
									}
									if (x) w[k] = 0;
								}
							} else {
								ans += w <= r;
							}
						}
						if (x) w[j] = 0;
					}
				} else {
					ans += w <= r;
				}
				w[i] = 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N, Q;
    static Dictionary<int, List<int>> G = new Dictionary<int, List<int>>();
    static int[] v, ans;
    static bool[] isReached;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
        Q = cin.nextInt();
        for(int i = 0; i < N - 1; i++)
        {
            int a = cin.nextInt() - 1;
            int b = cin.nextInt() - 1;
            if (!G.ContainsKey(a))
                G.Add(a, new List<int>());
            G[a].Add(b);

            if (!G.ContainsKey(b))
                G.Add(b, new List<int>());
            G[b].Add(a);
        }
        v = new int[N];
        for(int i = 0; i < Q; i++)
        {
            int p = cin.nextInt() - 1;
            int x = cin.nextInt();
            v[p] += x;
        }
        ans = new int[N];
        isReached = new bool[N];
    }
    static void solve()
    {
        input();
        DFS(0, 0);
        WriteLine(string.Join(" ", ans));

    }
    static void DFS(int i, int value)
    {
        value += v[i];
        ans[i] = value;
        isReached[i] = true;
        foreach(var u in G[i])
        {
            if(!isReached[u])
                DFS(u, value);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 82716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	rep(i, 0, n - 2)
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			++cnt;
	cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
const int maxn=310;
const long long INF=1e18+10;
void chkmin(long long &x,long long y){
	x=x<y?x:y;
}
void chkmax(long long &x,long long y){
	x=x>y?x:y;
}
long long Max(long long x,long long y){
	return x>y?x:y;
}
struct node{
	long long v,r;
}b[maxn];
struct Range{
	long long l,r;
};
bool cmp(const node &A,const node &B){
	return A.r<B.r;
}
bool cmpl(const Range &A,const Range &B){
	return A.l<B.l;
}
long long a[maxn];
long long val[maxn*61][maxn];
int num;
map<vector<long long>,vector<Range> > mp;
map<vector<long long>,vector<Range> >::iterator it;
long long d[maxn];
long long getmnv(long long l,long long r){
	if(l>r) return INF;
	int mnv=0;
	for(int j=59;j>=0;j--){
		if((l&(1LL<<j))==(r&(1LL<<j))) mnv+=(l>>j)&1;
		else{
			if(l&((1LL<<j)-1)) mnv++;
			break;
		}
	}
	return mnv;
}
void Add(int n,int p,long long K){
	if(K<0) return;
	long long Mn=b[1].v-(1<=p);
	vector<long long> vec;
	vec.resize(n);
	for(int i=1;i<=n;i++){
		vec[i-1]=b[i].v-(i<=p);
		if(d[i]<0) return;
		chkmin(Mn,vec[i-1]);
	}
	for(int i=1;i<=n;i++)
		vec[i-1]-=Mn;
	Range st=(Range){Max(Mn-K,0),Mn};
	sort(vec.begin(),vec.end());
	mp[vec].push_back(st);
}
int main(){
//	freopen("F.in","r",stdin);
	int n;
	long long K;
	scanf("%d%lld",&n,&K);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int nxt;
	long long l,r;
	for(int k=0;k<=60;k++){
		for(int i=1;i<=n;i++){
			b[i].v=a[i]>>k;
			b[i].r=a[i]&((1LL<<k)-1);
		}
		sort(b+1,b+n+1,cmp);
		l=0;
		for(int i=1;i<=n;i=nxt+1,l=r+1){
			nxt=i;
			while(nxt<n&&b[nxt+1].r==b[i].r) nxt++;
			r=b[i].r;
			Add(n,i-1,K-getmnv(l,r)-k);
		}
	}
	long long ans=0;
	vector<Range> vec;
	for(it=mp.begin();it!=mp.end();it++){
		vec=it->second;
		l=-1,r=-2;
		for(int j=0;j<(int)vec.size();j++){
			if(vec[j].l>r){
				ans=(ans+((r-l+1)%md))%md;
				l=vec[j].l,r=vec[j].r;
			}
			else chkmax(r,vec[j].r);
		}
		ans=(ans+((r-l+1)%md))%md;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 18432
_,*A=$<.map{_1.split.map &:to_i}
101.times{|x|101.times{|y|a=A.map{[_3,(_1-x).abs+(_2-y).abs]}
K,D=a.max
a.all?{_1==[K+D-_2,0].max}&&p(x,y,K+D)}}

Measured memory_bytes: 14396
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
int h, w, n, m, s, ans = 0, a[10000], num = 0, sum = 0;
int flag = 0;
string str;
int main() {
	cin >>str;
	for (int i = 0; i < str.size(); i++) {
		cout << str[i];
		if (i == 3)
			cout << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, y;
	cin >> n >> y;
	
	for(int i = 0; i <= n; ++i) {
		for(int j = 0; j <= n; ++j) {
			int k = n - i - j;
			
			if( k >= 0 && k <= 2000 && y == 10000 * i + 5000 * j + 1000 * k) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	
	cout << -1 << " " << -1 << " " << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
    for (T& x : v) is >> x;
    return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    if (!v.empty()) {
        os << v.front();
        for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];
    }
    return os;
}

int main() {
#ifdef LBT
    freopen("test.in", "r", stdin);
    int nol_cl = clock();
#endif
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> paint(n);
    for (int i = 0; i < n; ++i) cin >> paint[i].second >> paint[i].first;
    vector<int> c(m);
    cin >> c;
    sort(c.begin(), c.end(), greater<int>());
    sort(paint.begin(), paint.end(), greater<pair<int, int>>());
    int ans = 0;
    for (auto pr : paint){
        int v,s;tie(v,s)=pr;
        if (ans < m && s <= c[ans])
            ++ans;
    }
    cout << ans << '\n';

#ifdef LBT
    LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
    return 0;
}


Measured memory_bytes: 4164
S = input()
N = int(S)


def count753(s):
    is753 = "7" in s and "5" in s and "3" in s
    if len(s) == len(S):
        return 1 if int(s) <= N and is753 else 0
    return int(is753) + count753(s + "7") + count753(s + "5") + count753(s + "3")


print(count753("7") + count753("5") + count753("3"))

Measured memory_bytes: 45912
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

int A[200010];

void solve() {
    int N;
    long long K;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        --A[i];
    }
    vector<int> visited(N, -1);
    int cycle = 0;
    int cur = 0;
    int time = 0;
    while (true) {
        dbg << "cur = " << cur << ", time = " << time << endl;
        if (visited[cur] != -1) {
            cycle = time - visited[cur];
            break;
        }
        visited[cur] = time;
        ++time;
        cur = A[cur];
        if (time == K) {
            cout << cur + 1 << endl;
            return;
        }
    }
    int rem = (K - visited[cur]) % cycle;
    for (int i = 0; i < rem; ++i) cur = A[cur];
    cout << cur + 1 << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


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



int main(){
  int n, m;
  cin >> n >> m;
  vector<long long> x(n);
  vector<long long> y(m);
  int md = 1e9+7;
  for (int i=0; i<n; i++) cin >> x[i];
  for (int i=0; i<m; i++) cin >> y[i];
  long long xsum=0, ysum=0;
  for (int k=0; k<n; k++){
    xsum += k*x[k] - (n-k-1)*x[k];
    xsum %= md;
  }
  for (int k=0; k<m; k++){
    ysum += k*y[k] - (m-k-1)*y[k];
    ysum %= md;
  }
  cout << xsum*ysum%md << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define NUL -1

int u[100][100];//u[id][k v]
int l[100];

void search(int a,int d){
  int i,t,q;
  if(l[a]==NUL || (l[a]!=NUL && l[a] > d)){
    //printf("%d %d\n",l[a],d);
    l[a] = d;
    t = u[a][0];
    for(i=1;i<=t;i++){
      q = u[a][i];
      search(q,d+1);    
    }
  }
}



int main(){
  int n,i,ii,t,kk,c;
  int a;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&t);
    scanf("%d",&u[t][0]);
    for(ii=1;ii<=u[t][0];ii++)
      scanf("%d",&u[t][ii]);
    l[i]=NUL;
  }


  search(1,0);

  /*
  for(i=1;i<=n;i++)
    if(l[i]==NUL)
      search(i);
  */

  

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



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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1e9  //
#define LINF 1e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int cnt = 0;

    map<int, bool> mp;

    rep(i, n) {
        int a;
        cin >> a;

        if (mp[a]) {
            cnt--;
            mp[a] = false;
        } else {
            cnt++;
            mp[a] = true;
        }
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,anssum=0,sum=0;
	cin>>n;
	vl v(n),ans(n);
	rep(i,n)cin>>v[i],sum+=v[i];
	ll tab=sum;
	for(int i;i<n-1;i+=2)tab-=v[i]*2;
	ans[n-1]=tab;
	rep(i,n-1){
		ans[i]=(v[(i+n-1)%n]-ans[(i+n-1)%n]/2)*2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	scanf("%lld%lld",&a,&b);
	cout<<a*b/gcd(a,b);
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int cnt[4];

int main()
{
	int n;
	scanf("%d", &n);
	char s[5];
	for (int i = 0; i < n; ++i)
	{
		scanf("%s", s);
		switch (s[0])
		{
			case 'A': { cnt[0]++; break; }
			case 'W': { cnt[1]++; break; }
			case 'T': { cnt[2]++; break; }
			case 'R': { cnt[3]++; break; }
		}
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", cnt[0], cnt[1], cnt[2], cnt[3]);
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


using namespace std;

#define int         long long
#define ld          double
#define vi          vector <int>
#define vp          vector <pair<int,int>>
#define vvi         vector <vector <int>>
#define pb          push_back
#define mp          make_pair
#define pi          pair<int,int>
#define all(a)      a.begin(),a.end()
#define sz(a)       a.size()
#define sl(a)       a.length()
#define rev(a)      sort(all(a),greater<int>())
#define ff          first
#define ss          second
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define Mod         1000000007
#define deb(x)      cout << x << endl;
#define o(x)        for(auto a:x)cout << a <<" ";cout << endl;
#define o2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cout << x[i][j] << " ";cout << endl; } 
#define i(x,n)      for(int i=0;i<n;i++)cin >> x[i];
#define i2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cin >> x[i][j]; }
int inf = 1e18;





signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<long double> p(n+1,0);
    for(int i=1;i<=n;i++)cin >> p[i];
   

    long double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)dp[i][j] = 0;
    }

    dp[1][0] = 1 - p[1];
    dp[1][1] = p[1];


    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0){dp[i][j] = (1-p[i])*dp[i-1][j];continue;}

            dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
        }
    }

    int x = (n+2 -1)/2;
    long double ans = 0;
    for(int i=x;i<=n;i++)ans += dp[n][i];
    cout << setprecision(10);
    deb(ans);

}






Measured memory_bytes: 144372
#include <iostream>
#include <cmath>

using namespace std;

typedef long long int ll;

int main(void){
  ll a,b,c;
  cin >> a >> b >> c;
  ll right = c - a - b;
  if(right < 0){
    cout << "No" << endl;
    return 0;
  }
  right = right*right;
  if(4*a*b < right){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

int n,m,a[1100];bool c[1100][20];
int dp[10000];
signed main(){
  cin>>n>>m;

  rep(i,m){
    int b;
    cin>>a[i]>>b;
    rep(j,b){
      int cc;cin>>cc;cc--;
      c[i][cc] = true;
    }
  }

  rep(i,10000)dp[i] = INF;
  dp[0] = 0;

  rep(bit,1<<n){
    rep(i,m){
      int nbit = bit;
      rep(j,n){
        if(c[i][j]){//i番目の鍵がj番目の箱を開けられるか
          nbit |= (1<<j);
        }
      }
      chmin(dp[nbit], dp[bit] + a[i]);
    }
  }
  cout << (dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod 1e9+7
#define P(a,b) pair<a,b>
#define CIN(V,s,n) for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}

using namespace std;
bool sortBylen(string &a,string &b)
{
    if(a.size()>b.size())
        return true;
    else if(a.size()==b.size())
    {
        if(a>b)
        {
            return true;
        }
        else
            false;
    }
    else
        return false;
}
int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,W,i,j,k=2,l1,l2,m;
    string s1,s2;
    cin >> s1 >> s2;
    l1 = s1.size();
    l2 = s2.size();

    vector<vector<ll> > DP(l1+1,vector<ll>(l2+1,0));

    for(i=1;i<=l1;i++)
    {
        for(j=1;j<=l2;j++)
        {
            DP[i][j] = max(DP[i-1][j],DP[i][j-1]);
            if(s1[i-1]==s2[j-1])
            {
                DP[i][j] = max(DP[i][j],DP[i-1][j-1] + 1);
            }
        }
    }

    i = l1,j=l2;
    string s="";
    while(i>0 and j>0)
    {
        if(DP[i][j]==DP[i-1][j-1]+1)
        {
            if(DP[i-1][j]==DP[i][j]-1)
            {
                if(DP[i][j-1]==DP[i][j]-1)
                {
                    i--;
                    j--;
                    s += s1[i];
                }
                else
                {
                    j--;
                }
            }
            else
            {
                i--;
            }
        }
        else
        {
            i--;
            j--;
        }
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
    //cout << DP[l1][l2] << endl;
}

	return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll ans = -1e18;
  if (n % 2 == 1) {
    vector<ll> left(n / 2 + 2), middle(n / 2 + 2), right(n / 2 + 2);
    for (int i = 0; i < n / 2; i++) {
      left.at(i + 1) = left.at(i) + a.at(i * 2);
      middle.at(i + 1) = middle.at(i) + a.at(i * 2 + 1);
    }
    for (int i = n / 2; i > 0; i--) {
      right.at(i) = right.at(i + 1) + a.at(i * 2);
    }
    vector<ll> best(n / 2 + 2);
    best.at(0) = 0;
    for (int i = 1; i <= n / 2; i++) {
      best.at(i) = max(best.at(i - 1) + middle.at(i) - middle.at(i - 1), left.at(i));
    }
    for (int i = 0; i <= n / 2; i++) {
      ans = max(ans, best.at(i) + right.at(i + 1));
    }
  }
  else {
    ll keep = 0;
    for (int i = 1; i < n; i += 2) keep += a.at(i);
    ans = keep;
    for (int i = 1; i < n; i += 2) {
      keep = keep - a.at(i) + a.at(i - 1);
      ans = max(ans, keep);
    }
  }
  
  cout << ans << '\n';
}

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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int n,x,y,z;
    cin>>n>>x>>y>>z;
    int sum=x+y+z;
    vector<ll> tenp(n+1);
    tenp[0]=1;
    for(int i=0;i<n;i++) tenp[i+1]=tenp[i]*10%MOD;
    vector<vector<ll>> dp(n+1,vector<ll>(1<<(x+y+z)));
    dp[0][0]=1;
    const int mask=(1<<sum)-1;
    ll res=0;
    for(int i=0;i<n;i++){
        for(int bit=0;bit<(1<<sum);bit++){
            if(!dp[i][bit]) continue;
            for(int j=1;j<=7;j++){
                int tobit=((bit<<j)+(1<<(j-1)))&mask;
                bool bx=(tobit>>(x-1))&1;
                bool by=(tobit>>(x+y-1))&1;
                bool bz=(tobit>>(x+y+z-1))&1;
                if(bx && by && bz){
                    res+=dp[i][bit]*tenp[n-1-i];
                    res%=MOD;
                }
                else{
                    dp[i+1][tobit]+=dp[i][bit];
                    dp[i+1][tobit]%=MOD;
                }
            }
            dp[i+1][0]+=dp[i][bit]*3;
            dp[i+1][0]%=MOD;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 43392
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e6+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n,a[MAXN];
unordered_map<int,int>mp;
//map<int,int>mp;
//TLE了 可能思路：每个数*一个数的形式 判断所得的num 然后与n比较 
int main()
{
	scanf("%d",&n);int ans=0,max1=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),mp[a[i]]++,max1=max(max1,a[i]);
	for(int i=2;i<=max1;i++)
	{
		int num=0;
		for(int j=i;j<=max1;j+=i)
		{
			num+=mp[j];
		}
		ans=max(num,ans);
	}
	if(ans<=1) printf("pairwise coprime\n");
	else if(ans<n) printf("setwise coprime\n");
	else printf("not coprime\n");
	return 0;
} 

Measured memory_bytes: 46532
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
B = LI()

B.reverse()

ans = B[0] + B[-1]

for i in range(N - 2) :
    ans += min(B[i], B[i + 1])

print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  // int n, p;
  // cin >> n >> p;
  string n;
  cin >> n;

  rep(i,n.length()){
    if (n.find("7") != n.npos){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
  return 0;
}


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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=2e5+5;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n;
char s[N],t[N];
int ans;

int main()
{
    scanf("%s",s+1);
    scanf("%s",t+1);
    n=max(strlen(s+1),strlen(t+1));
    Rep(i,1,n)if(s[i]!=t[i])ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4148
(let* ((n (read))
       (c (make-hash-table :size n))
       (ans t))
  (loop :for i :from 1 :to n
        :for a := (read)
        :if (gethash a c)
        :do (setf ans nil)
        :else
        :do (setf (gethash a c) t))
  (format t "~A~%" (if ans "YES" "NO")))


Measured memory_bytes: 81928
/*
      author : nishi5451
      created: 11.08.2020 00:01:25
*/

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


int main(){
    string s,t,u;
    cin >> s >> t >> u;
    cout << "A" << t[0] << "C" << endl;
    return 0;
}

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

class Program
{
    public static void Main()
    {
        double n = int.Parse(Console.ReadLine());
        if ((n / 1.08) % 1 == 0)
        {
            Console.WriteLine(n / 1.08);
        } else
        {
            if (Math.Truncate(Math.Ceiling(n / 1.08) * 1.08) == n)
            {
                Console.WriteLine((int)(n / 1.08) + 1);
            } else
            {
                Console.WriteLine(":(");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    int a[n], x;
    ll ans=0;
    vector<int> p[n], m[n];
    rep(i, n){
        cin >> a[i];
        //cout << a[i] << " ";
    }
    rep(i, n){
        //if(i+a[i]<n) p[i+a[i]].append(i);
        if(i-a[i]>0) m[i-a[i]].push_back(i);
    }
    rep(i, n){
        //sort(p[i].begin(),p[i].end());
        sort(m[i].begin(),m[i].end());
    }

    rep(i, n){
        //cout <<"i+a[i]"<<i+a[i]<<endl;
        if(i+a[i]<n){
            x = i+a[i];
            //cout << "x fixed"<<endl;
        }
        else continue;
        //cout << "x="<<x<<endl;
        int y = 0;
        if(y == m[x].size()) continue;
        //cout << "!"<< endl;
        while(m[x][y] < i){
            y++;
            if(y == m[x].size()) break;
        }
        //cout << "y="<<y << endl;
        ans += m[x].size()-y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17776
// Aizu Vol-2 0217: Walking in the Hospital
// 2017.8.6

#include <stdio.h>

int main()
{
	int n, p, d1, d2;
	int i, max, id;

	while (1) {
		scanf("%d", &n);
		if (n == 0) break;
		for (id = -1, i = 0; i < n; i++) {
			scanf("%d%d%d", &p, &d1, &d2);
			d1 += d2;
			if (id < 0 || max < d1) id = p, max = d1;
		}
		printf("%d %d\n", id, max);
	}
	return 0;
}

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

int main(){
    int n,ans=0;
    cin>>n;
    int p[20]={};
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i+2<n;i++){
        if(p[i]<p[i+1]&&p[i+1]<p[i+2]){
            ans++;
        }if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
taro=0
hanako=0
for i in range(n):
    a,b=map(str,input().split())
    if a>b:
        taro+=3
    elif a<b:
        hanako+=3
    else :
        taro+=1
        hanako+=1
        
print(taro,hanako)


Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		if(D == 25) {
			System.out.println("Christmas");
		} else if(D == 24) {
			System.out.println("Christmas Eve");
		} else if(D == 23) {
			System.out.println("Christmas Eve Eve");
		} else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}


Measured memory_bytes: 26908
#include<stdio.h>
int count(char *ary);

int main()
{
  int i, length, countC = 0, counts = 0;
  char ary[11];
  scanf("%s", ary);

  // printf("%s\n", ary);
  
  length = count(&ary[0]);

  // printf("length=%d\n", length);

  if(ary[0] == 'A'){
    for(i = 2; i < length - 1; ++i){
      if(ary[i] == 'C') ++countC;
    }

    // printf("countC=%d\n", countC);
    
    if(countC == 1){
      for(i=0; i<length; ++i){
	if((int)ary[i] > 90) ++counts;
	// printf("counts=%d\n", counts);
      }
      if(counts == length - 2) printf("AC\n");
      else printf("WA\n");
      
    }else printf("WA\n");
    

  }else printf("WA\n");



  return 0;
}

int count(char *ary){
  int i, count=0;
  for(i=0; i<11; ++i){
    if(*(ary+i) == '\0') break;
    else  ++count;
  }

  return count;
}
  


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

int n,m;
const int MAXN = 10010;

struct edg{
    int u,v,cost;
};

int p[MAXN],sz[MAXN];
vector<edg> edgs;

bool cmp(edg a,edg b){
    return a.cost<b.cost;
}

int find(int x){
    return (x==p[x]) ? x : p[x]=find(p[x]);
}
bool unite(int a,int b){
    a = find(a);
    b = find(b);
    if(a==b){
        return false; //already same cc
    }
    if(sz[b] > sz[a]){ swap(a,b);}
    sz[a]+=sz[b];
    p[b] = a;
    return true;
}

void kruskal()
{
    for(int i=0; i<n; i++){
        p[i]=i; sz[i]=1;
    }
    sort(edgs.begin(),edgs.end(),cmp);
    int ans = 0;
    for(auto e : edgs){
        if( unite(e.u,e.v)){
            ans+=e.cost;
        }
    }
    cout<<ans<<"\n";
}
int main() {
    // freopen("./input.txt","r",stdin);
    // freopen("./output.txt","w",stdout);
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int a,b,c; cin>>a>>b>>c;
        edgs.push_back({a,b,c});
    }
    kruskal();
}


Measured memory_bytes: 4588
from functools import reduce

def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == '__main__':
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]
    if not x in points:
        points.append(x)

    buf = [abs(points[i + 1] - points[i]) for i in range(len(points) - 1)]
    print(reduce(lambda a,b: euclid(a, b), buf))


Measured memory_bytes: 14748