akhauriyash/Code-Regression huggingface dataset:
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#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 int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define N 400005

void Weapons19(){
    int n;cin>>n;
    map<int,int>m;
    for(int i=2;i<=n;i++){
        int x;cin>>x;
        m[x]++;
    }
    for(int i=1;i<=n;i++)cout<<m[i]<<"\n";








}   

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    

    Weapons19();
    
}


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

int main() {
  int count=0;
  int N;
  string S;
  cin>>S;
  rep(i,S.length()-1){
    if(S[i]==S[i+1]){
      count++;
      if(S[i]=='0')
        S[i+1]='1';
      else
        S[i+1]='0';
    }
  }
  cout<<min(count,(int)S.length()-count);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;		
	int n,m;
	cin>>n>>m;
	int tot=0;
	int a[n]={0};
	int b[n]={0};
	si S;
	for(int i=0;i<m;i++){
		int x; string s;
		cin>>x>>s;
		if(s=="AC"){
			if(S.find(x)==S.end())
			{	
				tot++;
				S.insert(x);
				a[x-1]=b[x-1];
			}
		}
		else b[x-1]++;
	}
	int tot2=0;
	for(int i=0;i<n;i++){
		tot2+=a[i];
	}
	cout<<tot<<" "<<tot2<<endl;
}

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

int main() {
string S;
  cin>>S;
  int R=0;
  if(S[0]=='1'){
    R=R+1;
  }
  if(S[1]=='1'){
    R=R+1;
  }
  if(S[2]=='1'){
    R=R+1;
  }
  cout <<R;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s; cin >> s;

    string sr = s;
    reverse(sr.begin(), sr.end());

    string cand[] = {"dream", "dreamer", "erase", "eraser"};
    for(int i=0; i<4; i++){
        reverse(cand[i].begin(), cand[i].end());
    }

    bool flag = true;
    while(flag){
        flag = false;
        for(int i=0; i<4; i++){
            if(sr.substr(0, cand[i].size()) == cand[i]){
                sr = sr.substr(cand[i].size());
                flag = true;
            }
        }
    }

    if(sr.size() == 0){
        cout << "YES";
    }
    else{
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 696
#include<stdio.h>

int d[15],i,j;
char s[15];

int main(){
	while(scanf("%s",s)!=EOF){
		for(i=0;i<10;i++)d[i]=s[i]-'0';
		for(i=10;i>0;i--){
			for(j=0;j<i-1;j++){
				d[j]=(d[j]+d[j+1])%10;
			}
		}
		printf("%d\n",d[0]);
	}
	
	return 0;
}

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


int main(){
	
	int n;cin>>n;
	vector<int> height(n);
	for(int i=0;i<n;i++){
		cin>>height[i];
	}
	vector<int> dp(n);
	dp[1] = abs(height[0] - height[1]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(height[i-1] - height[i]), dp[i-2] + abs(height[i-2] - height[i]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
cost = 0
if N == 1:
    print(0)
    exit()
for i in range(1,N):
    if A[i-1] > A[i]:
        cost += A[i-1] - A[i]
        A[i] = A[i-1]
print(cost)

Measured memory_bytes: 32124
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> b(n-1);
    int i;
    ll sum=0;
    for(i=0; i<n-1; i++) {
        scanf("%d", &b[i]);
    }
    for(i=0; i<n; i++) {
        if(i==0) sum+=b[0];
        else if(i==n-1) sum+=b[n-2];
        else sum+=MIN(b[i],b[i-1]);
    }
    printf("%lld\n", sum);


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc,char const *argv[]) {
    int x,a,b;
    cin>>x>>a>>b;
    int k=abs(x-a);
    int l=abs(x-b);
    if(k<l) {
        cout<<"A"<<endl;
    }
    else cout<<"B"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long A, long long B){
    for(ll x = 1; x < 1200; ++x){
        if(A + x != x * 108 / 100){ continue; }
        if(B + x != x * 110 / 100){ continue; }
        cout << x << endl;
        return;
    }
    cout << -1 << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct segtree{
    static const int SEG=1<<18;
    vint put;
    segtree():put(SEG*2){}
    void add(int a,int b,int x,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            put[k]+=x;
            return;
        }
        add(a,b,x,k*2+1,l,(l+r)/2);
        add(a,b,x,k*2+2,(l+r)/2,r);
    }
    int query(int k){
        k+=SEG-1;
        int ret=0;
        while(true){
            ret+=put[k];
            if(k==0)break;
            k=(k-1)/2;
        }
        return ret;
    }
};

signed main(){
    int N,Q;
    scanf("%lld%lld",&N,&Q);

    segtree segX,segY;
    rep(i,N)segX.add(i,i+1,2*i+1);


    vector<tuple<int,int,int>>qs;
    rep(i,Q){
        int x,d,l;
        scanf("%lld%lld%lld",&x,&d,&l);
        x*=2;
        qs.pb(make_tuple(x,d,l));
    }
    for(int i=Q-1;i>=0;i--){
        int x,d,l;
        tie(x,d,l)=qs[i];
        if(d==1){
            int lb=-1,ub=N;
            while(ub-lb>1){
                int mid=(ub+lb)/2;
                int xx=segX.query(mid);

                int yy=segY.query(mid);
                if(-(x-xx)<yy*2)lb=mid;
                else ub=mid;
            }
            segX.add(0,ub,-2*l);
            segY.add(0,ub,-l);
        }
        else{
            int lb=-1,ub=N;
            while(ub-lb>1){
                int mid=(ub+lb)/2;

                int xx=segX.query(mid);
                int yy=segY.query(mid);
                if(-(xx-x)<yy*2)ub=mid;
                else lb=mid;
            }
            segX.add(ub,N,2*l);
            segY.add(ub,N,-l);
        }
    }

    rep(i,N){
        int y=segY.query(i);
        printf("%lld\n",-y);
    }
    return 0;
}




Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll lg=31;
const ll N=1e5+5;
const ll INF=3e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define f first
#define s second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repp(i, a, b) for(int i = a; i > (b); --i)
#define sz(x) (int)(x).size()
#define pb push_back
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main() {
	FASTIO;
	string s, t;
	cin >> s >> t;
	ll maxc = 0;
	for (int i = 0; i <= sz(s) - sz(t); i++) {
	    ll c = 0;
	    for (int j = 0; j < sz(t); j++) {
	        if (s[i + j] == t[j]) {
	            c++;
	        }
	    }
	    maxc = max(maxc, c);
	}
	cout << (sz(t) - maxc) << endl;
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  k--;
  s[k] = s[k] - 'A' + 'a';
  cout << s << endl;
}


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

int main(){
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<ll> a(X),b(Y),c(Z);

    rep(i,X)cin>>a[i];sort(a.begin(),a.end(),greater<ll>());
    rep(i,Y)cin>>b[i];sort(b.begin(),b.end(),greater<ll>());
    rep(i,Z)cin>>c[i];sort(c.begin(),c.end(),greater<ll>());

    vector <ll> vec;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            for(int k =0;k<Z;k++){
                if((i+1)*(j+1)*(k+1)<=K)vec.push_back(a[i]+b[j]+c[k]);
                else break;
            }
        }
    }
    sort(vec.begin(),vec.end(),greater<ll>());
    for(int i=0;i<K;i++){
        cout<<vec[i]<<endl;
    }
}

Measured memory_bytes: 1404
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

vector<int> d(101, -1);
vector<vector<int> > c(101, vector<int>(101, 0));

int n, u, k, v;
typedef pair<int, int> P; 
int bfs(void) {
    queue<P> que;
    que.push(P(0, 0));
    while(que.size()>0) {
        P p = que.front(); que.pop();
        if(d[p.first]==-1) d[p.first] = p.second;
        for(int i=0; i<n; ++i) {
            if(c[p.first][i]==1 && d[i]==-1) que.push(P(i, d[p.first]+1));
        }
    }
}

int main() {
    cin >> n;
    for(int i=0; i<n; ++i) {
        cin >> u >> k;
        for(int j=0; j<k; ++j) {
            cin >> v;
            c[i][v-1] = 1;
        }
    }
    bfs();
    for(int i=0; i<n; ++i) {
        cout << i+1 << " " << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}
long long getKey(char str[]){
  long long sum=0,p=1;
  for(int i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    } 
  }
  return 0;
}

int main (){
  int i, n,h;
  char str[L],com[9];
  for(int i=0;i<M;i++) H[i][0]= '\0';
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> com >> str;
    if(com[0]=='i'){
      insert(str);
    } else{
      if(find(str)){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
  }
  return 0;
}


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

struct SuffixAutomaton {
    SuffixAutomaton(int n): last(0), succeed(1, std::vector<int>(ALPHA, -1)), fail(1, -1), length(1, 0) {
        succeed.reserve(n + n);
        length.reserve(n + n);
        fail.reserve(n + n);
    };
    int size() { return succeed.size(); }
    void extend(char ch) {
        int c = ch - 'a';
        int p = last, np = last = size();
        length.push_back(length[p] + 1);
        succeed.emplace_back(ALPHA, -1);
        fail.push_back(0);
        while (p != -1 && succeed[p][c] == -1)
            succeed[p][c] = np, p = fail[p];
        if (p == -1) return;
        int q = succeed[p][c];
        if (length[q] == length[p] + 1)
            fail[np] = q;
        else {
            int nq = size();
            length.push_back(length[p] + 1);
            succeed.push_back(succeed[q]);
            fail.push_back(fail[q]);
            fail[np] = fail[q] = nq;
            while (p != -1 && succeed[p][c] == q)
                succeed[p][c] = nq, p = fail[p];
        }
    }
    std::string nth_substring(int n) {
        std::vector<int> sub_size(size(), 1);
        std::vector<int> order = get_order();
        for (int i = (int)order.size() - 1; 0 <= i; i--) {
            int u = order[i];
            for (int v : succeed[u]) {
                if (0 <= v) sub_size[u] += sub_size[v];
            }
        }
        int pointer = 0;
        std::string result;
        while (n != 0) {
            for (int i = 0; i < ALPHA; i++) {
                if (succeed[pointer][i] < 0) continue;
                int next = succeed[pointer][i];
                if (sub_size[next] < n)
                    n -= sub_size[next];
                else {
                    result.push_back(i + 'a');
                    pointer = next;
                    n--;
                    break;
                }
            }
        }
        return result;
    }
    std::vector<int> get_order() {
        std::vector<int> order(size()), sum(length[last] + 1);
        for (int i = 0; i < size(); i++)
            sum[length[i]]++;
        std::partial_sum(sum.begin(), sum.end(), sum.begin());
        for (int i = 0; i < size(); i++)
            order[--sum[length[i]]] = i;
        return std::move(order);
    }
private:
    int last;
    const int ALPHA = 26;
    std::vector<std::vector<int>> succeed;
    std::vector<int> fail, length;
};

int main() {
    std::string s;
    int n;
    std::cin >> s >> n;
    SuffixAutomaton sam(s.size());
    for (char ch : s)
        sam.extend(ch);
    std::cout << sam.nth_substring(n) << "\n";
    return 0;
}


Measured memory_bytes: 1152
def main():

    A, B = map(int, input().split())
    grid = []
    for _ in range(50):
        grid.append(["#" for _ in range(100)])
    for _ in range(50):
        grid.append(["." for _ in range(100)])

    count1 = 0
    for i in range(0, 50, 3):
        for j in range(0, 100, 3):
            if count1 < A-1:
                grid[i][j] = "."
                count1 += 1
            if count1 == A-1:
                break
    count2 = 0
    for i in range(51, 100, 3):
        for j in range(0, 100, 3):
            if count2 < B-1:
                grid[i][j] = "#"
                count2 += 1
            if count2 == B-1:
                break

    print("100 100")
    for i in range(100):
        print("".join(grid[i]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int A[101][101]={0};
  for(int i=0;i<a;i++){
      for(int j = 0; j <b;j++){
          cin >> A[i][j];
        A[i][b] += A[i][j];
        A[a][j] += A[i][j];
        A[a][b] += A[i][j];
      }
  }
 
  for(int i = 0; i<=a;i++){
    for(int j = 0; j<=b;j++){ 
      cout <<A[i][j]  ;
      if(j != b)cout<< ' ';
    }
    cout << endl;
  }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

ll dp[110][2][110];

void solve() {
    int k, n;
    string s;
    cin >> s >> k;
    n = s.size();
    dp[0][0][0] = 1;
    rep(i, n) {
        int D = s[i]-'0';
        rep(j, 2) {
            rep(x, 105) {
                rep(d, (j ? 10 : D + 1)) {
                    dp[i + 1][j || d < D][x + (d == 0)] += dp[i][j][x];
                }
            }
        }
    }
    cout << dp[n][0][n-k] + dp[n][1][n-k] << endl;
    return;
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define ff first
#define ss second 
#define pb push_back
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Craig ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015
#define vll vector<ll>

int main()
{   
    ll n,m,i,j,k,mx=999999999999;
    string s1,s2;
    cin>>s1>>s2;
    n=s1.length();
    m=s2.length();
    for(i=0;i<=n-m;i++)
    {
        k=0;
        for(j=0;j<m;j++)
        {

            if(s2[j]!=s1[i+j])
                k++;
            //cout<<k;
        }
        if(mx>k)mx=k;
    }
    if(mx>k)mx=k;
    cout<<mx<<endl;
}

Measured memory_bytes: 3628
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(ll(0), a + b - n) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count=0;
        for (int i=1;i<n+1;i++){
            if (search(i)==8&&i%2==1){
                count++;
            }
        }
        System.out.println(count);
    }
    public static long search(long num){
        ArrayList<Long> ff = new ArrayList<Long>();
        for (long i = 2; i <= num; i++) {
            if (num % i == 0) {
                num /= i;
                ff.add(i);
                i = 1;
            }
        }
        ArrayList<Long> dd = new ArrayList<Long>();
        dd = (ArrayList<Long>) ff.clone();
        ArrayList<Long> ee = new ArrayList<Long>(new LinkedHashSet<>(dd));
        long[] d = new long[ee.size()];
        for (long g:d){
            g = 0;
        }
        for (int i = 0;i < ee.size();i++){
            for (long k:dd){
                if (ee.get(i) == k){
                    d[i]++;
                }
            }
        }
        long ans = 1;
        for (int i = 0;i < d.length;i++){
            ans = ans * (d[i]+1);
        }
        return ans;
    }
}

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sum=0;
//    int x=s.length();
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') sum++;
    }
    cout<<sum<<endl;
    return 0;
}


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

#define int long long
#define pb push_back
#define F first
#define S second
#define MAX 10000000
#define MOD 1000000007

typedef pair<int, int> PII;

signed main(){
    int N, M;
    cin>>N>>M;
    char arr[N][M];
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin>>arr[i][j];
        }
    }
    //cout<<"hre"<<endl;
    int dp[N][M];
    bool check = false;
    for(int i=0; i<N; i++){
        if(arr[i][0] == '#') check = true;
        if(check) dp[i][0] = 0;
        else dp[i][0] = 1;
    }
    check = false;
    for(int i=0; i<M; i++){
        if(arr[0][i] == '#') check = true;
        if(check) dp[0][i] = 0;
        else dp[0][i] = 1;
    }

    for(int i=1; i<N; i++){
        for(int j=1; j<M; j++){
            if(arr[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
        }
    }
    cout<<dp[N-1][M-1]<<endl;
    return 0;
}

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

int main() {
  int h,w;
  cin>>h>>w;

  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      if(i==0 || i==h+1 || j==0 || j==w+1){
        cout<<'#';
      }else{
        char s;
        cin>>s;
        cout<<s;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
from functools import reduce

N = int(input())
H = list(map(int, input().split()))

# 先頭から順に、可能な限りマスの高さを低くする戦略により、単調非減少にできるか判定
ans, _ = reduce(
    lambda acc, h: (
        (
            'Yes' if acc[0] == 'Yes' and acc[1] <= h else
            'No'
        ),
        h if acc[1] >= h else
        h - 1
    ),
    H,
    ('Yes', 0)
)

print(ans)


Measured memory_bytes: 14612
#include "stdio.h"
#include "iostream"
using namespace std;
#include <deque>
deque <int> input;

int main(void)
{
	int N,i;
	int temp;
	int ret = 0;
	int min = 0;
	int max = 0;
	cin >> N;
	int pos1 = 0, pos2 = 0;
	for (i = 0; i < N; i++)
	{
		cin >> temp;
		input.push_back(temp);
	}
	min = input[0];
	max = input[0];
	for (i = 0; i < N; i++)
	{
/*		if (min >= input[N-1-i])
		{
			min = input[i];
			pos1 = i;
		}*/
		if (max < input[i])
		{
			max = input[i];
			pos2 = i;
		}
		if ((input[i] < (max - 1)))
		{
			cout << "No";
			return 0;
		}
	}
    cout << "Yes";
	return 0;
}

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

void gg(int &a, int &b, int c, int d) {
  a = c;
  b = d;
}

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2 - x1, dy = y2 - y1;

  gg(dx, dy, -dy, +dx);
  int x3 = x2 + dx, y3 = y2 + dy;
  gg(dx, dy, -dy, +dx);
  int x4 = x3 + dx, y4 = y3 + dy;
  // +y, -x
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

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

#include <string>
#include <vector>
#include <algorithm>


int main()
{
	int a;
	cin >> a;

	vector< int > vec( a );

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

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


	int cnt = 0;


	for( int i=0 ; i<a ; i++ )
	{
		for( int ii=i+1 ; ii<a ; ii++ )
		{
			int j1 = vec[i] + vec[ii];

			for( int iii=ii+1 ; iii<a ; iii++ )
			{
				if( vec[iii] < j1 )
				{
					cnt++;
				}
				else break;
			}
		}
	}




	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
# %% constants & libraries
# ------------------------

# %% body
# -------

function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))::Vector{T}

    # handle IO and and stuff
    s = readto()
    println(
        sum(parse(Int, c) for c in s) % 9 === 0 ?
        "Yes" : "No"
    )
end

function solve()
    # ...
end

@static if @isdefined(Juno) || @isdefined(VSCodeServer)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


Measured memory_bytes: 191000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  int n, m, k;
  cin >> n >> m >> k;

  map<int, bool> mp;
  rep(i, n + 1) {
    rep(j, m + 1) {
      mp[i * m + j * n - 2 * i * j] = true;
    }
  }
  cout << (mp[k] ? "Yes" : "No") << endl;




  
  return 0;
}

Measured memory_bytes: 13056
# Author: cr4zjh0bp
# Created: Fri Mar 13 19:30:22 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self._size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self._size[y] += self._size[x]
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self._size[x] += self._size[y]
    
    def size(self, x):
        x = self.find(x)
        return self._size[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

n, m, k = na()
ab = nan(m)
cd = nan(k)

friend = defaultdict(int)
uf = UnionFind(n)

for i in range(m):
    a, b = ab[i]
    a -= 1
    b -= 1
    uf.unite(a, b)
    friend[a] += 1
    friend[b] += 1

block = defaultdict(list)
for i in range(k):
    c, d = cd[i]
    c -= 1
    d -= 1
    block[c].append(d)
    block[d].append(c)
ans = []
for i in range(n):
    bf = 0
    for j in block[i]:
        if uf.same(i, j):
            bf += 1
    ans.append(uf.size(i) - friend[i] - bf - 1)

print(*ans)

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

int main(){
    int N, R, res;

    cin >> N >> R;

    if(N >= 10){
        res = R;
    } else {
        res = R + 100 * (10 - N);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_N 10000
int N, K;
bool D[10];

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

	cin >> N >> K;
	memset(D, false, sizeof(D));
	rep(i, 0, K) {
		int d;
		cin >> d;
		D[d] = true;
	}

	for(int i = N; i <= 10 * N; i++) {
		int flag = true;
		string s = to_string(i);
		rep(j, 0, s.size()) {
			if(D[s[j] - '0']) {
				flag = false;
				break;
			}
		}
		if(flag) {
			cout << i << endl;
			return 0;
		}
	}


			

		
}


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

int main(){
	int n;
	int a[10000];
	long long int max = -1000000, min = 1000000, sum = 0;
	cin >> n;
	for (int i = 0; i <n;i++){
		cin >> a[i];
		if (a[i]>max) max = a[i];
		if (a[i]<min) min = a[i];
		sum += a[i];
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1200
# NOTE: 1-origin (not 0-origin)
$adj_lists = []

$cache= {}

# $queue = []

def find_min_dist(start_node, target_node)

  queue = []

  queue.push([start_node, 0])

  # min_dis = Float::INFINITY
  dis = 0
  while (n, d = queue.shift)
    if n == target_node
      return d
    else
    nodes = $adj_lists[n]
    nodes.each{|node|
      queue.push([node, dis])
    }
    dis += 1

    $cache[[start_node, target_node]] = dis

  end

  # $cache[[start_node, target_node]] = min_dis

  # return min_dis + 1

  # mins = nodes.map{|n|
  #
  # }
  # dis = mins.min + 1
  # $cache[[start_node, target_node]] = dis
  # return dis
  end

end

_ = gets


while line = gets
  i, _, *nodes= line.split(' ').map(&:to_i)
  $adj_lists[i] = nodes
end

# # NOTE: 1-origin
# distances = [nil] * $adj_lists.size
#
# distances[1] = 0
#
# # (1..$adj_lists.size).each{|i|
# #
# # }
#
# # p $adj_lists
#
#

# Node => min dist
node_to_min_dist_hash = {}

def find(start_node, target_node)
  open_list   = [[start_node, 0]]
  closed_list = []

  while open_list.size != 0
    node, dist = open_list.shift
    if node == target_node
      # puts("Found #{node}, #{target_node}: dist #{dist}")
      return dist
    end
    # puts(node)
    nodes = $adj_lists[node]
    nodes.each{|n|
      open_list.push([n, dist+1])
    }
    closed_list.push(node)
  end

  return -1
end



def find_all(start_node)
  # Node => min dist
  node_to_min_dist_hash = Hash.new(-1)

  open_list   = [[start_node, 0]]
  closed_list = []

  while open_list.size != 0
    node, dist = open_list.shift

    if closed_list.include?(node)
      next
    end

    # if node == target_node
    #   # puts("Found #{node}, #{target_node}: dist #{dist}")
    #   return dist
    # end

    if !node_to_min_dist_hash.has_key?(node)
      node_to_min_dist_hash[node] = dist
    end

    # puts(node)
    nodes = $adj_lists[node]
    nodes.each{|n|
      open_list.push([n, dist+1])
    }
    closed_list.push(node)
  end

  return node_to_min_dist_hash
end

# # Print
# (1...$adj_lists.size).each{|target_node|
#   min_dist = find(1, target_node)
#   puts("#{target_node} #{min_dist}")
# }
#

node_to_min_dist_hash = find_all(1)

# Print
(1...$adj_lists.size).each{|target_node|
  min_dist = node_to_min_dist_hash[target_node]
  puts("#{target_node} #{min_dist}")
}

# p find_node(1, 2)
# p find_node(1, 3)
# p find_node(1, 4)
#
# # p distances



Measured memory_bytes: 6888
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 200000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, A[MAX_N], B[MAX_N];

void solve() {
  if (N % 2 == 0) {
    for (int i = 0; i < N / 2; i++) {
      B[i] = A[N - 2 * i - 1];
    }
    for (int i = 0; i < N / 2; i++) {
      B[i + N / 2] = A[2 * i];
    }
  } else {
    for (int i = 0; i < N / 2 + 1; i++) {
      B[i] = A[N - 2 * i - 1];
    }
    for (int i = 0; i < N / 2; i++) {
      B[i + N / 2 + 1] = A[2 * i + 1];
    }
  }

  for (int i = 0; i < N; i++) cout << B[i] << " ";
  cout << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	double cost;
};

typedef pair<double,int> P;
int V;

const int MAX_V = 5000;

vector<edge> G[MAX_V];
double d[MAX_V];
const int INF = 1000000000;

int prevv[MAX_V];

void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+MAX_V,INF);
	fill(prevv,prevv+MAX_V,-1);
	d[s] = 0.0;
	que.push(P(0.0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first)
			continue;
		for(int i = 0; i < G[v].size(); i++){
			if(v==6){
//				cout<<endl;
			}
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
				// »Ìm[hÖÌÅZ£oHðL^µÄ¨­
				prevv[e.to] = v;
			}
		}
	}
}

class Building{
public:
	int node;
	int x;
	int y;
};


int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<Building> vb;
		for(int i = 0; i < n; i++){
			Building b;
			cin>>b.node>>b.x>>b.y;
			vb.push_back(b);
		}
		// »ê¼êÌgÝí¹ÉÎµÄµç×é
		for(int i = 0; i < vb.size(); i++){
			for(int j = i+1; j < vb.size(); j++){
				int dist = (vb[i].x-vb[j].x)*(vb[i].x-vb[j].x)+(vb[i].y-vb[j].y)*(vb[i].y-vb[j].y);
				// rÔÌ£Ìñæª2500Èº¾Á½êAGbWðÞ·Ô
				if(dist<=2500){
					edge e;
					e.cost=sqrt((double)dist);
					e.to=vb[j].node;
					G[vb[i].node].push_back(e);

					//e.cost=dist;
					e.to=vb[i].node;
					G[vb[j].node].push_back(e);
				}
			}
		}

		//dijkstra(1);
		//cout<<d[22]<<endl;

		int m;
		cin>>m;
		for(int i = 0; i < m; i++){
			int s,g;
			cin>>s>>g;
			dijkstra(s);
			if(EQ(d[g],INF))
				cout<<"NA"<<endl;
			else{
			//	cout<<d[g]<<endl;
				vector<int> path;
				path.push_back(g);
				int cp=g;
				while(1){
					int np=prevv[cp];
					cp=np;
					path.push_back(cp);
					if(cp==s)
						break;
				}
				for(int j = 0; j < path.size(); j++){
					cout<<path[path.size()-1-j];
					if(j==path.size()-1)
						cout<<endl;
					else
						cout<<" ";
				}
			}
		}
		for(int i = 0; i < MAX_V; i++)
			G[i].clear();
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll x[100010];
ll y[100010];

vector<ll> pos, neg;

int main(){
    int n;
    cin >> n;
    rep(i, n){
        ll a;
        cin >> a;
        if (a >= 0) pos.push_back(a);
        else neg.push_back(a);
    }
    sort(pos.rbegin(), pos.rend());
    sort(neg.begin(), neg.end());

    if (neg.empty()) neg.push_back(pos.back()), pos.pop_back();
    if (pos.empty()) pos.push_back(neg.back()), neg.pop_back();

    vector<P> res;
    ll now = neg[0];
    for (int i = 0; i+1 < pos.size(); ++i) {
        res.push_back({now, pos[i]});
        now -= pos[i];
    }
    res.push_back({pos.back(), now});
    now = pos.back() - now;

    for (int i = 1; i < neg.size(); ++i) {
        res.push_back({now, neg[i]});
        now -= neg[i];
    }

    cout << now << endl;
    rep(i, n-1) cout << res[i].first << " " << res[i].second << endl;

    return 0;
}


Measured memory_bytes: 7216
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
if(input[0]===input[2]){

console.log(input[1])
}else if(input[0]==input[1]){

  console.log(input[2])
}else{
  console.log(input[0])
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int N;
int cnt[1<<20];
int all=0;
bool isp[1<<20];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		cnt[A]++;
		all=gcd(all,A);
	}
	bool ok=true;
	for(int i=2;i<1<<20;i++)
	{
		int sum=0;
		for(int j=i;j<1<<20;j+=i)sum+=cnt[j];
		if(sum>1)ok=false;
	}
	cout<<(ok?"pairwise coprime":all==1?"setwise coprime":"not coprime")<<endl;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  string s, t; cin >> s >> t;
  vector<set<int>> st(26);
  ll n = s.size();
  rep(i, n) {
    st[s[i]-'a'].insert(i+1);
  }
  ll loop = 0;
  int i = 0;
  for(auto c : t) {
    if(st[c-'a'].size() == 0) {
      cout << -1 << endl;
      return 0;
    }

    auto it = st[c-'a'].upper_bound(i);
    if(it != st[c-'a'].end()) i = *it;
    else {
      ++loop;
      i = *st[c-'a'].begin();
    }
  }
  ll ans = loop*n + i;
  cout << ans << endl;
}

Measured memory_bytes: 8508
#include <stdio.h>
#define Max 100000

int a[Max];
int partition(int,int);


int main(){
  int n,q;
  int i;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&a[i]);
  }
  q=partition(0,n-1);

  for(i=0; i < n; i++){
    if(i==q) printf("[");

      printf("%d",a[i]);

      if(i==q) printf("]");

      if(i != n-1) printf(" ");
  }
  printf("\n");

  return 0;
}

int partition(int p,int r){
  int x;
  int i,j;
  int s;

  x=a[r];
  i=p-1;
  for(j=p; j < r; j++){
    if(a[j]<= x){
      i++;
      s=a[i];
      a[i]=a[j];
      a[j]=s;
    }
  }
      s=a[i+1];
      a[i+1]=a[r];
      a[r]=s;
 
    return i+1;
  }

Measured memory_bytes: 992
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;

LL fun(LL n, LL m)//写个自定义函数配配对
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}

int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);//输出与换行
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int N, ans;
int cnt;
bool color[8];
int main(void) {
	cin >> N;
	FOR(i, 0, N) {
		int c = 0; cin >> c;
		if (c < 400)color[0] = true;
		else if (c < 800)color[1] = true;
		else if (c < 1200)color[2] = true;
		else if (c < 1600)color[3] = true;
		else if (c < 2000)color[4] = true;
		else if (c < 2400)color[5] = true;
		else if (c < 2800)color[6] = true;
		else if (c < 3200)color[7] = true;
		else if (c >= 3200)cnt++;
	}
	int kaunt = count(color, color + 8, true);
	cout <<max(kaunt,1)<<" "<< kaunt + cnt<<endl;
	
	return 0;
}

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

using namespace std;

int main() {
  bool res = true;
  int l;
  string S;

  cin >> S;
  l = S.length();

  for (int i = 0; i < l - 1; ++i) {
    for (int j = i + 1; j < l; ++j) {
      if (S[i] == S[j]) {
        res = false;
      }
    }
  }

  if (res) cout << "yes" << endl;
  else cout << "no" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<vector>
#include<string.h>
#define N 10000000
using namespace std;
int main()
{
    int a,b,maxp;
    scanf("%d %d",&a,&b);
    maxp=a+b;
    if(a-b>maxp)
        maxp=a-b;
    if(a*b>maxp)
        maxp=a*b;
    printf("%d\n",maxp);
    return 0;
}

Measured memory_bytes: 256
x = int(input())

if x >= 400 and x <= 599:
    print(8)
elif x >= 600 and x <= 799:
    print(7)
elif x >= 800 and x <= 999:
    print(6)
elif x >= 1000 and x <= 1199:
    print(5)
elif x >= 1200 and x <= 1399:
    print(4)
elif x >= 1400 and x <= 1599:
    print(3)
elif x >= 1600 and x <= 1799:
    print(2)
elif x >= 1800 and x <= 1999:
    print(1)



Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,m;cin >> n >> m;
  if (n%2==1) {
    for (int i=1;i<=m;i++) cout << i << " " << n-i+1 << endl;
  }
  else {
    long long k=n/2;
	for (int i=1;i<=m;i++) {
	  if (i%2==1) cout << (i+1)/2 << " " << k-(i+1)/2+1 << endl;
	  else cout << k+(i+1)/2 << " " << n-(i+1)/2 << endl;
	}
  }
}

Measured memory_bytes: 3592