akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		int[] count = {-1, -1, -1};
		int[] amount = {10000, 5000, 1000};
		boolean isExist = false;
		
		for(int i = 0;(i <= n) && (amount[0] * i <= y);i++) {
			for(int j = 0;(amount[1] * j <= y) && (j <= n - i);j++) {
				int k = n - j - i;
				if(amount[0] * i + amount[1] * j + amount[2] * k == y) {
					count[0] = i;
					count[1] = j;
					count[2] = k;
					isExist = true;
					break;
				}
			}
			
			if(isExist) {
				break;
			}
		}
		
		System.out.println(count[0] + " " + count[1] + " " + count[2]);
    }
}

Measured memory_bytes: 23252
def main() -> None:
    N = int(input())
    S = input()
    m = 0
    for i in range(N):
        l1 = S[0:i]
        l2 = S[i:]
        if m < len(set(sorted(l1)) & set(sorted(l2))):
            m = len(set(sorted(l1)) & set(sorted(l2)))
    
    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  if(k%2 == 0){
    cout << -1 << endl;
    return 0;
  }
  if(k%5 == 0){
    cout << -1 << endl;
    return 0;
  }
  if(k == 1){
    cout << 1 << endl;
    return 0;
  }
  if(k == 3){
    cout << 3 << endl;
    return 0;
  }

  int sum = 7;
  int rest = 7;
  int cnt = 1;
  while(sum % k != 0){
    rest *= 10;
    rest %= k;
    sum += rest;
    sum %= k;
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int n,k,s;
int ans;

void dfs(int num,int cnt,int sum){
  if(sum==s && cnt == k)
    ans++;
  if(num > n)
    return;
  if(cnt == k)
    return;
  dfs(num+1,cnt+1,sum+num);
  dfs(num+1,cnt,sum);
}

int main(){
  
  while(scanf("%d%d%d",&n,&k,&s),n+k+s!=0){
    ans=0;
    dfs(1,0,0);
    printf("%d\n",ans);
  }
  
  return 0;
}

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

int main() {
    int h, w, k, sum = 0, ans = 0;
    cin >> h >> w >> k;
    char c[h][w];
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> c[i][j];
            if(c[i][j] == '#') sum++;
        }
    }

    int HB[h] = {0}, WB[w] = {0};
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(c[i][j] == '#') HB[i]++;
        }
    }
    for(int i = 0; i < w; ++i) {
        for(int j = 0; j < h; ++j) {
            if(c[j][i] == '#') WB[i]++;
        }
    }

    for (int bit = 0; bit < (1<<h); ++bit){

        vector<int> S;
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        for (int bitJ = 0; bitJ < (1<<w); ++bitJ){
            int sumb = sum;
            vector<int> SS;
            for (int i = 0; i < w; ++i) {
                if (bitJ & (1<<i)) { // i が bit に入るかどうか
                    SS.push_back(i);
                }
            }

            for (int i = 0; i < (int)S.size(); ++i) sumb -= HB[S[i]];
            for (int i = 0; i < (int)SS.size(); ++i) sumb -= WB[SS[i]];

            for (int i = 0; i < (int)S.size(); ++i) {
                for (int j = 0; j < (int)SS.size(); ++j) {
                    if(c[S[i]][SS[j]] == '#') sumb++;
                }
            }

            if(sumb == k) ans++;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3620
H,N = map(int,input().split())
magicL =[]
for x in range(N):
    magic = list(int(i) for i in input().split())
    magicL.append(magic)
 
ml = magicL
dp = [10**9 for i in range(H +1)]
dp [0] = 0
for i in range(N):
    for w in range(H +1):
        dp[min(w+ml[i][0],H)] = min(dp[min(w+ml[i][0],H)],dp[w]+ml[i][1])
print(dp[H])

Measured memory_bytes: 43756
import sys
input = sys.stdin.readline
def print_ans(S):
    """Test Case
    >>> print_ans("1905")
    YYMM
    >>> print_ans("0112")
    AMBIGUOUS
    >>> print_ans("1700")
    NA
    """
    front = int(S[:2])
    rear = int(S[2:])
    frontMM_flg = 1 <= front <= 12
    rearMM_flg = 1 <= rear <= 12
    if frontMM_flg and rearMM_flg:
        print("AMBIGUOUS")
    elif frontMM_flg and not rearMM_flg:
        print("MMYY")
    elif not frontMM_flg and rearMM_flg:
        print("YYMM")
    else:
        print("NA")
    


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        
        int absMin = 1000000;
        int eatNum = 0;
        for(int i = 1; i <= N; i++){
            if ( absMin > Math.abs(L + i - 1) ){
                absMin = Math.abs(L + i - 1);
                eatNum = i;
            }
        }
        
        int sum = 0;
        for(int i = 1; i <= N; i++){
            if ( i == eatNum ) continue;
            sum += (L + i - 1);
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    s = r.readLine();
    sl = s.split(" ");
    String b1 = sl[0];
    String b2 = sl[1];

    for(int i = 0; i < n; i++)
    {
      System.out.print(b1.charAt(i));
      System.out.print(b2.charAt(i));
    }
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


Measured memory_bytes: 21332
n = int(input())
a = list(map(int,input().split()))
a.append(0)

ans = 1000
cnt = 0

for i in range(n):
    if a[i] < a[i+1]:
        tmp = ans // a[i]
        cnt += tmp
        ans -= a[i] * tmp
    else:
        ans += a[i] * cnt
        cnt = 0

print(ans)


Measured memory_bytes: 61780
n = raw_input()
while 1:
	try :
		a = map(int,raw_input().split())
		a.sort()
		a.reverse()
#		print a
		if a[0]**2 == a[1]**2 + a[2]**2:
			print "YES"
		else : 
			print "NO"
	except EOFError:
		break

Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define forn(i,n)for(ll i=0;i<(n);i++)
#define forn_rev(i,n)for(ll i=(n)-1;i>=0;i--)
#define for1n(i,n) for(ll i=1;i<=(n);i++)
#define ARRAY_SIZE(a) sizeof(a)/sizeof(*a)
#define MOD 1000000007
#define MAXN 1000005

using namespace std;


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--)
    {

        ll K;
       string s;
       cin>>K>>s;

       if(s.length()<=K){
        cout<<s;
       }
       else{
        string temp="";
        forn(i,K) temp+=s[i];
        cout<<temp<<"...";
       }







    }



    return 0;
}

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

int main() {
// Initialize number
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500*i + 100*j + 50*k == X) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
 
int main(){
  int A,B,sum=0,i;
  
  scanf("%d %d", &A, &B);
  if(A<3 || B>20){
    scanf("%d %d", &A, &B);
  }
  
  for(i=0;i<2;i++){
    if(A>=B){
      sum = sum + A;
      A = A -1;
    }else{
      sum = sum + B;
      B = B -1;
    }
  }
  
  printf("%d",sum);
  
  return 0;
  
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vi p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  vector<P> ap;
  rep(i, a) ap.push_back(P(p[i], 0));
  rep(i, b) ap.push_back(P(q[i], 1));
  rep(i, c) ap.push_back(P(r[i], 2));
  sort(ap.begin(), ap.end());
  reverse(ap.begin(), ap.end());
  dump(ap);
  ll ans = 0;
  int pos = 0;
  int z = 0;
  while(0 < x + y - z) {
    if (ap[pos].second == 0) {
      if (0 < x) {
        ans += ap[pos].first;
        x--;
      }
    }
    if (ap[pos].second == 1) {
      if (0 < y) {
        ans += ap[pos].first;
        y--;
      }
    }
    if (ap[pos].second == 2) {
      ans += ap[pos].first;
      z++;
    }
    pos++;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 7664
#include <iostream>

using namespace std;

int main()
{
    constexpr int kMod = 1e9 + 7;

    int n;
    cin >> n;

    auto power = 1;
    for (int i = 2; i <= n; i += 1) {
        power = (1LL * power * i) % kMod;
    }

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


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

int main(){
  int N;
  cin >> N ;
  vector<int> unko(N);
  vector<int> unchi(N,0);
  vector<int> aa(N,0);
  int comp;
  int second;
  int count = 0;
  
  for(int i=0; i<N ; i++){
  cin >> unko.at(i);  
  }
  
  comp = 0;
  
  for(int i=0; i<N; i++){
    comp = max(comp, unko.at(i));
  }
  
  
  for(int i=0; i<N; i++){
    if(unko.at(i) == comp){
      count += 1;
    }
  }
 
  unchi = unko;
  
  for(int i=0 ; i<N; i++){
    if(unchi.at(i) == comp){
      unchi.at(i)=0;
    }
  }
  
  sort(unchi.begin(), unchi.end());
  second = unchi.at(N-1);  
 
  
  for(int i=0 ; i<N; i++){
    if(unko.at(i) == comp){
      if(count > 1){
        cout << comp <<endl;
      }else{
      cout << second << endl;
      }
    }else{
      cout << comp <<endl;
    }
  }      
}

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

int main() {
    //input
    string s;
    cin >> s;

    int a=0,z=0;
    for(int i=0;i<s.length();i++){
        if(s.at(i) == 'A'){
            a = i;
            break;
        }
    }
    for(int i=a+1;i<s.length();i++){
        if(s.at(i) == 'Z'){
            z = i;
        }
    }

    cout << z-a+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N;
  	vector<ll> a;
  	cin >> N;
  	ll ans = 0;
  	a.resize(N);
    for(int i = 0; i < N; ++i){
      cin >> a[i];
    }
  	for(int i = 1; i < N; ++i){
      	if(a[i - 1] == a[i]){
          if(a[i] + 1 != a[i+1]) {
            a[i]++;
            ans++;
          }
          else{
            a[i] += 2;
            ans++;
          }
        }
    }
  	cout << ans << endl;
}

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

import math
def calc(x1,x2):
    
    l1 = l[x1]
    l2 = l[x2]
    s = 0
    for i in range(d):
        s += (l1[i]-l2[i])**2
    s = math.sqrt(s)
    if(s.is_integer()):
        return 1
    return 0


ans = 0
for i in range(n):
    for j in range(i,n):
        if(i==j):
            continue
        ans += calc(i,j)
print(ans)

Measured memory_bytes: 3064
#1,1からH,Wへの最短経路の距離を求め、全体から引く
# -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
inf=float("inf")
s = [[-1]*(w+2)] + [[-1] + [inf if i=="." else -1 for i in input()] + [-1] for _ in range(h)] + [[-1]*(w+2)]
from math import isinf
white = 0
for i in s:
    for j in i:
        if isinf(j):
            white+=1


inf=float("inf")
from collections import deque
s[1][1] = 0
stack_deque = deque([[1,1]])
ret = -1
cnt = 0
while len(stack_deque) > 0:
    curh,curw = stack_deque.popleft()
    cnt = s[curh][curw]+1
    if curh == h and curw==w:
        ret = white - (cnt-1) -1
        break
    if isinf(s[curh-1][curw]):
        s[curh-1][curw]=cnt
        stack_deque.append([curh-1,curw])
    if isinf(s[curh+1][curw]):
        s[curh+1][curw]=cnt
        stack_deque.append([curh+1,curw])
    if isinf(s[curh][curw-1]):
        s[curh][curw-1]=cnt
        stack_deque.append([curh,curw-1])
    if isinf(s[curh][curw+1]):
        s[curh][curw+1]=cnt
        stack_deque.append([curh,curw+1])
print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
  int A,B;
  cin >> A >> B;
  int answa = A + B;
  int anssa = A - B;
  int ansseki = A*B;
  cout << max(max(answa,anssa),ansseki) << endl;
}

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

int main() {
  using  tsii =  tuple<string, int, int>;  // pair<int, int> に pii という別名を付ける

  int N;
  cin >> N;
  
  vector<tsii> restaurant_list(N);
  for (int i=0;i<N;i++){
    cin >> get<0>(restaurant_list.at(i)) >> get<1>(restaurant_list.at(i));
    get<1>(restaurant_list.at(i)) *= -1;
    get<2>(restaurant_list.at(i)) = i;
  }
  
  sort(restaurant_list.begin(), restaurant_list.end());
  
  string city;
  int point, index;
  for (int i=0;i<N;i++){
    tie(city, point, index) = restaurant_list.at(i);
    cout << index+1 << endl;
    
  }
  
}


Measured memory_bytes: 256
# 2019 6/9
# ABC129 B Balance


def partition(weight, N):
    min_dif = 1000000
    for i in range(N):
        former = sum(weight[:i])
        lattar = sum(weight[i:])
        dif = abs(former - lattar)
        if dif <= min_dif:
            min_dif = dif
    return min_dif


if __name__ == '__main__':
    N = int(input())
    weight = list(map(int, input().split()))

    print(partition(weight, N))

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

int main(){


  int A,B,K=0,minimum,maximum,found=0;
  cin>>A>>B;

  if(A<B){
    minimum = A;
    maximum = B;
  }
  else{
    minimum = B;
    maximum = A;
  }
    for(int i=0;i<=maximum;i++){

        if(abs(minimum-i)==abs(maximum-i)){
            K = i;
            found++;
            break;
        }
        K++;
    }
        if(found==0){
            cout<<"IMPOSSIBLE"<<endl;
        }
        else
            cout<<K<<endl;

}


Measured memory_bytes: 256
X=int(input())
L1=[]
Hash={}
for i in range(300+1):
    L1.append(i**5)
    Hash[i**5]=i
FLAG=0
for i in L1:
    for j in L1:
        if i-j==X:
            print(Hash[i],Hash[j])
            FLAG=1
            break
        elif i+j==X:
            print(Hash[i],-Hash[j])
            FLAG=1
            break
    if FLAG==1:
        break


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

int main(){
  int N;
  bool jail = false;
  cin >> N;
  int cnt = 0;
  int left, right;
  for (int i = 0; i < N; i++)
  {
    cin >> left >> right;

    if (left == right){
      cnt += 1;
    }
    else
    {
      cnt = 0;
    }
    
    if (cnt == 3){
      jail =true;

    }
  }
  
  if (jail){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

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

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


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

int main() {
	string s,t;
	bool p=true;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
	    if(s[i]!=t[i]){
	        p=false;
	        break;
	    }
	}
	if(p){
	    cout<<"Yes";
	} else{
	    cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int cur = -1;
  int prev_max = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (cur == -1 && (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')) {
      cur = 1;
    } else if (cur != -1 && !(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')) {
      prev_max = max(prev_max, cur);
      cur = -1;
    } else if (cur != -1 && (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')) {
      ++cur;
    }
  }

  if (cur != -1)
    prev_max = max(prev_max, cur);

  cout << prev_max << endl;

  return 0;
}

Measured memory_bytes: 256
// CONTEST

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#ifndef DEBUG
#define DEBUG 0
#endif
#define dbg(X) do { if (DEBUG) { cout << #X ": " << (X) << endl << flush; } } while (0)
#define dbg2(X) do { if (DEBUG) { cout << #X ":" << endl; for (auto& __x : (X)) { cout << __x << endl << flush; } } } while (0)
#define dbgv(...) do { if (DEBUG) { cout << "(" #__VA_ARGS__ "): " << make_tuple(__VA_ARGS__) << endl << flush; } } while (0)
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int n;
  cin >> n;
  vector<int> ls(n, 0);
  cin >> ls;

  int m = *max_element(ALL(ls));

  int g = ls[0];
  FOR(i, 1, n) { g = gcd(g, ls[i]); }
  dbg(g);
  if (g > 1) {
    cout << "not coprime" << endl;
    return;
  }

  // Precompute factors
  vector<bool> sieve(m + 1, 1);
  vector<vector<int>> factors(m + 1);
  for (int p = 2; p <= m; p++) {
    if (sieve[p] == 0) { continue; }
    for (int x = p; x <= m; x += p) {
      sieve[x] = 0;
      factors[x].push_back(p);
    }
  }
  dbg(factors);

  set<int> fs;
  bool pairwise = 1;
  FOR(i, 0, n) {
    for (auto f : factors[ls[i]]) {
      if (fs.count(f)) {
        pairwise = 0;
        break;
      }
      fs.insert(f);
    }
  }
  dbg(pairwise);

  cout << (pairwise ? "pairwise coprime" : "setwise coprime") << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  // [ Single case ]
  mainCase();
  return 0;
  // [ Multiple cases ]
  // int t;
  // cin >> t;
  // FOR(i, 0, t) { mainCase(); }
  // return 0;
}

/*
python misc/run.py atcoder/abc177/e/main.cpp --check

%%%% begin
3
3 4 5
%%%%
pairwise coprime
%%%% end

%%%% begin
2
1 1000000
%%%%
%%%% end
*/


Measured memory_bytes: 66144
package main
 
import (
  "bufio"
  "fmt"
  "os"
   "strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := sc.Text()
    a, _ := strconv.Atoi(s)
    
    cnt := 0
    for i := 1; i <= a; i++ {
      s := strconv.Itoa(i)
      if len(s) % 2 == 1 {
        cnt++
      }
    }
    fmt.Println(cnt)
  }
}

Measured memory_bytes: 1152
//展望台 i から一本の道を使って辿り着ける展望台の標高の最大値よりも展望台 i の標高が高い


#include <iostream>
#include <algorithm>
using namespace std;
#define N 100010
int main()
{
    int n, m, h[N], ma[N]; //nは展望台の数　mは道の数　h[N]は各展望台の高さ　ma[N]は高い方の展望台
    cin >> n >> m; //展望台の数と道の数を入力
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i]; //各展望台の数を入力　添え字と展望台のナンバリングを合わせてる
        ma[i] = 0; //ma[N]をそれぞれ初期化
    }
    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; //ansが良い展望台の数
    for (int i = 1; i <= n; i++)
    {
        ans += h[i] > ma[i];
    }
    cout<<ans<<endl;
}


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

int main(){
    long long n,m;
    cin>>n>>m;
    if(n==1&&m==1) cout<<1<<endl;
    else if(n==1||m==1) cout<<max(m-2,n-2)<<endl;
    else  cout<<max(n*m-2*(n+m)+4,1LL*0)<<endl;
}

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var S = cin.Read;
                WriteLine(S.ToCharArray().Count(c => c == 'o') * 100 + 700);
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
        public void ReadIntArrays(long N, out int[] A, out int[] B, out int[] C) { A = new int[N]; B = new int[N]; C = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; C[i] = ReadInt; }}
        public void ReadLongArrays(long N, out long[] A, out long[] B) { A = new long[N]; B = new long[N]; for (long i = 0; i < N; ++i) { A[i] = ReadLong; B[i] = ReadLong; }}
    }
}


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

int main() {
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(1) == s.at(2)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  int n,m,i,j;
  int result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%d %d",&n,&m);
  rep(i,m) scanf("%d",&a[i]);
  
  rep(i,m) result += a[i];
  
  if(n >= result) printf("%d",n-result);
  else printf("-1");
  
  return 0;
}



Measured memory_bytes: 3688
import sys
from io import StringIO
import unittest

def yn(b):
    print("YES" if b==1 else "NO")
    return

def resolve():
    readline=sys.stdin.readline
    ss=readline().strip()
    #n,m,k=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    ss=ss.replace("dream","D")
    ss=ss.replace("erase","E")
    ss=ss.replace("Der","DR")
    ss=ss.replace("Er","ER")
    for s in ss:
        if s not in ["D","E","R"]:
            print("NO")
            return
    print("YES")

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまでコピぺえ 
### ----------------

Measured memory_bytes: 5824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int a = str.length();
		int m = 1,w = 0;
		for(int i = 0;i < a;i++){
			for(int k = m;k < a;k++){
				if(str.charAt(i) == str.charAt(k))w++;
			}
			m++;
		}
		if(w != 0)System.out.print("no");
		else System.out.print("yes");
	}

}

Measured memory_bytes: 21844
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int D;
int c[32];
int s[512][32];
int ans[512];

void inp(){
    cin>>D;
    for(int i=1;i<=26;i++){
        cin>>c[i];
    }
    for(int i=1;i<=D;i++){
        for(int j=1;j<=26;j++){
            cin>>s[i][j];
        }
    }
}

void ans_inp(){
    for(int i=1;i<=D;i++){
        cin>>ans[i];
    }
}

void ans_ran(){
    for(int i=1;i<=D;i++){
        ans[i]=rand()%26+1;
    }
}

int man_calc(bool disp){
    int l[32]={0};
    int man=0;
    for(int i=1;i<=D;i++){
        int n=ans[i];
        l[n]=i;
        man+=s[i][n];
        for(int j=1;j<=26;j++){
            man-=c[j]*(i-l[j]);
        }
        if(disp) cout<<man<<endl;
    }
    return man;
}

void ans_disp(){
    for(int i=1;i<=D;i++){
        cout<<ans[i]<<endl;
    }
}

void change_ans(int i,int n){
    ans[i]=n;
}

void solve_C(){
    int M;
    cin>>M;
    for(int i=0;i<M;i++){
        int from,to;
        cin>>from>>to;
        change_ans(from,to);
        cout<<man_calc(false)<<endl;
    }
}

void random_solve(){
    int seed=1234;
    int cnt=100000;
    srand(seed);
    ans_ran();
    for(int i=0;i<=cnt;i++){
        int bef=man_calc(false);
        int ci=rand()%D+1;
        int tn=rand()%26+1;
        int fn=ans[ci];
        change_ans(ci,tn);
        int aft=man_calc(false);
        if(bef>aft){
            change_ans(ci,fn);
        }
        if(i%(cnt/5)==0){
            //cout<<i<<endl;
            for(int ci=1;ci<=D;ci++){
                for(int tn=1;tn<=26;tn++){
                    int bef=man_calc(false);
                    int fn=ans[ci];
                    change_ans(ci,tn);
                    int aft=man_calc(false);
                    if(bef>aft){
                        change_ans(ci,fn);
                    }
                }
            }
        }
    }
    ans_disp();
    //cout<<man_calc(false)<<endl;
}

signed main(){
    inp();
    random_solve();
    return 0;
}



Measured memory_bytes: 3276
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fi first
#define se second

constexpr int MOD = 998244353;

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

  int N;
  cin >> N;

  vector<pair<int, int>> V(N);
  for (auto& p : V) {
    cin >> p.fi >> p.se;
    p.se += p.fi;
  }

  sort(V.rbegin(), V.rend());

  vector<pair<int, int>> stk;
  for (auto p : V) {
    ll w = 1;
    while (!stk.empty() && p.se > stk.back().fi) {
      w = w * stk.back().se % MOD;
      stk.pop_back();
    }
    stk.emplace_back(p.fi, w + 1);
  }

  ll res = 1;
  for (auto p : stk) {
    res = res * p.se % MOD;
  }
  cout << res << endl;

  return 0;
}


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

using namespace std;

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

    long long n, a, b;

    cin >> n >> a >> b;

    long long ans = 0;

    ans += n/(a+b) * a;

    if(n%(a+b) != 0) ans += min(n%(a+b), a);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	int n, m;
	cin >> n >> m;
	int a[m];
	for(int i=0;i<m;i++)
		cin >> a[i];
	ll sum = accumulate(a, a+m, 0);
	if(sum > n)
		cout << -1 << "\n";
	else
		cout << n - sum << "\n";

	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

long long f(long long x, long long m){
    return (x *x) % m;
}

int main(){
    long long n, x, m;
    cin >> n >> x >> m;

    set<long long> T;
    long long now = x;
    T.insert(now);
    long long start;
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        now = f(now, m);
        if(T.find(now) == T.end()) T.insert(now);
        else{
            start = now;
            break;
        }
    }

    bool find = false;
    vector<long long> loop;
    long long dist = 0;
    //printf("start %lld\n", start);
    now = x;
    for(long long i = 0; i < m; i++){
        //printf("i %lld %lld\n", i+1, now);
        if(now == start and find == false){
            //printf("find\n");
            find = true;
            dist = i;
        }
        else if(now == start and find == true) break;

        if(find == true){
            loop.push_back(now);
        }
        
        now = f(now, m);
    }
    //printf("dist %lld\n", dist);

    long long fre = 0;
    for(long long i = 0; i < loop.size(); i++) fre += loop[i];

    long long ans = 0;
    if(n <= dist) {
        now = x;
        for(long long i = 0; i < n; i++){
            ans += now;
            now = f(now, m);
        }
    }
    else{
        now = x;
        for(long long i = 0; i < dist; i++){
            ans += now;
            now = f(now, m);
        }
        long long r = (n-dist)/((long long)loop.size());
        long long amari = (n-dist) % ((long long)loop.size());

        ans += fre * r;
        for(long long i = 0; i < amari; i++) ans += loop[i];
    }

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

Measured memory_bytes: 6268
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <string.h>
using namespace std;

int main()
{
  int large_value = 1e9+7;
  int h = 0;
  int w = 0;
  scanf("%d %d", &h, &w);
  vector<string> walls(h, ""); 
  for(int i=0; i<h; i++){
    cin >> walls[i];
  }
  vector<int> arr((h+1)*(w+1), 0);
  arr[w+1] = 1;
  for (int i=1; i<h+1; i++){
    for (int j=1; j<w+1; j++){
      if(walls[i-1][j-1] != '#'){
         arr[i*(w+1) + j] = (arr[(i-1)*(w+1)+j] + arr[i*(w+1) + j-1]) % large_value;
      }
    }
  }
  printf("%d\n", arr[(h+1)*(w+1)-1]);
  //for(int i=0; i<h+1; i++){
  //  for(int j=0; j<w+1; j++){
  //    printf("%d ", arr[i*(w+1)+j]);
  //  }
  //  cout << endl;
  //}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int N,A,B,result=0,bcounter=1;
	string S;
	bool flug;
	cin>>N>>A>>B;
	cin>>S;
	
	REP(i,N){
		flug=false;
		switch(S[i]){
			case 'a':
				if(result<A+B) flug=true;
				break;
			case 'b':
				if(result<A+B&&(bcounter++)<=B) flug=true;
				break;
			case 'c':
				break;
		}
		if(flug){
			puts("Yes");
			result++;
		}else puts("No");
	}
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e15+4;
const int Nmax=2e5+1;
const int Nd=61;
ll dfs[3003][3003][4];
ll  v[3003][3003];

int main(){
  int n;cin>>n;
  vector<int> a(n),b(n);//b:補正後の高さ
  ll now=0;
  rep(i,n){
    cin>>a[i];
    if(i>0 && a[i]<b[i-1]){
      b[i]=b[i-1];
      now+=b[i]-a[i];
    }else{//台が不要
      b[i]=a[i];
    }
  }
  cout<<now<<endl;






  return 0;
}


Measured memory_bytes: 4840
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int[] count = new int[1001];
        boolean[] first = new boolean[1001];
        boolean[] second = new boolean[1001];

        while (in.hasNextLine()) {
            String line = in.nextLine();
            if (line.isEmpty()) {
                break;
            }
            int c = Integer.parseInt(line.split(",")[0]);
            count[c]++;
            first[c] = true;
        }

        while (in.hasNextLine()) {
            String line = in.nextLine();
            if (line.isEmpty()) {
                break;
            }
            int c = Integer.parseInt(line.split(",")[0]);
            count[c]++;
            second[c] = true;
        }

        for (int c = 1; c < count.length; c++) {
            if (first[c] && second[c]) {
                System.out.println(c + " " + count[c]);
            }
        }
    }
}

Measured memory_bytes: 25880
/*#include<bits/stdc++.h>
using namespace std;
int64_t f(int64_t b,int64_t n){
if(n<b)return n;
  else
    return f(b,n/b)+(n%b);
}
int main(){
int64_t N,S;
  cin>>N>>S;
  if(N<S)
    cout<<-1<<endl;
  else if(N==S)
    cout<<1+N<<endl;
  else{
  int64_t K=N-S;
    vector<int64_t>A={};
    for(int64_t i=1;i*i<=K;i++){
    if(K%i==0){
    if(K==i*i)
      A.push_back(i+1);
      else{
      A.push_back(i+1);
        A.push_back((K/i)+1);
      }
      
    }
    
    }sort(A.begin(),A.end());
    int64_t ans=-1;
    int64_t M=A.size();
    for(int i=0;i<M;i++){
     int64_t B=A.at(i);
      if(f(B,N)==S){ans=B; break;}
    }cout<<ans<<endl;
  
  }
          return 0;
}
*/
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll f(ll b,ll n){
  if(n<b){
    return n;
  }else{
    return f(b,n/b)+n%b;
  }
}
int main(void){
  ll n,s;
  cin>>n>>s;
  if(n<s){
    cout<<-1<<endl;
  }else if(n==s){
    cout<<n+1<<endl;
  }else{
    ll k=n-s;
    vector<ll> vec;
    for(ll i=1;i*i<=k;i++){
      if(k%i==0){
        if(k==i*i){
          vec.push_back(i+1);
        }else{
          vec.push_back(i+1);
          vec.push_back((k/i)+1);
        }
      }
    }
    sort(vec.begin(),vec.end());
    ll ans=-1;
    ll len=vec.size();
    for(int i=0;i<len;i++){
      ll num=vec[i];
      if(f(num,n)==s){
        ans=num;
        break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    string s[h];
    int c = 0;
    rep(i,0,h){
        cin>>s[i];
        rep(j,0,w){
            if(s[i][j]=='#'){c++;}
        }
    }
    string ans = (c==h+w-1?"Possible":"Impossible");
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | g x == g y = "Yes"
        | otherwise  = "No"
  where [x, y] = fmap read (words s) :: [Int]

g :: Int -> Int
g x | x == 2                 = 0
    | x `elem` [4, 6, 9, 11] = 1
    | otherwise              = 2

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;

bool chek(ll key) {
	if (key) return true;
	else return false;
}

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	
	for (int i = 0; i < n; i++) {
		
		while (i + 1 < n && a[i] == a[i + 1]) ++i;

		if (i + 1 < n && a[i] < a[i + 1]) {
			while (i + 1 < n && a[i] <= a[i + 1]) ++i;
		}
		else if (i + 1 < n && a[i] > a[i + 1]) {
			while (i + 1 < n && a[i] >= a[i + 1]) ++i;
		}
		ans++;

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int s;
    int count=0;
    cin>>s;
    while(s>4 || s==3){
       if(s%2==0){
          s/=2;
       }else{
          s=3*s+1;
       }
      count++;
    }
    count+=4;
    cout<<count<<"\n";




    return 0;
}


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

using namespace std;

int sum_(int a, int b, int bit) {
    if (bit == 0) {
        return a+b;
    } else {
        return a-b;
    }
}

string bit_out(int bit) {
    if (bit == 0) {
        return "+";
    } else {
        return "-";
    }
}

int main() {
    int abcd, x[4];
    cin >> abcd;
    for (int i=0; i<4; i++) {
        x[3-i] = abcd % 10;
        abcd /= 10;
    }
    for (int i=0; i<2; i++) {
        for (int j=0; j<2; j++) {
            for (int k=0; k<2; k++) {
                if (sum_(sum_(sum_(x[0], x[1], i),x[2], j),x[3], k) == 7) {
                    cout << x[0] << bit_out(i) << x[1] << bit_out(j) << x[2] << bit_out(k) << x[3] << "=7" << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

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

typedef long long ll;

struct BIT{
    // 1-origin
    vector<int> v;
    int n;

    BIT(int _n):
        v(vector<int>(_n+1, 0)), n(_n) {}

    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= lsb(i);
        }
        return s;
    }
    
    int sum(int l, int r){
        return sum(r) - sum(l-1);
    }

    void add(int i, int x){
        while(i <= n){
            v[i] += x;
            i += lsb(i);
        }
    }

    ll invNum(){
        ll ret = 0;
        for(int j = 0; j < n; j++){
            ret += j - sum(v[j]);
            add(v[j], 1);
        }
        return ret;
    }

private:
    // least significant bit
    int lsb(int i){
        return i & -i;
    }
};

typedef pair<int,int> pii;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    int c[n];
    for(int i = 0; i < n; i++)  cin >> c[i], c[i]--;
    vector<pair<pii,int>> vp;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        vp.push_back({{--r, --l}, i});
    }
    sort(vp.begin(), vp.end());
    vector<int> last(n, -1), ans(q);
    int qind = 0;
    BIT bit(n);
    for(int i = 0; i < n; i++){
        if(last[c[i]] != -1){
            bit.add(last[c[i]]+1, -1);
        }
        last[c[i]] = i;
        bit.add(last[c[i]]+1, 1);
        while(qind < q && vp[qind].first.first == i){
            ans[vp[qind].second] = bit.sum(i+1)-bit.sum(vp[qind].first.second);
            qind++;
        }
    }
    for(int i = 0; i < q; i++)  cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 17384
x=int(input())
if 400<=x<600:
    print(8)
elif 600<=x<800:
    print(7)
elif 800<=x<1000:
    print(6)
elif 1000<=x<1200:
    print(5)
elif 1200<=x<1400:
    print(4)
elif 1400<=x<1600:
    print(3)
elif 1600<=x<1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
bool isPrime(ll x)
{
    bool flag = false;
    for (ll i = 2; i < x; i++)
    {
        if (x % i == 0) {
            flag = true;
            break;
        }
    }
    return flag;
}
int main()
{
    ll x;
    cin >> x;
    while (1)
    {
        if(!isPrime(x)) {
            break;
        }
        x += 1;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int n;
vector<int> G[100000];
int memo[100000];

void dfs(int v){
	if(G[v].size() == 0){
		memo[v] == 0;
		return;
	}
	vector<int> va;
	for(int i = 0; i < G[v].size(); i++){
		dfs(G[v][i]);
		va.push_back(memo[G[v][i]]);
	}
	sort(va.begin(), va.end());
	reverse(va.begin(), va.end());
	for(int i = 0; i < va.size(); i++) memo[v] = max(memo[v], va[i] + i + 1);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i < n; i++){
		int a;
		scanf("%d", &a);
		a--;
		G[a].push_back(i);
	}
	dfs(0);
	printf("%d\n", memo[0]);
	return 0;
}


Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 5;

ll n;
ll a[mx];
ll dp[mx];

ll fn(ll i)
{
	if(dp[i] != -1)
		return dp[i];
	if(i == n)
		return 0;
	if(i > n)
		return 1e18;
	dp[i] = min(fn(i+1) + abs(a[i+1] - a[i]), fn(i+2) + abs(a[i+2] - a[i]));
	return dp[i];
}

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

	cin >> n;
	for(ll i=1; i<=n; i++)
	{
		cin >> a[i];
	}
	memset(dp, -1, sizeof dp);
	cout << fn(1) << "\n";

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#define int long long
using namespace std;
signed main() {
	int n, a, ans = 0; cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		ans += a - h;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	string R,G;
	cin >> R >> G;
	if(R[0]==G[2]&&R[1]==G[1]&&R[2]==G[0])
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 256