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

int main(){
  int n;
  cin >> n;
  
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int ans = 1;
  int s = 0;
  for (int i = 1; i < n; i++){
    if (s == 0){
      if (a[i] - a[i - 1] > 0) s = 1;
      if (a[i] - a[i - 1] < 0) s = - 1;
    }
    if (s == 1){
      if (a[i] - a[i - 1] < 0){
        ans++;
        s = 0;
      }
    }
    if (s == -1){
      if (a[i] - a[i - 1] > 0){
        ans++;
        s = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
from itertools import product

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

cnt = 0
for pat in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        tmp = sum(pat[sij - 1] for sij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 9092
#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 pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO
int h,w;
cin>>h>>w;
vector<string> s(h);
for(int i=0;i<h;i++){
	cin>>s[i];
}
vector<vector<int> > v(h*w,vector<int>(h*w,INT_MAX));
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
    	if(s[i][j]=='#')
    	   continue;
    	if((i-1)>=0){
    		if(s[i-1][j]!='#')
    		v[j+i*w][j+(i-1)*w]=1;
		}
		if((i+1)<h){
			if(s[i+1][j]!='#')
    		v[j+i*w][j+(i+1)*w]=1;
		}
		if((j-1)>=0){
			if(s[i][j-1]!='#')
    		v[j+i*w][j-1+(i)*w]=1;
		}if((j+1)<w){
			if(s[i][j+1]!='#')
    		v[j+i*w][j+1+i*w]=1;
		}
	}
}
for(int i=0;i<h*w;i++){
	for(int j=0;j<h*w;j++){
		if(i==j)
		   v[i][j]=0;
	}
}
for(int k=0;k<h*w;k++){
	for(int i=0;i<h*w;i++){
		for(int j=0;j<h*w;j++){
			if((v[i][k]==INT_MAX)||(v[k][j]==INT_MAX))
			      continue;
			if(v[i][j]>v[i][k]+v[k][j]){
				v[i][j]=v[i][k]+v[k][j];
			}
		}
	}
}
int ans=0;
for(int i=0;i<h*w;i++){
	for(int j=0;j<h*w;j++){
		//cout<<v[i][j]<<" ";
		if(v[i][j]!=INT_MAX){
			ans=max(ans,v[i][j]);
		}
	}
	//cout<<"\n";
}
cout<<ans;
}


Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 1000000007  # type: int


def bit_sum(n):
    wa = 0
    while n > 0:
        wa += n & 1
        n >>= 1
    return wa


def bit(n, k):
    return (n >> k) & 1


def solve(N: int, a: "List[List[int]]"):
    dp = [0]*(1 << N)
    dp[0] = 1
    for S in range(1, 1 << N):
        i = bit_sum(S)
        for j in range(N):
            if bit(S, j) == 1 and a[i-1][j] == 1:
                dp[S] = (dp[S]+dp[S ^ (1 << j)]) % MOD
    print(dp[(1 << N)-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 57708
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<ll,ll>

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    rep(i,N)cin >> A[i];
    ll ans = 0;
    rep(i,N){
        ans += A[i]/2;
        A[i]%=2;
        if(A[i+1])A[i+1] += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  cin >> a;
  int sum=0,ans=0,len=a.size();
  rep(i,len){
    if(a.at(i)=='A'||a.at(i)=='T'||a.at(i)=='C'||a.at(i)=='G'){
      sum++;
    }
    else{
      ans = max(ans,sum);
      sum = 0;
    }
  }
  ans = max(ans,sum);
  cout << ans;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

int main() {
    ll n;
    cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    ll ans=0;
    ll sq=sqrt(n-1);
    if(sq*sq==n-1){
        ll tmp=0;
        for(int i=2;i<sq;i++){
            if((n-1)%i==0)tmp++;
        }
        ans+=tmp*2+2;
    }else{
        ll tmp=0;
        for(int i=2;i<=sq;i++){
            if((n-1)%i==0)tmp++;
        }
        ans+=tmp*2+1;
    }
    V div;
    ll sqq=sqrt(n);
    for(int i=2;i<=sqq;i++){
        if(n%i==0){
            div.push_back(i);
            if(!(sqq*sqq==n && i==sqq))div.push_back(n/i);
        }
    }
    div.push_back(n);
    for(int i=0;i<div.size();i++){
        ll p=n;
        while(p%div[i]==0)p/=div[i];
        if(p%div[i]==1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
// Vicfred
// https://atcoder.jp/contests/abc166/tasks/abc166_f
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <stack>

using namespace std;

const unsigned long MAXN = 100005;

int n;
string S[MAXN];
bool visited[MAXN][10][10][10];
stack<char> st;
stack<char> answer;

bool dfs(int i, int a, int b, int c) {
    if(i == n) {
        while(!st.empty()) {
            answer.emplace(st.top());
            st.pop();
        }
        return true;
    }

    visited[i][a][b][c] = true;

    if(S[i] == "AB") {
        if(a+1 < 10 && b > 0 && !visited[i+1][a+1][b-1][c]) {
            st.emplace('A');
            if(dfs(i+1, a+1, b-1, c)) {
                return true;
            }
            st.pop();
        }
        if(b+1 < 10 && a > 0 && !visited[i+1][a-1][b+1][c]) {
            st.emplace('B');
            if(dfs(i+1, a-1, b+1, c)) {
                return true;
            }
            st.pop();
        }
    }
    else if(S[i] == "AC") {
        if(a+1 < 10 && c > 0 && !visited[i+1][a+1][b][c-1]) {
            st.emplace('A');
            if(dfs(i+1, a+1, b, c-1)) {
                return true;
            }
            st.pop();
        }
        if(c+1 < 10 && a > 0 && !visited[i+1][a-1][b][c+1]) {
            st.emplace('C');
            if(dfs(i+1, a-1, b, c+1)) {
                return true;
            }
            st.pop();
        }
    }
    else {
        // case BC
        if(b+1 < 10 && c > 0 && !visited[i+1][a][b+1][c-1]) {
            st.emplace('B');
            if(dfs(i+1, a, b+1, c-1)) {
                return true;
            }
            st.pop();
        }
        if(c+1 < 10 && b > 0 && !visited[i+1][a][b-1][c+1]) {
            st.emplace('C');
            if(dfs(i+1, a, b-1, c+1)) {
                return true;
            }
            st.pop();
        }
    }

    return false;
}

int main () {
    int a, b, c;
    cin >> n >> a >> b >> c;

    for(int i = 0; i < n; ++i)
        cin >> S[i];

    if(a > 0 and b > 0 and c > 0) {
        cout << "Yes" << endl;

        bool idx[3] = {true, true, true};
        for(int i = 0; i < n; i++) {
            if(S[i] == "AB") {
                cout <<  "AB"[idx[0]] << endl;
                idx[0] = !idx[0];
            }
            else if(S[i] == "BC") {
                cout <<  "BC"[idx[1]] << endl;
                idx[1] = !idx[1];
            }
            else {
                cout <<  "CA"[idx[2]] << endl;
                idx[2] = !idx[2];
            }
        }
    } else {
        if(dfs(0, min(a, 3), min(b, 3), min(c, 3))) {
            cout << "Yes" << endl;
            while(!answer.empty()) {
                cout << answer.top() << endl;
                answer.pop();
            }
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 111032
N = int(input())
topb = 0
taila = 0
both = 0
cnt = 0
for _ in range(N):
    s = input()
    cnt +=s.count("AB")

    if s[0] == "B" and s[-1] == "A":
        both += 1
    elif s[0] == "B":
        topb += 1
    elif s[-1] == "A":
        taila += 1
add_cnt = 0
if taila == 0 and topb == 0 and both >0:
    add_cnt = both -1
else:
    add_cnt = min(taila + both,topb + both)

print(cnt + add_cnt)

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

using namespace std;

int main(){

    string s1, s2, s3;
    int diff;

    cin >> s1 >> s2 >> s3;

    diff = 'A' - 'a';

    cout << char(s1[0]+diff) << char(s2[0]+diff) << char(s3[0]+diff);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  int x = ceil((double)X / 1000) * A;
  int y = ceil((double)X / 500) * B;
  int z = (X / 1000) * A + ceil(double(X % 1000) / 500) * B;
  //cerr << x << " " <<  y << " " << z << endl;
  cout << min({x, y, z}) << endl;
  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#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;
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; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];

  map<string,int> mp;
  rep(i,n) mp[s[i]]++;

  cout << "AC x " << mp["AC"] << "\n";
  cout << "WA x " << mp["WA"] << "\n";
  cout << "TLE x " << mp["TLE"] << "\n";
  cout << "RE x " << mp["RE"] << "\n";  
  
  return 0;
}


Measured memory_bytes: 6368
/* ex9_1
   bonbonc    */

#include <stdio.h> 
#include<stdlib.h>
#include<string.h>
#define SIZE 100000

typedef struct _entry{
    int key;//キー
    char token;//文字（0や1)
    struct _entry *next;//次の要素のポインタ
} entry;

void initialize_pool(entry *pool, int size);//プールの初期化関数
entry* insert_list(entry *head, int key, char character);//リストの先頭に要素を挿入する関数
entry* delete_head(entry *head);//リストの先頭を削除する関数

entry pool[SIZE];//メモリ確保用のentry配列
entry *freelist;//未使用のリスト

int main(void){
    entry *head;//リストの先頭を示すポインタ
    int count=0,i;//ブロックを消した回数を記録する変数とループ変数
    char string[SIZE];//入力を受け取る変数

    initialize_pool(pool,SIZE);//プールを初期化

    scanf("%s",string);//入力を受け取る
    head =NULL;//先頭のポインタをNULLで初期化
    
    for(i=0;i<strlen(string);i++){//一文字ずつ見ていく
        if(head==NULL){//先頭ポインタがNULLだったら、リストにstring[i]を挿入
            head = insert_list(head,i,string[i]);
        }else if(head->token != string[i]){
            head = delete_head(head);//リストの先頭と、string[i]が違ったら先頭を取り出す
            count++;//先頭を取り出した分のカウント
            count++;//string[i]を入れて取り出した分のカウント（実際には入れていない)
        }else{
            head = insert_list(head, i, string[i]);//リストの先頭とstring[i]が同じだったらそのまま先頭に挿入
        }
        
    }
    printf("%d\n",count);//答えを出力
    return 0;
}

void initialize_pool(entry *pool, int size){
    int i;//ループ変数
    if(size<1){//sizeが1より小さいときの例外処理
        fprintf(stderr, "Illegal pool size %d.\n",size);
        exit(1);
    }
    for(i=0;i<(size-1);i++){//pool[i]の次のポインタをpool[i+1]につなげる
        pool[i].next = &(pool[i+1]);
    }
    pool[size-1].next = NULL;//末尾の次のポインタをNULLにする
    freelist = pool;//freelistにpoolを渡す
}

entry* insert_list(entry *head, int key, char character){
    entry *new;

    if(freelist == NULL){//freelistが空いていないときの処理
        fprintf(stderr, "out of free space.\n");
        exit(1);
    }else{
        new = freelist;//freelistを一つ持ってくる
        freelist = freelist->next;//freelistを次の要素にずらす
    }
    //それぞれのメンバ変数を渡す
    new -> key = key;
    new -> token = character;
    new -> next = head;
    
    return new;//newポインタを返す
}

entry* delete_head(entry *head){
    entry *ptr;
    ptr=head;//先頭のポインタをコピー
    head = head->next;//先頭のポインタを次のポインタにずらす
    ptr->next = freelist;//元先頭のポインタをfreelistにつなげる
    freelist = ptr;//freelistの先頭のポインタを元先頭ポインタにする

    return head;//新しい先頭ポインタを返す
}

Measured memory_bytes: 3356
n = int(input())

cnt = [0] * 10001

for i in range(1, 100):
	for j in range(1, 100):
		for k in range(1, 100):
			x = i*i + j*j + k*k + i*j + j*k + i*k
			if(x <= 10000):
				cnt[x]+=1

for i in range(1, n+1):
	print(cnt[i])

Measured memory_bytes: 9360
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+50;
int n,m,p,t,dp[40],c[N],ans;
struct node{
    int a,b;
    bool friend operator <(node a,node b){
        return 1ll*a.a*(b.b+1)>1ll*b.a*(a.b+1);
    }
}a[N];
int main(){
    scanf("%d%d",&n,&t);
    for(int i=1,x,y;i<=n;i++){
        scanf("%d%d",&x,&y);
        x?a[++m]=(node){x,y},0:c[++p]=y;
    }
    sort(a+1,a+m+1);sort(c+1,c+p+1);
    memset(dp,0x3f,sizeof(dp));dp[0]=0;
    for(int i=1;i<=m;i++)for(int j=32;j;j--)
        dp[j]=min(1ll*dp[j],dp[j-1]+1+1ll*(dp[j-1]+1)*a[i].a+a[i].b);
    for(int i=32,j=0,sum=0;~i;i--){
        while(j<p&&dp[i]+sum+1+c[j+1]<=t)sum+=c[++j]+1;
        if(dp[i]<=t)ans=max(ans,i+j);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
/**
 * author:    Ziel
 * created:   23.04.2020 20:19:46
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string x;
		cin >> x;
		s.insert(x);
	}
	cout << sz(s);

	return 0;
}

/*
	Raise your standard.
*/

Measured memory_bytes: 19200
#include <bits/stdc++.h>
#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 PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int a[30];
int n;

int dfs(int x,int b,int c){
    if(x == n) return abs(b-c);
    int res = min(dfs(x+1,b+a[x],c) , dfs(x+1,b,c+a[x]));
    return res;
}

int main(){

    while(true){
	cin >> n;
	if(n == 0) break;
	REP(i,n){
	    cin >> a[i];
	}
	cout << dfs(0,0,0) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-2) {
        string ns = s.substr(i,3);
        if(ns == "ABC") ans++;
    }
    cout << ans << endl;
}

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

int main() {
  int N,M,max;
  cin >> N >> M;
  
  
  for(int i=M/N+1; i >0; i--){
    if(M%i==0 && M/i >= N){
      max = i;
      break;
    }
  } 
  cout << max <<endl;
}

Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))

for i in range(1,n):
    print(" ".join(map(str,a)))
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j-=1
    a[j+1]=v

print(" ".join(map(str,a)))


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

using namespace std;
#define PI              3.1415926536

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define REP(i,n) for(i=0;i<n;i++)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	//c_p_c();
	FIO;


	int n;
	cin >> n;

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

	int dp[n];
	dp[n - 1] = 0;

	for (i = n - 2; i >= 0; i--)
	{
		if (a[i] >= a[i + 1])
			dp[i] = 1 + dp[i + 1];
		else
			dp[i] = 0;
	}
	// for (i = 0; i < n; i++)
	// 	cout << dp[i] << " ";
	cout << *max_element(dp, dp + n);



}








Measured memory_bytes: 5192
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    ll n; cin>>n;
    unordered_map<ll,ll>mp;
    bool flag = true;
    rep(i,0,n)
    {
        ll x; cin>>x;
        if(mp.find(x)!=mp.end())flag = false;
        mp[x]++;
    }
    if(flag)cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}
/*
5 2
. #
# #
# .
# #
. #
*/


Measured memory_bytes: 8520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD           1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define endl "\n"
#define PI 3.14159265358979323846264338327950L
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fc[100001], in[100001];
/*int pwmd(int a, int n)
{
	if (!n)
		return 1;
	int pt = pwmd(a, n / 2);
	pt *= pt, pt %= mod;
	if (n & 1)
		pt *= a, pt %= mod;
	return pt;
}*/

/*void dfs(int i,int par)
{
	for(int x:adj[i])
	{
		if(x!=par)
		{
			dfs(x,i);
		    sub[i]+=sub[x];
		}
	}
}*/
int pow(int a, int b, int m)
{
	int ans = 1;
	while (b > 0)
	{
		if (b % 2 == 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans % m;
}
/*vector<int> sq(5002);
void pre()
{
	for (int i = 0; i <= 5000; ++i)
		sq.pb(i * i);
}*/

bool compare(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b)
{
	if (a.ss.ff != b.ss.ff)
		return (a.ss.ff > b.ss.ff);
	else
		return (a.ff < b.ff);
}
bool comp(string a, string b)
{
	if (a.size() == b.size())
		return a < b;
	return a.size() < b.size();
}
int32_t main()
{
	FIO;
	int n;
	cin >> n;
	vector<int> r(11);
	vector<int> fact(12);
	int x = 26;
	int sum = 26;
	for (int i = 0; i <= 10; i++)
	{
		r[i] = sum;
		fact[i + 1] = x;
		x *= 26;
		sum += x;
	}

	string s = "";
	int i = 0;
	int sz = 0;
	for (i = 0; i <= 10; i++)
	{
		if (n <= r[i])
		{
			sz = i + 1;
			break;
		}
	}

	for (int j = 1; j <= sz - 1; j++)
	{
		n -= fact[j];
	}

	n--;
	for (int i = 0; i < sz; i++)
	{
		int rem = n % 26;
		n /= 26;
		s += (char)(rem + 'a');
	}

	reverse(s.begin(), s.end());
	cout << s << endl;

	//cout << s << endl;

}


Measured memory_bytes: 3680
#A問題

S = input()
if S == "RRR":
    print(3)
if S == "RRS"or S == "SRR" :
    print(2)
if S == "RSR"or S == "RSS" or S == "SRS" or S == "SSR":
    print(1)
if S == "SSS":
    print(0) 

Measured memory_bytes: 8912
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
        String ans = "";
        if (a > x) {
          ans = "NO";
        } else if (a + b > x) {
          ans = "YES";
        } else {
          ans = "NO";
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
from itertools import combinations
c = [list(map(int, input().split())) for _ in range(3)]

row = [[0] * 3 for _ in range(2)]

for i in range(2):
    for j in range(3):
        row[i][j] = c[i+1][j] - c[i][j]

ans = "Yes"
for i in row:
    if any(x != y for x, y in combinations(i, 2)):
        ans = "No"

print(ans)


Measured memory_bytes: 3060
#define ll long long
#define ffor(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--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int a,b,c;

	cin >> a >> b >> c;

	if(a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
list = gets.chomp.split.map(&:to_i)

s = []
list.each.with_index(0) do |x, i|
  s[i] = s[i - 1].to_i + x
end

min_diff = 1_000_000
0.upto(list.length - 1) do |i|
  x = s[list.length - 1] - s[i] * 2
  min_diff = x.abs if x.abs < min_diff
end
puts min_diff



Measured memory_bytes: 1788
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

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

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  out((N - 1) / 2);
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp


if s == 'SSS'
  puts 0
elsif s == 'SSR'  ||  s == 'SRS' || s == 'RSS' || s == 'RSR'
  puts 1
elsif s == 'RRS' || s == 'SRR'
  puts 2
elsif s == 'RRR'
  puts 3
end


Measured memory_bytes: 14256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace Template
{
    public class Scanner
    {
        public string NextLine => Console.ReadLine();
        public int NextInt => int.Parse(NextLine);
        public long NextLong => long.Parse(NextLine);
        public double NextDouble => double.Parse(NextLine);
 
        public string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }
 
    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }
 
        static void Solve() 
        {
            var scan = new Scanner();
            var val = scan.NextInt;
            Console.WriteLine((val < 1200) ? "ABC" : "ARC");
        }
 
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int debt = 100000;
		for(int i=0; i < n; i++){
			debt = debt + (debt * 5 / 100);
			if(debt % 1000 == 0){
				debt = (debt / 1000) * 1000;
			}
			else{
				debt = (debt / 1000 + 1) * 1000;
			}
		}

		System.out.println(debt);

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}

Measured memory_bytes: 11000
#include<stdio.h>
int a[200002];
int b[200000];
int c[200000];
long long hebing(int a[],int left,int mid,int right){
int s1=mid-left;
int s2=right-mid;
long long num=0;
int i,j;
for(i=0;i<s1;i++)b[i]=a[left+i];
for(i=0;i<s2;i++)c[i]=a[mid+i];
b[s1]=c[s2]=2000000000;
i=j=0;
for(int k=left;k<right;k++){
    if(b[i]<=c[j])
    a[k]=b[i++];

else {
    a[k]=c[j++];
    num+=s1-i;
}
}
return num;
}
long long hbpx(int a[],int p,int q){
int mid;
long long n1,n2,n3;
  if(p+1<q){
    mid=(p+q)/2;
    n1= hbpx(a,p,mid);
    n2=hbpx(a,mid,q);
    n3=hebing(a,p,mid,q);
  return n1+n2+n3;
  }
else return 0;
}
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
long long x = hbpx(a,0,n);
printf("%lld\n",x);
return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int tmp = 0;
    ArrayList<Integer> ans1 = new ArrayList<Integer>();
    ArrayList<Integer> maxcount = new ArrayList<Integer>();
    int count = 0;
    for (int i = 0; i < n; i++) {
      ans1.add(sc.nextInt());
    }
    int ans = Collections.max(ans1);
    for(int i = 0; i < n; i++){
      if (ans == ans1.get(i)) {
        count++;
        maxcount.add(i);
      }
    }
    for(int i = 0; i < n; i++){
      if(count >= 2){
        System.out.println(ans);
      }else{
        if(i == maxcount.get(0)){
          ans1.remove(i);
          tmp = Collections.max(ans1);
          System.out.println(tmp);
          ans1.add(i, ans); 
        }else{
          System.out.println(ans);
        }
      }
    }
  }
}

Measured memory_bytes: 101116
#include<bits/stdc++.h>
#define LL long long
#define max 1e5

using namespace std;

int gcd(int a , int b)
{
    return a%b==0? b:gcd(b,a%b);
}
inline int quickread()
{
    int X=0;
    bool flag=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') flag=0;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        X=(X<<1)+(X<<3)+ch-'0';
        ch=getchar();
    }
    if(flag) return X;
    return ~(X-1);
}

void slove()
{
    LL x,y;
    scanf("%lld%lld",&x,&y);
}
int main()
{
    int n;
    cin>>n;
    char ch[n+5];
    scanf("%s",ch);
    int ans=0;
    for(int i=0,j=n-1;;)
    {
        if(i>=j)
            break;
        if(ch[i]=='R')
            i++;
        if(ch[j]=='W')
            j--;
        if(ch[i]=='W'&&ch[j]=='R')
        {
            ans++;
            ch[j]='W';
            ch[i]='R';
            i++,j--;
        }
    }
    cout<<ans<<endl;
    //puts(ch);
}


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

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

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

Measured memory_bytes: 256
N = int(input())
a_b = [[int(x) for x in input().split()] for i in range(N)]
sorted_tasks = sorted(a_b, key=lambda x: x[1])
current_time = 0
is_no = False
for task in sorted_tasks:
    current_time += task[0]
    if task[1] < current_time:
        is_no = True
        break

if is_no:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 42832
import kotlin.math.absoluteValue
import kotlin.math.min

fun main() {
    val ln = nextLongList()
    val ans = solve(ln)
    println(ans)
}


fun solve(ln: List<Long>): Long {
    val current = ln[0]
    val moveCount = ln[1]
    val moveAmount = ln[2]


    //移動する必要がある
    if (current.absoluteValue > moveAmount) {
        //実際に移動する回数
        //moveAmountを超える回数まで移動したあとは偶数か奇数かで移動回数が決まる。0回か1回
        //moveAmountを超える回数までの移動回数は？　→　
        val actualMoveCount = if(current.absoluteValue / moveAmount > moveCount) moveCount else current.absoluteValue / moveAmount

        val temp = min(
            (current - moveAmount * actualMoveCount).absoluteValue,
            (current + moveAmount * actualMoveCount).absoluteValue
        )

        return min(
            (temp - (moveCount - actualMoveCount) % 2 * moveAmount).absoluteValue,
            (temp + (moveCount - actualMoveCount) % 2 * moveAmount).absoluteValue
        )

    } else {
        //移動回数が偶数である場合
        if (moveCount % 2 == 0L) {
            return current.absoluteValue
            //移動回数が奇数である場合
        } else {
            return min((current - moveAmount).absoluteValue, (current + moveAmount).absoluteValue)
        }
    }
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextLongList(): List<Long> {
    return readLine()!!.split(" ").map { it.toLong() }
}

fun nextString(): String {
    return readLine()!!
}

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

left_black = 0
right_white = S.count('.')
ans = right_white

for i in range(N):
    if S[i] == '#':
        left_black += 1 
    else:
        right_white -= 1
    ans = min(ans, left_black + right_white)
print(ans)

Measured memory_bytes: 3500
def main():
    while True:
        a, op, b = input().split()
        a = int(a)
        b = int(b)

        if op == '?':
            break
        elif op == '+':
            print(a + b)
        elif op == '-':
            print(a - b)
        elif op == '*':
            print(a * b)
        elif op == '/':
            print(int(a / b))
        else:
            pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 int INF = 1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	int ans = INF;
	rep(div,1<<(h-1)){
		int g = 0;
		vector<int> id(h);
		rep(i,h){
			id[i] = g;
			if(div >> i & 1) g++;
		}
		g++;
		vector<vector<int>> c(g, vector<int>(w, 0));
		rep(i,h)rep(j,w) c[id[i]][j] += (s[i][j]-'0');
		int num = g-1;
		vector<int> now(g);
		auto add = [&](int j){
			rep(i,g) now[i] += c[i][j];
			rep(i,g) if(now[i] > k) return false;
			return true;
		};
		rep(j,w){
			if(!add(j)){
				num++;
				now = vector<int>(g);
				if(!add(j)){
					num = INF;
					break;
				}
			}
		}
		chmin(ans, num);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

string a[10];
int h, w;

bool check(){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#')return false;
    }
  }
  return true;
}

bool dfs(int y, int x){
  if(y==0 && x==0)return check();
  if(y>0 && a[y-1][x]=='#'){
    a[y-1][x] = '.';
    bool tmp = dfs(y-1, x);
    if(tmp)return true;
    a[y-1][x] = '#';
  }
  if(x>0 && a[y][x-1]=='#'){
    a[y][x-1] = '.';
    bool tmp = dfs(y, x-1);
    if(tmp)return true;
    a[y][x-1] = '#';
  }
  return false;
}

int main(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    cin >> a[i];
  }
  if(a[h-1][w-1]=='.'){
    cout << "Impossible" << endl;
  }
  a[h-1][w-1] = '.';
  cout << (dfs(h-1, w-1)?"Possible": "Impossible") << endl;
}



Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)%2)
typedef long long ll;
typedef long double ld;
const ll oo=2*1000*1000*1000;
const int _cnt=1000*1000;
const int _p=1000*1000*1000+7;
int o(int x) { return x%_p; }
int gcd(int a,int b) { return (b)?gcd(b,a%b):a; }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
using namespace std;

void file_put(){
	freopen("filename.in","r",stdin);
	freopen("filename.out","w",stdout);
}

string s,t;
int q,a,b,x,y,s1,s2,n1,n2;
int f1[100005][30],f2[100005][30];

int _get(int k){
	int ans=0,t=1;
	while (t<k) {
		ans++;
		t<<=1;
	}
	return ans;
}

int __get(int k){
	return (int)(log(k)/log(2));
}

void init(){
	n1=__get(s.length());
	n2=__get(t.length());
	for (int i=0; i<s.length(); i++) f1[i][0]=(s[i]=='B')+1;
	for (int i=0; i<t.length(); i++) f2[i][0]=(t[i]=='B')+1;
	for (int j=1; j<=n1; j++)
		for (int i=0; i<=s.length()-(1<<j); i++)
			f1[i][j]=(f1[i][j-1]+f1[i+(1<<(j-1))][j-1])%3;
	for (int j=1; j<=n2; j++)
		for (int i=0; i<=t.length()-(1<<j); i++)
			f2[i][j]=(f2[i][j-1]+f2[i+(1<<(j-1))][j-1])%3;
}

int get_1(int x,int y){
	int sum=0;
	for (int i=x; i<=y; i+=(1<<(__get(y-i+1)))) sum=(sum+f1[i][__get(y-i+1)])%3;
	return sum;
}

int get_2(int x,int y){
	int sum=0;
	for (int i=x; i<=y; i+=(1<<(__get(y-i+1)))) sum=(sum+f2[i][__get(y-i+1)])%3;
	return sum;
}

int main(){
	//file_put();
	
	cin>>s;
	cin.ignore();
	cin>>t;
	cin.ignore();
	scanf("%d",&q);
	init();
	for (int i=1; i<=q; i++){
		scanf("%d%d%d%d",&x,&y,&a,&b);
		s1=get_1(--x,--y);
		s2=get_2(--a,--b);
		if (s1==s2) printf("YES\n"); else printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 24320
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
using Int = int64_t;


void calc() {

	std::string S; std::cin >> S;
	Int Q; std::cin >> Q;
	bool flag = true; //true -> そのまま, false -> 逆向き

	rep(i, Q) {
		Int T; std::cin >> T;
		if (T == 1)flag = !flag;
		if (T == 2) {
			Int F; char C; std::cin >> F >> C;
			if (F == 1) {
				if (flag)S.insert(S.begin(), C);
				else S.push_back(C);
			}
			else {
				if (flag)S.push_back(C);
				else S.insert(S.begin(), C);
			}
		}
	}

	if (!flag)std::reverse(S.begin(), S.end());

	std::cout << S << "\n";

}


int main() {

	calc();

	return 0;
}

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

using namespace std;

const int N = 1e6 + 5;
char c[N];

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

  int n;
  cin >> n;
  int g = 0;
  bool pc = true;
  for (int i = 0, x; i < n; ++i) {
    cin >> x;
    g = gcd(x, g);
    if (pc) {
      for (int j = 2; j * j <= x; ++j) {
        if (x % j) continue;
        if (c[j]) pc = false;
        c[j] = true;
        while (x % j == 0) x /= j;
      }
      if (x != 1) {
        if (c[x]) pc = false;
        c[x] = true;
      }
    }
  }
  cout << (g == 1 ? (pc ? "pairwise coprime" : "setwise coprime") : "not coprime");

  return 0;
}


Measured memory_bytes: 4584
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT
 
using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;
 
template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
 
int n;
int m;
ll len;
ll pos[100000];
int val[100000];
ll res[100001];

ll calc () {
    ll ans = 0;
    for (int i = 0; i < n; i++) ans += val[i];
    ans -= len - pos[0];
    ll cur = 0, best = 0, now = len;
    res[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        cur -= now - pos[i];
        now = pos[i];
        cur += val[i];
        best = max (best, cur);
        res[i] = best;
    }
    cur = now = 0;
    ans = max (ans, res[0]);
    for (int i = 0; i < n; i++) {
        cur -= 2 * (pos[i] - now);
        now = pos[i];
        cur += val[i];
        ans = max (ans, cur + res[i + 1]);
    }
    re ans;
}
 
int main () {
    scanf ("%d%lld", &n, &len);
    for (int i = 0; i < n; i++) scanf ("%lld%d", &pos[i], &val[i]);
    ll ans = calc ();
    for (int i = 0; i < n; i++) pos[i] = len - pos[i];
    reverse (pos, pos + n);
    reverse (val, val + n);
    ans = max (ans, calc ());
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
n,A,B,C=map(int,input().split())

l=[]

for i in range(n):
    l.append(int(input()))

def base(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
ans=10**9
for i in range(4**n):
    d=str(base(i,4)).rjust(n,'0')
    a=0
    b=0
    c=0
    ca=-10
    cb=-10
    cc=-10
    for j in range(n):
        if d[j]=="1":
            a+=l[j]
            ca+=10
        elif d[j]=="2":
            b+=l[j]
            cb+=10
        elif d[j]=="3":
            c+=l[j]
            cc+=10
    if ca<0:
        ca=0
    if cb<0:
        cb=0
    if cc<0:
        cc=0
    if a*b*c!=0:
        ans=min(ans,abs(A-a)+abs(B-b)+abs(C-c)+ca+cb+cc)
    
print(ans)










Measured memory_bytes: 3064
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto a = readln.split.to!(int[]);
    if (a[2] > a[0] + a[1]) {
        writeln("dangerous");
    } else if (a[2] > a[0]) {
        writeln("safe");
    } else {
        writeln("delicious");
    }
}



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

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

  string  s; cin >> s;
  int l = 0, r = s.size() - 1, ans = 0;
  while (true) {
    // cout << l << ' ' << r << '\n';
    if (l >= r) break;
    if (s[l] != 'x' && s[r] != 'x' && s[l] != s[r]) {
      ans = -1;
      break;
    }
    if (s[l] == s[r]) {
      l++; r--;
    } else if (s[l] == 'x') {
      l++;
      ans++;
    } else if (s[r] == 'x') {
      r--;
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 512
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();
		char[] C = S.toCharArray();

		String res = "Yes";
		for(int i=1;i<=C.length;i++) {
			if(i%2==1&&C[i-1]=='L') {
				res = "No";
				break;
			}else if(i%2==0&&C[i-1]=='R'){
				res = "No";
				break;
			}
		}
		out.println(res);

	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

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

ll dp[100010];

int main(int argc, char **argv)
{
	ll N;
	cin >> N;
	vector<ll> h(N); for (ll i = 0; i < N; ++i) cin >> h[i];

	for (ll i = 0; i < N+1; ++i) dp[i] = 1ll<<60;
	dp[0] = 0;

	for (ll i = 0; i < N; ++i)
	{
		if (i+1 < N)dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
		if (i+2 < N)dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
	}
		
	std::cout << dp[N-1]<< std::endl;
}

Measured memory_bytes: 1792
n,k=map(int,input().split())
hoge=input()
if(k==1):
  print(hoge[0].lower(),end="")
  print(hoge[1:])
elif(k==n):
  print(hoge[:n-1],end="")
  print(hoge[n-1].lower())
else:
  print(hoge[:k-1],end="")
  print(hoge[k-1].lower(),end="")
  print(hoge[k:])

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

int n;
int a[N],b[N];
int sum,ans;

main () {
    cin >> n;

    for (int i = 1; i <= n; i ++)
        cin >> a[i];

    for (int i = 1; i <= n; i ++)
        cin >> b[i];

    for (int i = 0; i <= 28; i ++) {
        int t = (1 << i);
        vector <int> v,d;

        for (int i = 1; i <= n; i ++)
            v.pb(a[i] % (t * 2));

        for (int i = 1; i <= n; i ++)
            d.pb(b[i] % (t * 2));

        sort (v.begin(),v.end());
        sort (d.begin(),d.end());

        for (int i = 0; i < v.size(); i ++) {
            int posL = lower_bound(d.begin(),d.end(),t - v[i]) - d.begin();
            int posR = upper_bound(d.begin(),d.end(),2 * t - v[i] - 1) - d.begin();
            int psL = lower_bound(d.begin(),d.end(),3 * t - v[i]) - d.begin();
            int psR = upper_bound(d.begin(),d.end(),4 * t - v[i] - 1) - d.begin();
//            cout << t << " " << v[i] <<  " " << posL << " " << posR << " " << psL << " " << psR << endl;
            ans += (posR - posL + 1) % 2;
            ans += (psR - psL + 1) % 2;
        }
        if (ans % 2)
            sum += t;
        ans = 0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 8876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int ad = abs(x - a);
	int bd = abs(x - b);
	if (ad < bd)cout << "A" << endl;
	else cout << "B" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,k,ans=1;
    cin>>n>>k;
    ans*=k;
    for(ll i=1;i<n;i++) ans*=k-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256