akhauriyash/Code-Regression huggingface dataset:
//
// Created on 2020/07/25.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int x;
    cin>>x;
    if(x < 600){
        cout<<8<<endl;
        return  0;
    }
    if(x < 800){
        cout<<7<<endl;
        return 0;
    }
    if(x < 1000){
        cout<<6<<endl;
        return 0;
    }
    if(x < 1200){
        cout<<5<<endl;
        return 0;
    }
    if(x < 1400){
        cout<<4<<endl;
        return 0;
    }
    if(x < 1600){
        cout<<3<<endl;
        return 0;
    }
    if(x < 1800){
        cout<<2<<endl;
        return 0;
    }
    if(x < 2000){
        cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();
		if(x>=r&&x<=h-r&&y>=r&&y<=w-r) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26328
N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(N):
    ans = 0
    for j in range(i, N - 1):
        if ans < S[j]:
            ans = S[j]
        else:
            ans = ((ans + F[j] - 1) // F[j]) * F[j]

        ans += C[j]

    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
map<int,int> m;
vector<int> v;
int main()
{
	int n;
	cin>>n;
	int x;
	for(int i=1;i<=n;i++)
	{
		x=0;
		cin>>x;
		if (m[x]==0) v.push_back(x);
		m[x]++;
	}
	int ans=0;
	for (int i=0;i<v.size();i++)
	  if (v[i]>m[v[i]]) 
	    ans+=m[v[i]];
	  else if (v[i]<m[v[i]])
	    ans+=m[v[i]]-v[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import reduce
from operator import xor

N = int(readline())
A = [0] + list(map(int,read().split()))

B = [0] * (N+1)
for n in range(N,0,-1):
    s = reduce(xor,B[n+n::n],0)
    B[n] = s^A[n]

I = [i for i,x in enumerate(B) if x]

print(len(I))
if len(I) > 0:
    print(' '.join(map(str,I)))

Measured memory_bytes: 20328
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

class TVertex
{
    int FIndex;
    int FCommuniyId;
    std::vector<TVertex*> FList;

public:
    TVertex(int Index)
     : FIndex(Index), FCommuniyId(0)
    {}
    void AddPath(TVertex* Vertex)
    {
        FList.push_back(Vertex);
    }
    void SetCommunity(int CommunityId)
    {
        if(FCommuniyId) return;
        FCommuniyId = CommunityId;
        for(std::vector<TVertex*>::iterator It = FList.begin(); It != FList.end(); ++It){
            TVertex* V = *It;
            V->SetCommunity(CommunityId);
        }
    }
    int CommunityId()const
    {
        return FCommuniyId;
    }
};
class TGraph
{
    std::vector<TVertex*> FTable;
    void Init(int n)
    {
        assert(n > 0);
        FTable.resize(n);
        for(int i = 0; i < n; ++i){
            FTable[i] = new TVertex(i);
        }
    }
public:
    TGraph(int n)
    {
        Init(n);
    }
    
    void SetupVertex(std::istream& in)
    {
        int Index;
        in >> Index;
        assert(Index >= 1);
        assert(Index <= FTable.size());
        int k;
        in >> k;
        for(int i = 0; i < k; ++i){
            int v;
            in >> v;
            FTable[Index]->AddPath(FTable[v]);
        }
    }
    void MakeFriend(int s, int t)
    {
        assert(s < FTable.size());
        assert(t < FTable.size());
        FTable[s]->AddPath(FTable[t]);
        FTable[t]->AddPath(FTable[s]);
    }
    void SetCommunity()
    {
        for(std::size_t i = 0; i < FTable.size(); ++i){
            FTable[i]->SetCommunity(i+1);
        }
    }
    bool IsSameCommunity(int s, int t)const
    {
        assert(s < FTable.size());
        assert(t < FTable.size());
        return FTable[s]->CommunityId() == FTable[t]->CommunityId();
    }
};

int main()
{
    int n, m;
    std::cin >> n >> m;
    TGraph Graph(n);
    for(int i = 0; i < m; ++i){
        int s, t;
        std::cin >> s >> t;
        Graph.MakeFriend(s, t);
    }
    int q;
    std::cin >> q;
    Graph.SetCommunity();
    for(int i = 0; i < q; ++i){
        int s, t;
        std::cin >> s >> t;
        std::cout << (Graph.IsSameCommunity(s, t) ? "yes" : "no") << std::endl;
    }
    return 0;
    
}

Measured memory_bytes: 13580
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

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

    string s;
    cin >> s;

    for (size_t i = 0; i < s.size(); ++i) {
        if (s[i] == 'd') {
            if (i + 4 >= s.size() || s[i+1] != 'r' || s[i+2] != 'e' || s[i+3] != 'a'
                || s[i+4] != 'm') {
                cout << "NO" << endl;
                return 0;
            } 
            i += 4;
            if (i + 2 <= s.size()) {
                if (s[i+1] == 'e' && s[i+2] == 'r') {
                    if (i + 3 < s.size() && s[i+3] == 'a') {
                        continue;
                    } else {
                        i += 2;
                    }
                }
            } 
        } else if (s[i] == 'e') {
            if (i + 3 >= s.size() || s[i+1] != 'r' || s[i+2] != 'a' || s[i+3] != 's' 
                || s[i+4] != 'e') {
                cout << "NO" << endl;
                return 0;
            }
            i += 4;
            if (i + 1 < s.size() && s[i+1] == 'r') {
                ++i;
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
K, N = map(int, input().split())
A = list(map(int, input().split()))

dA = [A[i+1] - A[i] for i in range(N-1)]
dA.append(K-A[-1]+A[0])
sumdA = sum(dA)
maxdA = max(dA)
print(sumdA - maxdA)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1, 0));
  for (int i = 1; i <= s.size(); ++i) {
    for (int j = 1; j <= t.size(); ++j) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      }
    }
  }
  string ans;
  int i = s.size();
  int j = t.size();
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j]) {
      --i;
    } else if (dp[i][j] == dp[i][j-1]) {
      --j;
    } else {
      ans = s[i-1] + ans;
      --i; --j;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
input()
list_ = sorted(map(int, input().rstrip("\n").split()))

dict_ = dict()
for key in list_:
    dict_[key] = dict_.get(key, 0) + 1

max_ = 0
for key in set(list_):
    num = dict_[key] + dict_.get(key - 1, 0) + dict_.get(key + 1, 0)
    max_ = num if num > max_ else max_
print(max_)


Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007

int main() {
	int n; cin >> n;
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		ll a;ll b = 0; cin >> a;
		while (true) {
			if (a % 2 == 0) { a /= 2, b++; }
			else { break; }
		}
		sum += b;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,k,bt,max_v;
  cin >> n >> k;
  for(int i=0;;i++){
    if(i==0) bt = 1;
    else bt *= k;
    max_v = bt-1;
    if(max_v>=n){
      cout << i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		List<String> alphabet = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

		for (String string : alphabet) {
			if (!S.contains(string)){
				System.out.println(string);
				return;
			}
		}
		System.out.println("None");
		return;
	}
}


Measured memory_bytes: 25044
n,l  = map(int, input().split())

apples = []
minval = 200

for i in range(n):
    apples.append(i+l)

for i in apples:
    minval = min(minval, abs(i))

for i in apples:
    if minval == abs(i):
        print(sum(apples)-i)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int N,R[200000],h;
  int min=1000000000,max,dis=-1000000000;
  cin >>N;
  for(int t=1;t<=N;t++){
    cin >> R[t];
  }
 
  for(int t=1;t<N;t++){
    if(min>=R[t]){
      min=R[t];
      max=-1;
      for(int i=t+1;i<=N;i++) if(max<R[i]) max=R[i];
      if((max-min) >= dis) dis=max-min;
    }
      }
     
  cout <<dis<<endl;
  return 0;
}

Measured memory_bytes: 1940
//
// Created by ryo on 2019/11/10.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    ll n;
    cin >> n;
    vector<ll> d(n);
    map<ll, ll> count;
    ll mmax = -1;
    rep(i, n) {
        cin >> d[i];
        count[d[i]] += 1;
        chmax(mmax, d[i]);
    }

    if (d[0] > 0 || count[0] > 1) {
        cout << 0 << endl;
        return 0;
    }

    sorti(d);

    ll ans = 1;
    constexpr ll mod = 998244353;

    for (ll i = 1; i <= mmax; ++i) {
        ll pre = count[i-1];
        //if (pre == 0) ans = 0;
        for (ll j = 0; j < count[i]; ++j) {
            ans *= pre;
            ans %= mod;
        }
    }

    ans %= mod;
    cout << ans << endl;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<char>> c(h, vector<char>(w));
  int i, j;
  for(i = 0; i < h; i++)
  {
    for(j = 0; j < w; j++)
    {
      cin >> c.at(i).at(j);
    }
  }
  for(i = 0; i < 2 * h; i++)
  {
    for(j = 0; j < w; j++)
    {
      cout << c.at(i/2).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
 
#define ll long long int
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define V vector<ll>
#define print2(x) cout <<"####"<< #x <<"  =>  "<<x<< endl
#define print1(x) cout <<"****"<< #x <<"  =>  "<<x<< endl
#define maxn 100005

ll cnt[26];
ll ans;	
int main()
{
	fast_io;
	string s;
	cin>>s;
	ll n=s.length();
	rep(i,0,n-1)
	{
		int x=int(s[i])-int('a');
		cnt[x]++;
	}
	ans=1+(n*(n-1))/2;
	rep(i,0,25)
	{
		ans-=(cnt[i]*(cnt[i]-1))/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 720
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    ll n;
    cin >> n;
    map<string, ll> s_map;
    ll max_num = 0;
    for (ll i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s_map.count(s) == 0) {
            s_map[s] = 1;
        } else {
            s_map[s]++;
        }
        max_num = max(s_map[s], max_num);
    }
    for (auto s : s_map) {
        if (s.second == max_num) cout << s.first << endl;
    }

    return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> K(M); //kを入れておく
  vector<vector<int>> S(M); //sを入れておく
  vector<int> P(M);
  
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    K.at(i) = k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      s--;
      S.at(i).push_back(s);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> P.at(i);
  }
  
  int ans = 0;
  //Nビットのビット列を全列挙(1で点灯)
  for (int bit = 0; bit < (1 << N); bit++) {
    bool check = true;
    for (int i = 0; i < M; i++) { //電球i
      int p = P.at(i);
      int k = K.at(i);
      int count_on = 0;
      for (int j = 0; j < k; j++) {
        if ((bit & (1 << S.at(i).at(j))) > 0) {
          count_on++;
        }
      }
      if (!(count_on % 2 == p)) {
        check = false;
      }
    }
    if (check) {
      ans++;
    }
  }
  cout << ans << endl;
}

      
        


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int m,n,x;
int p[100][100];
int pp[100],wa;

scanf("%d",&n);scanf("%d",&m);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
{
scanf("%d",&x);
p[i][j]=x;
}
}
for(int i=0;i<m;i++){
scanf("%d",&x);
pp[i]=x;
}
wa=0;
for(int i=0;i<n;i++){
	
for(int k=0;k<m;k++)
{
wa+=p[i][k]*pp[k];
}
printf("%d\n",wa);
wa=0;
}
return 0;
}

Measured memory_bytes: 1064
import java.io.*;
import java.util.*;
public class Main {        
    public static void main(String args[]) {
        int x=II();
        int ans=0;
        if(x<=599)
            ans=8;
        else if(x<=799)
            ans=7;
        else if(x<=999)
            ans=6;
        else if(x<=1199)
            ans=5;
        else if(x<=1399)
            ans=4;
        else if(x<=1599)
            ans=3;
        else if(x<=1799)
            ans=2;
        else
            ans=1;

        System.out.println(ans);
    }
    
    ////////////////////////////////////
    static scan in=new scan(System.in);
    static int II() {
        return in.nextInt();
    }
    static long IL() {
        return in.nextLong();
    }
    static int[] IIA(int n) {
        int a[]=new int[n];
        for(int i=0;i<n;i++) {
            a[i]=II();
        }
        return a;
    }
    static String IS() {
        return in.next();
    }
    static char IC(){
        return in.next().charAt(0);
    }
    static String[] ISA(int n) {
        String a[]=new String[n];
        for(int i=0;i<n;i++) {
            a[i]=IS();
        }
        return a;
    }
    static char[] ICA(int n) {
        char a[]=new char[n];
        for(int i=0;i<n;i++) {
            a[i]=IC();
        }
        return a;
    }
}
class scan
{
    public static BufferedReader reader;
    public static StringTokenizer token;

    scan(InputStream str)
    {
        reader=new BufferedReader(new InputStreamReader(str));
        token=null;
    }

    static int nextInt()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Integer.parseInt(token.nextToken());
    }

    static long nextLong()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return Long.parseLong(token.nextToken());
    }

    static String next()
    {
        while(token==null||!token.hasMoreTokens())
        {
            try { token=new StringTokenizer(reader.readLine());   }
            catch(IOException e){  throw new RuntimeException(e); }
        }
        return token.nextToken();
    }

}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N;
str S;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N >> S;
	F0R(i, sz(S)) {
		int ascii = S[i] - 'A';
		ascii = (ascii + N) % 26;
		S[i] = 'A' + ascii;
	}
	cout << S;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
import sys
import math

a, b, c = map(int, input().split())
ma=max(a, max(b, c))
if 3 *ma %2 ==(a + b + c)%2:
    print(((3 * ma) - (a + b + c))// 2)
else:
    print(((3 * (ma+1)) - (a + b + c))// 2)


Measured memory_bytes: 3060
import itertools
import math
N = int(input())
nums = list(map(int,input().split(" ")))
nums.sort()
ind = 0
maxcolor = 0
mincolor = 0
cols = []
while True:
    if ind == N or nums[ind] >= 3200:
        break
    cols.append(nums[ind]//400)
    ind += 1

cols = list(set(cols))
over3200 = nums[ind:]
maxcolor = mincolor = len(cols) #3200未満の色の種類

if len(over3200) > 0:
    if mincolor > 0: #3200以下が一人でもいたらそれに合わせて終わり
        pass
    else:
        mincolor = 1 #3200以下が居なかったら全員同じ色に

maxcolor = maxcolor + len(over3200)
print(mincolor,maxcolor)

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


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

    vector<int> prime(1000001);
    for (int i = 0; i < 1000001; ++i) {
        prime[i] = i;
    }
    prime[0] = -1;
    prime[1] = -1;
    for (int i = 2; i < 1000001; ++i) {
        for (int j = i * 2; j < 1000001; j += i) {
            prime[j] = min(prime[j], i);
        }
    }

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

    bitset<1000001> appear(0);
    bool flag = true;
    for (int start : a) {
        int now = start;
        map<int, bool> facts;
        while (prime[now] != -1) {
            facts[prime[now]] = true;
            now /= prime[now];
        }
        for (auto pair : facts) {
            int fact = pair.first;
            if (appear[fact]) {
                flag = false;
                break;
            }
            appear[fact] = true;
        }
    }

    if (flag) {
        cout << "pairwise coprime" << endl;
    } else {
        int res = a[0];
        for (int i = 1; i < n; ++i) {
            res = gcd(res, a[i]);
        }
        if (res == 1) {
            cout << "setwise coprime" << endl;
        } else {
            cout << "not coprime" << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n"
#define CNO cout << "No" \
                 << "\n"
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double N;
  cin>> N;
  vector<int> A(N);
  double count = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
      count += A[i];
  }

  double C = count /N;
  int B = count/N;
  if(C-B >=0.5)
    B +=1;
    
  int count2 =0;
       
  for(int i = 0; i< N;i++){
    int x = A[i]- B;
    count2 += pow(x, 2);
  }
  cout << count2 << endl;
}
  

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

string S, T;
unsigned long long diff,ls;

int main() {
	cin>>S;
	cin>>T;
	
	ls = S.length();
	
	for (unsigned long long i = 0; i<ls; i++){
		if (S[i]!=T[i]){
			diff++;
		}
	}
	
	cout<<diff<<endl;
	return 0;
}

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

int main() {
	int length;
	long long sum = 0;
	cin >> length;
	int *a = new int[length];
	for (int i = 0; i < length; i++) {
		cin >> a[i];
		sum += a[i];
	}
	long long sum1 = a[0];
	long long min = abs(sum - 2 * sum1);
	for (int i = 1; i < length-1; i++) {
		sum1 += a[i];
		if (abs(sum-2*sum1) < min)
			min = abs(sum-2*sum1);
	}
	cout << min ;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std ;

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,(e-1)/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,(e-1)/2);
	return power(b*b,e/2);
}

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

	int n;
	cin>>n;
	int a[n],b[n],c[n],i,dp[3][n+1];
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][1]=a[0];
	dp[1][1]=b[0];
	dp[2][1]=c[0];
	for(i=2;i<=n;i++)
	{
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i-1];
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i-1];
		dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c[i-1];
	}
	cout<<max({dp[0][n],dp[1][n],dp[2][n]});
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include<string>

int main()
{	
  int H = 0, N = 0;
	std::string ans;

	long long int M = 0;
	std::cin >>H >> N;

	std::vector<int> A(N);
	for (int i = 0; i < N; i++){
		std::cin >> A[i];

		M += A[i];
	}
	
	if (H > M){
		ans = "No";
	}
	else{
		ans = "Yes";
	}
	
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for(int i = 0; i < n; i++)
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}

signed main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N){
    cin >> a.at(i);
  }
  bool b = true;
  for(int j = 1; j < N; j++){
    if(a.at(a.size()-j) > a.at(a.size()-(j+1)) ){

    }
    else if(a.at(a.size()-j) == a.at(a.size()-(j+1)) ){

    }
    else if(a.at(a.size()-j) < a.at(a.size()-(j+1)) && a.at(a.size()-(j+1)) - a.at(a.size()-j) == 1){
      a.at(a.size()-(j+1))--;
    }
    else if(a.at(a.size()-j) < a.at(a.size()-(j+1)) && a.at(a.size()-(j+1)) - a.at(a.size()-j) > 1){
      b = false;
    }
  }
  Yn(b);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int a,b; cin >> a >> b;
    if (b % a == 0)
        cout << a+b << endl;
    else
        cout << b-a << endl;
    return 0;
}


Measured memory_bytes: 3612
using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split();
            double a = double.Parse(input[0]);
            double b = double.Parse(input[1]);
            double x = double.Parse(input[2]);

            double ans = 0;

            if(x > a*a*b/2.0)
            {
                double c = 2.0 * x /a/a - b;
                double cos = a/Math.Sqrt(a*a + (b-c)*(b-c));
                ans = 180.0/Math.PI * Math.Acos(cos);
            }
            else
            {
                double d = 2.0 * x /a/b;
                double cos = d / Math.Sqrt(d*d + b*b);
                ans = 180.0/Math.PI * Math.Acos(cos);

            }
           
            Console.WriteLine(ans);
                
        }
    }

Measured memory_bytes: 13140
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
q,h,s,d = readInts()
n = I()
q = 4*q
h = 2*h
print(min(n*q,n*h,n*s,(n//2)*d + (n-(n//2)*2)*min(q,h,s)))


Measured memory_bytes: 10460
K, X = map(int, input().split())

ans = []
for i in range(X - K + 1, X + K):
  ans.append(i)

N = len(ans)
for i in range(N):
  print(ans[i], end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < 3; i++){
      list.add(sc.nextInt());
    }
    Collections.sort(list);
    System.out.println(list.get(0) + list.get(1));
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  multiset<int> s;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    auto it = s.lower_bound(x);
    if (it != s.begin()) {
      --it;
      s.erase(it);
    }
    s.insert(x);
  }
  printf("%d\n", int(s.size()));
  return 0;
}



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

int main(){
  string s,t; cin >> s >> t;
  string ss="",tt="";
  for(int i=(int)('a'); i<=(int)('z'); i++){
    for(int j=0; j<s.size(); j++){
      if(s[j]==(char)(i)){
        ss.push_back((char)(i));
      }
    }
    for(int j=0; j<t.size(); j++){
      if(t[j]==(char)(i)){
        tt.insert(tt.begin(),(char)(i));
      }
    }
  }
  cout << (ss<tt?"Yes":"No") << endl;
}

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


int main() {
    string s;
    cin >>s;
    if(s[0]!=s[1]){
        if((s[0]==s[2]&&s[1]==s[3])||(s[0]==s[3]&&s[1]==s[2])){
            cout << "Yes" <<endl;
        }else{
            cout << "No" <<endl;
        }
    }else{
        if(s[2]==s[3]&&s[1]!=s[2]){
            cout << "Yes" <<endl;
        }else{
            cout << "No" <<endl;
        }
    }
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 R, G, B, N;
    cin >> R >> G >> B >> N;
    i64 sum = 0;
    for (i64 i = 0; i <= N; i++) {
        for (i64 j = 0; j <= N; j++) {
            if (N - i * R - j * G < 0) break;
            if ((N - i * R - j * G) % B == 0) sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> bit(60, 0);
    rep(i, n) {
        rep(j, sz(bit)) {
            if ((a[i] & (1LL << j)) != 0) {
                bit[j]++;
            }
        }
    }
    ll ans = 0;
    vector<ll> cb(60, 0);
    rep(i, n) {
        rep(j, sz(bit)) {
            ll cnt = bit[j] - cb[j];
            ll val = 1LL << j;
            if ((a[i] & val) != 0) {
                cb[j]++;
                cnt = n - i - cnt;
            }
            val %= mod;
            ans = (ans + cnt * val) % mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <set>
using namespace std;
long long dp[100010],mod = 1000000007;
set<int> s;
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=0;i<m;i++){
		int a; cin >> a;
		s.insert(a);
	}
	dp[0] = 1;
	for(i=0;i<=n;i++){
		if(s.count(i)) dp[i] = 0;
		(dp[i+1] += dp[i]) %= mod;
		(dp[i+2] += dp[i]) %= mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func parseToArray2d(linesStr string) [][]int {
	var result [][]int
	for _, line := range strings.Split(linesStr, `\n`) {
		var parsedLine []int
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.Atoi(element)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func max(l, r int) int {
	if l > r {
		return l
	}
	return r
}

// https://yourbasic.org/golang/round-float-to-int/#before-go-1-10
func round(x float64) float64 {
	t := math.Trunc(x)
	if math.Abs(x-t) >= 0.5 {
		return t + math.Copysign(1, x)
	}
	return t
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var content string
	// 複数行の扱いがうまくいってない気がする。いまテストケースが複数行を一括で与える場合しか考慮していないので
	for scanner.Scan() {
		line := scanner.Text()
		content = content + line
	}
	arr := parseToArray2d(content)
	input := arr[0]

	width := input[0]
	height := input[1]
	x := input[2]
	y := input[3]
	r := input[4]

	var result string
	if x >= r && y >= r && x <= width-r && y <= height-r {
		result = "Yes"
	} else {
		result = "No"
	}

	fmt.Println(result)

	return
}



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

int main() {
    string str;cin>>str;
    
    cout<<"2018/01/";
    if(str[8]=='0')cout<<'0';
  else cout<<str[8];
    if(str[9]=='0')cout<<'0'<<endl;
  else cout<<str[9]<<endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  int X = B / 4;
  int D = B % 2;
  int E = B / 2;
  if ( D == 1 ) {
    cout << "No" <<endl;
  }
  else if ( A > E ) {
    cout << "No" <<endl;
  }
  else if ( A * 4 >= B ) {
    cout << "Yes" <<endl;
  }
  else if ( ( A - 1 ) * 4 + 2 >= B ) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int Z = Y/1000 - N;
        int a;
        int b = 0;
        int c;
        while(true) {
            int x = Z - 4*b;

            if (b >= 2000 || x < 0) {
                a = -1;
                b = -1;
                c = -1;
                break;
            }

            if(x % 9 == 0) {
                a = x / 9;
                c = N - a - b;
                if (c >= 0) {
                    break;
                }
            }
            b += 1;
        }
        System.out.print(a);
        System.out.print(' ');
        System.out.print(b);
        System.out.print(' ');
        System.out.print(c);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  int cur = 0;
  int ans = 0;
  rep(i, 0, N) {
    int a; cin >> a;
    if(cur <= a) {
      ans++;
      cur = a;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)
 

def maxProfit(prices) -> int:
    if len(prices) < 2:
        return 0
    ans = 1000
    for i in range(1,len(prices)):
        if prices[i] > prices[i - 1]:
            stock = ans // prices[i - 1]
            ans += stock * (prices[i] - prices[i - 1]) 
    return ans

def main():
    n = int(input().strip())
    A = [int(i) for i in input().strip().split()]

    ans = maxProfit(A)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int mod = 1000000007;

int pow3(int n){
    int a = 1;
    REP(i, n) a = (a * 3) % mod;
    return a;
}

signed main(){

    string S; cin >> S;
    int N = S.size();

    int abc = 0, qbc = 0, aqc = 0, abq = 0, aqq = 0, qbq = 0, qqc = 0, qqq = 0;
    vec a(N + 1, 0), b(N + 1, 0), c(N + 1, 0), q(N + 1, 0);

    REP(i, N){
        if(S[i] == 'A'){
            a[i + 1] = a[i] + 1;
        }else{
            a[i + 1] = a[i];
        }
        if(S[i] == 'B'){
            b[i + 1] = b[i] + 1;
        }else{
            b[i + 1] = b[i];
        }
        if(S[i] == 'C'){
            c[i + 1] = c[i] + 1;
        }else{
            c[i + 1] = c[i];
        }
        if(S[i] == '?'){
            q[i + 1] = q[i] + 1;
        }else{
            q[i + 1] = q[i];
        }
    } 
    FOR(i, 1, N - 1){
        if(S[i] == 'B'){
            abc += a[i] * (c[N] - c[i + 1]);
            qbc += q[i] * (c[N] - c[i + 1]);
            abq += a[i] * (q[N] - q[i + 1]);
            qbq += q[i] * (q[N] - q[i + 1]);
            abc %= mod;
            qbc %= mod;
            abq %= mod;
            qbq %= mod;
        }
        if(S[i] == '?'){
            aqc += a[i] * (c[N] - c[i + 1]);
            qqc += q[i] * (c[N] - c[i + 1]);
            aqq += a[i] * (q[N] - q[i + 1]);
            qqq += q[i] * (q[N] - q[i + 1]);
            aqc %= mod;
            qqc %= mod;
            aqq %= mod;
            qqq %= mod;
        }
    }

    abc = (abc * pow3(q[N])) % mod;
    qbc = (qbc * pow3(q[N] - 1)) % mod;
    aqc = (aqc * pow3(q[N] - 1)) % mod;
    abq = (abq * pow3(q[N] - 1)) % mod;
    qqc = (qqc * pow3(q[N] - 2)) % mod;
    aqq = (aqq * pow3(q[N] - 2)) % mod;
    qbq = (qbq * pow3(q[N] - 2)) % mod;
    qqq = (qqq * pow3(q[N] - 3)) % mod;

    int ans = (abc + qbc + aqc + abq + aqq + qbq + qqc + qqq) % mod;

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int x3, y3, x4, y4;
    x3 = x2 + y1 - y2;
    y3 = y2 + x2 - x1;
    x4 = x3 + y2 - y3;
    y4 = y3 - x2 + x3;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	long long n;
	long long w, x, y, z;
	bool v = true;
	scanf("%lld %lld %lld", &n, &x, &y);
	if ((x + y) >(n + 1))v = false;
	if ((x*y) < n)v = false;
	if (v){
		z = 0;
		for (long long i = 0; i < x; i++){
			if ((z + x - i) == n){
				printf("%d", z + 1);
				z++;
				if (i == (x - 1))printf("\n");
				else printf(" ");
			}
			else if ((z + y + x - i - 1)>n){
				w = n  - x + i;
				for (long long j = w; j >= z; j--){
					printf("%lld", j + 1);
					if (i == (x - 1) && j == z)printf("\n");
					else printf(" ");
				}
				z = w + 1;
			}
			else{
				w = z + y - 1;
				for (long long j = w; j >= z; j--){
					printf("%lld", j + 1);
					if (i == (x - 1) && j == z)printf("\n");
					else printf(" ");
				}
				z = w + 1;
			}

		}

	}
	else printf("-1\n");


	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;
#define N 100010
int main(){
  int n,m,h[N],ma[N];
  cin >> n >> m;
  for(int i = 1; i <= n; ++i){
    cin >> h[i];
    ma[i] = 0;
  }
  for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a],h[b]);
    ma[b] = max(ma[b],h[a]);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    ans += (h[i] > ma[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4400
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll s[12345678];
ll v[12345678];
ll keta(ll a){
    ll res = 0;
    while(a){
        res += a%10;
        a/=10;
    }
    return res;
}
bool comp(ll a,ll b){
    ll ka = keta(a);
    ll kb = keta(b);
    if(a*kb == b*ka)return a<b;
    else return a*kb<b*ka;
}
int main(){
    ll ten[17];
    ten[0] = 1;
    rep(i,16)ten[i+1] = ten[i]*10;
    vector<ll>ans;
    rep(i,17){
        rep(j,999){
            if((j+1)*ten[i]>1e15)break;
            ans.push_back((ll)(j+1)*ten[i]-1);
        }
    }
    sort(ans.begin(),ans.end(),comp);
    vector<ll>a;
    ll ma = 0;
    for(ll x:ans){
        if(ma<x)a.push_back(x);
        ma = max(x,ma);
    }
    int k;
    cin >> k;
    rep(i,k)cout << a[i] << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main(){
  int n, d;
  cin >> n >> d;

  vvi x(n, vi(d));
  rep(i, 0, n) rep(j, 0, d) cin >> x[i][j];

  int ans = 0;
  rep(i, 0, n) rep(j, i+1, n){
    int sum = 0;
    rep(k, 0, d){
      sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    }
    int dist = sqrt(sum);
    if(sum%dist == 0 and (double)sum/dist == dist){
      ans++;
    }
  }

  cout << ans << 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
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)}; 


////////////////////////////////////////////////////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll COM(int n, int k){
  if(n < k)return 0;
  if(n < 0 || k < 0)return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

int n,k;
signed main(){
  cin>>n>>k;
  COMinit();
  int ans = COM(2*n-1, n);
  if(k >= n-1){
    cout << ans << endl;
    return 0;
  }
  repd(i,k+1,n){
    ans += (MOD-COM(n-1, n-i-1)*COM(n, i)%MOD);
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 117504
from functools import lru_cache
N = int(input())
K = int(input())
@lru_cache(None)
def f(n,k):
  if k<0:
    return 0
  if n<10:
    if k>1:
      return 0
    elif k==1:
      return n
    elif k==0:
      return 1
  a, b = divmod(n,10)
  m = 9*f(a-1,k-1)+f(a,k)+b*(f(a,k-1)-f(a-1,k-1))
  return m
print(f(N,K))

Measured memory_bytes: 3936
def pow_mod(x, y):
    MOD = 1000000007
    if y == 0: return 1
    ans = 1
    while y > 1:
        if y % 2 != 0: 
            ans *= x
            ans %= MOD
        x *= x
        x %= MOD
        y //= 2
    return ans * x % MOD

def main():
  MOD = 1000000007
  r1, c1, r2, c2 = map(int, input().split()) 

  points = {r2 + c2 + 2, r2 + 1, c2 + 1, r2 + c1 + 1, c1, r1 + c2 + 1, r1, r1 + c1}

  factorial_map = {0: 1}
  for i in range(1, r2 + c2 + 3):
    factorial_map[i] = (factorial_map[i - 1] * i) % MOD
    if i > 1 and (i - 2) not in points:
      del factorial_map[i-2]

  a = 1
  a *= factorial_map[r2 + c2 + 2]
  a %= MOD
  a *= pow_mod(factorial_map[r2 + 1], MOD - 2)
  a %= MOD
  a *= pow_mod(factorial_map[c2 + 1], MOD - 2)
  a %= MOD

  b = 1
  b *= factorial_map[r2 + c1 + 1]
  b %= MOD
  b *= pow_mod(factorial_map[r2 + 1], MOD - 2)
  b %= MOD
  b *= pow_mod(factorial_map[c1], MOD - 2)
  b %= MOD

  c = 1
  c *= factorial_map[r1 + c2 + 1]
  c %= MOD
  c *= pow_mod(factorial_map[r1], MOD - 2)
  c %= MOD
  c *= pow_mod(factorial_map[c2 + 1], MOD - 2)
  c %= MOD

  d = 1
  d *= factorial_map[r1 + c1]
  d %= MOD
  d *= pow_mod(factorial_map[r1], MOD - 2)
  d %= MOD
  d *= pow_mod(factorial_map[c1], MOD - 2)
  d %= MOD

  ans = a
  ans -= b
  ans %= MOD
  ans -= c 
  ans %= MOD
  ans += d
  ans %= MOD

  print(ans)


if __name__ == "__main__":
  main()

Measured memory_bytes: 40172