akhauriyash/Code-Regression huggingface dataset:
/*input
6
30 10 60 10 60 50
*/
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author masterbios
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLinovaAndKingdom solver = new CLinovaAndKingdom();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLinovaAndKingdom {
       

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            int dp[] = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            Arrays.fill(dp, (int) 1e9);
            dp[0] = 0;
            dp[1] = Math.abs(a[1] - a[0]);
            for (int i = 2; i < n; i++) {
                dp[i] = Math.min(Math.abs(a[i] - a[i - 1]) + dp[i - 1], Math.abs(a[i] - a[i - 2]) + dp[i - 2]);
            }
            out.println(dp[n - 1]);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

const int INF=1e8;
int H, W;
int blankMap[20][20];

vector<pair<int, int>> steps={{1,0},{-1,0},{0,1},{0,-1}};

int bfs(int initX, int initY) {
  int highestCost = 0;
  int simulateMap[20][20];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      simulateMap[i][j] = blankMap[i][j];
    }
  }

  queue<tuple<int, int, int>> route; //cost, x, y;

  route.push(make_tuple(0, initX, initY));

  while (!route.empty()) {
    int cost, x, y;
    tie(cost, x, y) = route.front();
    route.pop();

    if (simulateMap[y][x]<=cost) continue;

    simulateMap[y][x] = cost;
    highestCost = max(highestCost,cost);
    
    for (auto step: steps) {
      int dx = step.first;
      int dy = step.second;
 
      if (
        0<=x+dx && x+dx<W &&
        0<=y+dy && y+dy<H &&
        cost+1 < simulateMap[y+dy][x+dx]
      ) {
        route.push(make_tuple(cost+1, x+dx, y+dy));
      }
    }
  }
  return highestCost;
}

int main() {
  cin >> H >> W;

  string S[H];
  for (int i = 0; i < H; i++) {
    cin >> S[i];
    for (int j = 0; j < W; j++) {
      blankMap[i][j]= (S[i][j]=='#')? -1: INF;
    }
  }

  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j]=='#') continue;

      ans = max(ans, bfs( j, i));
    }
  }

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

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


int main(){
	int N; cin >> N;
	string s;
	cin >> s;
	int red = 0, blue = 0;

	rep(i, s.size()){
		if(s[i] == 'R') red++;
		else blue++;
	}
	if(red>blue) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
		
}









Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            st = null;
            return str;
        }

        public void resetST() {
            st = null;
        }
    }

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        String a = sc.nextLine();
        String  b = sc.nextLine();
        int count =0;
        for (int i=0;i<a.length();i++)
        {
            if(a.charAt(i)!=b.charAt(i)) {
                count++;
            }
        }
        System.out.println(count);
	// write your code here
    }
}


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

int main() {
  int n; cin >> n;
  int a, b, c;
  a = n / 100;
  b = ( n % 100 ) / 10;
  c = ( n % 100 ) % 10;
  if(a == 1) {
    a = 9;
  } else if ( a == 9 ) {
    a = 1;
  }
  if(b == 1) {
    b = 9;
  } else if ( b == 9 ) {
    b = 1;
  }
  if(c == 1) {
    c = 9;
  } else if ( c == 9 ) {
    c = 1;
  }
  cout << 100 * a + 10 * b + c << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> B(1000010);
    for (auto a : A) {
        if (B[a] != 0) {
            B[a]++;
            continue;
        }
        for (int t = a; t <= 1000000; t += a) {
            B[t] += 1;
        }
    }
    int ans = 0;
    for (auto a : A) {
        if (B[a] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7952
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int N = 1e5 + 500;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

inline ll labs(ll x){
	return (x < 0 ? -x : x);
}

inline int add(int A, int B){
	if(A + B >= MOD)
		return A + B - MOD;
	return A + B;
}

int mogu[N][2], n, dp[N][2];
ll gr[2], A[N], S[N];

bool moze(int l,int r, int k){
	return (mogu[r][k] == mogu[l][k]) || (l > r);
}

int main(){
	scanf("%d%lld%lld", &n, gr, gr + 1);
	for(int i = 1;i <= n;i++)
		scanf("%lld", S + i);
	S[0] = -INF;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 2;j++){
			mogu[i][j] = mogu[i - 1][j] + (S[i] - S[i - 1] < gr[j]);
		}
	}
	dp[0][0] = 1; dp[0][1] = 0;
	int sad[2] = {0, 0};
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < 2;j++){
			while(S[i] - S[sad[j] + 1] >= gr[j])
				sad[j]++;
			if(moze(sad[j] + 1, i - 1, !j)){
				if(sad[j] + 1 < i)
					dp[i][j] = add(dp[i][j], dp[sad[j] + 1][!j]);
				else
					dp[i][j] = add(dp[i][j], add(dp[i - 1][0], dp[i - 1][1]));
			}
		}
	}
	printf("%d\n", add(dp[n][0], dp[n][1]));
}

Measured memory_bytes: 4064
n, k = map(int, input().split())


def comb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(k) :
    ans = comb(n-k+1, i+1)*comb(k-1, i)%mod
    print(ans)

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

#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;*/  


#define ll long long int
#define ld long double
#define le length()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkp make_pair
#define ppl pair<ll,ll>
#define ppi pair<int,int>
#define ppli pair<ll,int>
#define ps push
#define mod 1000000007
#define fi first
#define se second
#define debug1(x) cout<<#x<<" = "<<x<<'\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define all(v) v.begin(),v.end()
#define mset(x) memset(x,0,sizeof(x))
#define sz size()


ll power(ll a,ll b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    ll r=power(a,b/2)%mod;
    if(b%2==0)
    return (r*r)%mod;
    else
    return (((r*r)%mod)*a)%mod;
}
#define pri 1000009
int prime[pri];
int sumprime[pri];
void sieve(int n)
{ 
    prime[0]=prime[1]=1;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(!prime[i])
        {
            for(int j=2*i;j<=n;j=j+i)
            {
                prime[j]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!prime[i])
        {
            sumprime[i]=sumprime[i-1]+1;
        }
        else
        {
            sumprime[i]=sumprime[i-1];
        }
    }
}

bool comp(const pair<ll,ll> &a, 
               const pair<ll,ll> &b)
{
       return (a.second < b.second);
}

const int N=5*1e5+9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  /*  #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ll a,b,k,k1;
    cin>>a>>b>>k;
    k1=k;
    k=k-min(a,k);
    a=a-min(a,k1);   
    b=b-k;
    cout<<a<<" "<<max((ll)0,b)<<"\n";
    return 0;
}

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

using namespace std;
#define int long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second


int N;
int A[100100];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    int prev = A[N - 1];
    int a = 0;
    int ans = 1;
    for (int i = N - 2; i >= 0; --i) {
        if (A[i] == prev) {
            a++;
            ans *= prev;
            if (a == 2)break;
            prev = -1;
        } else { prev = A[i]; }
    }
    if (a != 2) {
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    mut a:[usize;4],
    }
    a.sort();
    println!("{}",if a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9{"YES"}else{"NO"})
}

Measured memory_bytes: 2144
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> b = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            b.add(Integer.parseInt(sc.next()));
        }
        sc.close();

        // 主処理
        Deque<String> dq = new ArrayDeque<>();
        for (int i = n - 1; 0 <= i; i--) {
            for (int index = i; 0 <= index; index--) {
                if (b.get(index) == index + 1) {
                    dq.addFirst(Integer.toString(b.get(index)));
                    b.remove(index);
                    break;
                }
            }
        }
        String result = b.isEmpty() ? String.join("\r\n", dq) : "-1";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23636
def resolve():
    a, b, m = map(int, input().split())
    a_s = [int(i) for i in input().split()]
    b_s = [int(i) for i in input().split()]

    min_cost = min(a_s) + min(b_s)
    for _ in range(m):
        a_i, b_i, c_i = map(int, input().split())
        cost = a_s[a_i-1] + b_s[b_i-1] - c_i
        if cost < min_cost:
            min_cost = cost

    print(min_cost)


resolve()

Measured memory_bytes: 18488
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        ll n,k,q;
        cin >> n >> k >> q;
        ll a[n] = {0};
        for(int i=0;i<q;i++){
            int temp;
            cin >> temp;
            a[temp-1]++;
        }
        for(int i=0;i<n;i++){
            if(k<=q-a[i]){
                cout << "No" << endl;
            }
            else cout << "Yes" << endl;
        }
        return 0;
}

Measured memory_bytes: 1408
import numpy as np


def solve(n, k, aaa, fff):
    aaa = np.sort(aaa)
    fff = np.sort(fff)[::-1]

    l = 0
    r = 10 ** 12
    while l <= r:
        m = (l + r) // 2
        req = np.clip(aaa - m // fff, 0, None).sum()
        # print(aaa, m // fff, m, req)
        if req > k:
            l = m + 1
        else:
            r = m - 1
    return l


n, k = list(map(int, input().split()))
aaa = np.array(list(map(int, input().split())), dtype=np.int64)
fff = np.array(list(map(int, input().split())), dtype=np.int64)

print(solve(n, k, aaa, fff))


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

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] data = new int[2];
                data = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int h = data[0];
                int w = data[1];

                if (h == 0 && w == 0) break;
                else
                for (int i = 0; i < h; i++)
                {
                    if (i % 2 == 0) //奇数行の時
                    {
                        for (int j = 0; j < w; j++)
                        {
                        　　switch (j % 2)
                            {
                              case 0 : Console.Write("#"); break;
                              case 1: Console.Write("."); break;
                            }                           
                        }
                        Console.WriteLine();
                    }
                    else
                    {
                        for (int j = 0; j < w; j++)
                        {
                            switch (j % 2)
                            {
                                case 0: Console.Write("."); break;
                                case 1: Console.Write("#"); break;
                            }
                        }
                        Console.WriteLine();
                    }
                }
                Console.WriteLine();
            }

        }
    }
}


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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;
  set<string> gift;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    gift.insert(s);
  }
  cout << gift.size() << endl;

  return 0;
}


Measured memory_bytes: 19232
#include<iostream>
#include<cstdio>
#include<string>
#include<stack>
#include<cstdlib>
using namespace std;
int main(){
  string r;
  while(getline(cin,r)){
    r+=' ';
    int mark = -1,range = 1;
    stack <double> num;
    char ord = 'k';
    for(int i=0; i<r.size(); i++){
      if(r[i] == ' '){
	if(mark != -1){
	  double x = atof(r.substr(mark,range).c_str());
	  if(ord == '-'){x = -x;ord = 'k';}
	  num.push(x);
	  mark = -1;
	  range = 1;
	}
	else{
	  double a = num.top();
	  num.pop();
	  double b = num.top();
	  num.pop();
	  if(ord == '+'){num.push(b+a);}
	  if(ord == '-'){num.push(b-a);}
	  if(ord == '/'){num.push(b/a);}
	  if(ord == '*'){num.push(b*a);}
	  ord = 'k';
	}
      }
      else if((r[i]>='0' && r[i]<='9') || r[i] == '.'){
	if(mark == -1){mark = i;}
	else{range++;}
      }
      else{ord = r[i];}
    }
    printf("%.6lf\n",num.top());
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, c;
    cin >> s >> c;
    int ans = 2000;
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i <= s.size()-c.size(); i++)
    {
        cnt1 = 0;
        for (int j = 0, k = i; j < c.size() && k < s.size(); j++, k++)
        {
            if (s[k] != c[j])
            {
                cnt1++;
            }
        }
        ans = min(cnt1, ans);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
//using namespace atcoder;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


// edit

void solve() {
    ll N, X, M;
    cin >> N >> X >> M;

    map<ll, ll> used;
    vector<ll> vec;
    ll ans = 0;
    ll A = X;
    for (ll i = 0; i < N; ++i) {
        if (!used.count(A)) {
            used[A] = i;
            vec.push_back(A);
            ans += A;
            A = A * A % M;
        } else {
            ll T = i - used[A]; // 周期T
            ll s = i - T;
            ll d = (N - i) / T;
            ll m = (N - i) % T;
            ll add = 0;
            ll tapi = 0;
            for (int j = 0; j < T; ++j) {
                if (j < m) add += vec[s + j];
                tapi += vec[s + j];
            }
            add += tapi * d;
            ans += add;
            break;
        }
    }

    cout << ans << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
string s;
int pos;

int main()
{
  scanf(" %d\n", &n);

  while(n--){
    getline(cin, s);
    while((pos = s.find("Hoshino")) >= 0) s[pos + 6] = 'a';
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
 
#define ll              long long
#define ull             unsigned long long
#define mx              1000000
#define mod             1000000007
 
int main()
{
    ios_base::sync_with_stdio(0);
 
    int a,n;
    cin>>n;
   
        cout<<n/3<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
int main(){
    ll a, b;
    cin >> a >> b;
    string ans;
    if(a < 0 && b < 0){
        ll len = abs(a) - abs(b) + 1;
        if(len % 2 == 0)ans = "Positive";
        else ans = "Negative";
    }
    else if(a <= 0 && b >= 0)ans = "Zero";
    else ans = "Positive";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

int main(){

    int N;
    cin >> N;

    int sz = 1;
    while(true){
        if(sz * (sz - 1) > 2 * N){
            cout << "No" << endl;
            return 0;
        }
        if(sz * (sz - 1) == 2 * N){
            cout << "Yes" << endl << sz << endl;
            break;
        }
        sz++;
    }

    vector<vector<int>> ans(sz, vector<int>(sz - 1));
    int now = 1;
    rep(i, sz - 1)rep(j, sz - i - 1){
        ans[i][i + j] = now;
        ans[i + j + 1][i] = now;
        now++;
    }

    rep(i, sz){
        cout << sz - 1;
        rep(j, sz - 1)cout << ' ' << ans[i][j];
        cout << endl;
    }
    
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int f=0;
	int i;
    char ch[102];
    scanf("%s",ch);
    for(i=0;i<3;i++)
    {
    	if(ch[i]=='7')
    	{
    		f=1;
    		printf("Yes");
    		break;
		}
	}
	if(f!=1)
	printf("No");
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

ll lcm(ll A, ll B){
    ll C = Euclid(A, B);
    return A*(B/C); //()がないとオーバーフローする可能性があるので注意！
}

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


    ll A, B;
    cin >> A >> B;

    cout << lcm(A, B) << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val lIn = readLine()!!.split(" ").map(String::toInt)
    val n = lIn[0]
    val a = lIn[1]
    val b = lIn[2]
    val subMax = listOf(a, b).min()
    val subMin = listOf(0, (a + b) - n).max()
    println("$subMax $subMin")
}

Measured memory_bytes: 37844
/*
[abc105] A - AtCoder Crackers
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N, K;

ll solve() { return (N % K == 0) ? 0 : 1; }

int main() {
    cin >> N >> K;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
program prob6
    implicit none
    integer :: N, K, i, a, b, ans
    character(100005) :: S
    read(*,*) N, K, S
    
    ans = 0
    do i = 2, N-1
        if(S(i:i) == 'L')then
            if(S(i-1:i-1) == 'L')then
                ans = ans + 1
            end if
        end if
        if(S(i:i) == 'R')then
            if(S(i+1:i+1) == 'R')then
                ans = ans + 1
            end if
        end if
    end do
    if(S(1:1) == 'R')then
        if(S(2:2) == 'R')then
            ans = ans + 1
        end if
    end if
    if(S(N:N) == 'L')then
        if(S(N-1:N-1) == 'L')then
            ans = ans + 1
        end if
    end if

    a = 0
    b = 0
    do i = 1, N-1
        if(S(i:i) == 'L' .and. S(i+1:i+1) == 'R')then
            a = a + 1
        end if
        if(S(i:i) == 'R' .and. S(i+1:i+1) == 'L')then
            b = b + 1
        end if
    end do
    ans = ans + 2 * min(a, min(b, K))
    if(K > min(a, b)) then
        ans = ans + K - min(a, b)
    end if
    ans = min(ans, N-1)

    write(*,*) ans

    stop
contains
end program prob6

Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(){
	int n, l;
	cin >> n >> l;
	int res=0, rac=0;
	int j=l;
	for(int i=1; i<=n; i++, j++){
		res+=j;
	}
	j--;
	if(j<=0) cout << res-j;
	else if(l>=0) cout << res-l;
	else cout << res;
	
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = s()
if int(N) <= int(N[0]*len(N)):
    print(N[0]*len(N))
else:
    if N[0] == 9:
        print('1'+0*len(N))
    else:
        print(str(int(N[0])+1)*len(N))


Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll k;
int n,cnt,len;
int a[N],c[N],v[N];
int main() {
	int i,p;
	scanf("%d%lld",&n,&k); k++;
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	p=1;
	while (!v[p]) {
		c[++cnt]=p;
		v[p]=cnt; p=a[p]; 
	}
	if (k<=v[p]-1) {
		printf("%d\n",c[k]);
		return 0;
	}
	len=v[p]-1; cnt-=len;
	k-=v[p]-1;
	if (k%cnt==0) printf("%d\n",c[len+cnt]);
	else printf("%d\n",c[len+k%cnt]);
	return 0;
} 

Measured memory_bytes: 6012
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define pi 3.14159265358979323846
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

int main()
{

  int x,y; cin >> x >> y;
  cout << x+y/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#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>;
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; }

using Graph = vector<vector<int> >;

int node_count[200010];

void dfs(int v, int p, int cnt, Graph &G){
    node_count[v] += cnt;
    for(auto nv : G[v]){
        if(nv == p) continue;
        dfs(nv, v, node_count[v], G);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    Graph G(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int p, x;
        cin >> p >> x;
        p--;
        node_count[p] += x;
    }
    dfs(0, -1, 0, G);
    rep(i,n){
        cout << node_count[i];
        if(i != n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 26624
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		
		int[] arr = new int[N];
		for(int i = 0; i < N; i++){
			arr[i] = sc.nextInt();
		}
		
		final int MAX = N * A;
		
		long[][] DP = new long[N + 1][MAX + 1];
		DP[0][0] = 1;
		
		for(int index = 0; index < N; index++){
			final int value = arr[index];
			
			for(int prev_index = index; prev_index >= 0; prev_index--){
				
				for(int curr_value = MAX - value; curr_value >= 0; curr_value--){
					DP[prev_index + 1][curr_value + value] += DP[prev_index][curr_value];
				}
			}
		}
		
		long answer = 0;
		for(int i = 1; i <= N; i++){
			answer += DP[i][i * A];
		}
		//System.out.println(Arrays.deepToString(DP));
		
		System.out.println(answer);
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  multiset<ll> B;
  rep(i,N){
    cin >> A.at(i);
    if(i==0){
      B.insert(A.at(i));
    }else{
      auto a=B.lower_bound(A.at(i));
      if(a==B.begin()){
        B.insert(A.at(i));
      }else{
        a--;
        B.erase(a);
        B.insert(A.at(i));
      }
    }
  }
  cout << B.size() << endl;
}

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

int main(){
  string str;
  while(cin>>str){
    int j=0,i=0,joi=0,ioi=0;
    while(j<str.size()){
      if(str.find("JOI",j)==string::npos)
        break;
      j=str.find("JOI",j)+1;
      joi++;
    }
    while(i<str.size()){
      if(str.find("IOI",i)==string::npos)
        break;
      i=str.find("IOI",i)+1;
      ioi++;
    }
    cout << joi << endl << ioi << endl;    
  }
  return 0;
}

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

using namespace std;

struct Item {
	string name;
	int value;
};

Item item[100];

int newValue[100];

struct Recipe {
	int item;
	int len;
	int suppli[100];
};

Recipe recipe[100];


int main () {

	while(true) {
		for ( int i=0; i<100; i++ ) {
			item[i].value = -1;

			for ( int j=0; j<100; j++ ) {
				recipe[i].suppli[j] = 0;
			}
		}


		int itemNum;
		cin >> itemNum;

		if ( itemNum == 0 )
			break;

		for ( int i=0; i<itemNum; i++ ) {
			cin >> item[i].name;
			cin >> item[i].value;
			//cout << item[i].name << item[i].value << endl;
		}
		
		int recipeNum;
		cin >> recipeNum;
		for ( int i=0; i<recipeNum; i++ ) {
			string find;
			cin >> find;
			for ( int j=0; j<itemNum; j++ ) {
				if ( find.compare(item[j].name)==0 ) {
					recipe[i].item = j;
					break;
				}
			}

			cin >> recipe[i].len;
			//			cout << "len: " << recipe[i].len << endl;

			for ( int j=0; j<recipe[i].len; j++ ) {
				cin >> find;
				//				cout << "Find: " << find << " ";
				for ( int k=0; k<itemNum; k++ ) {
					//cout << "Now: " << item[k].name << endl;
					
					if (find.compare(item[k].name)==0) {
						//cout << "Found: " << item[j].name << endl << endl;
						recipe[i].suppli[j] = k;
						break;
					}
				}
			}
		}



		for ( int i=0; i<recipeNum; i++ ) {
			int sum = 0;
			for ( int j=0; j<recipe[i].len; j++ ) {
				sum += item[recipe[i].suppli[j]].value;
			}
			if ( item[recipe[i].item].value > sum )
				item[recipe[i].item].value = sum;
		}

		//cout << endl;
		for ( int i=0; i<itemNum; i++ ) {
			//cout << item[i].name << item[i].value << endl;
		}
			
		string find;
		cin >> find;

		for ( int i=0; i<itemNum; i++ ) {
			if ( find.compare(item[i].name)==0 ) {
				cout << item[i].value << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n;
	int ans = 0;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}
	for (int i = 0; i < n; i++) {
		int min_i = i;
		int v = vec.at(min_i);
		for (int j = i; j < n; j++) {
			if (vec.at(j) < vec.at(min_i)) {
				min_i = j;
			}
		}
		if (min_i != i) ans++;
		vec.at(i) = vec.at(min_i);
		vec.at(min_i) = v;
	}
	for (int i = 0; i < n; i++) {
		cout << vec.at(i);
		if (i != n - 1) cout << ' ';
	}
	cout << endl;
	cout << ans << endl;
}


Measured memory_bytes: 3120
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    A, B, C = readnums()
    if A == B and B == C:
        if A == 1:
            print(0)
        else:
            print(-1)
    else:
        ans = 0
        while all([not A % 2, not B % 2, not C % 2]):
            A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
            ans += 1

        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      2*acos(0.0)
#define pii                     pair< ll, ll >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     100005

using namespace std;

ll dist[MAX];

ll bfs(ll k)
{
    ms(dist,-1);
    deque<int> dq;
    dq.push_back(1);
    dist[1]=1;
    while(!dq.empty())
    {
        int u=dq.front();
        dq.pop_front();
        if(u%k==0)return dist[u%k];
        if(dist[(u+1)%k]==-1 || dist[(u+1)%k]>dist[u]+1)
        {
            int x =(u+1)%k;
            dist[x]=dist[u]+1;
            dq.push_back(x);
//            if(x==0)return dist[x];
        }
        if(dist[(u*10)%k]==-1 || dist[(u*10)%k]>dist[u])
        {
            int x = (u*10)%k;
            dist[x]=dist[u];
            dq.push_front(x);
//            if(x==0)return dist[x];
        }
    }
}


int main()
{
//    READ;
//    WRITE;
//    ms(dp,-1);
    int k;
    cin>>k;
    int ans=bfs(k);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, M,wa, K, W,ans,k[5];
string s,t[100];
bool a, b, c;
int main() {
	cin >> s;
	a = b = c = false;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a') {
			a = true;
		}
		if (s[i] == 'b') {
			b = true;
		}
		if (s[i] == 'c') {
			c = true;
		}
	}
	if (a == true && b == true && c == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    sort(a.begin(), a.end(), greater<int>());
    cout << 10*a[0] + a[1] + a[2] << endl;
}

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

void swap(int *x, int *y){
	int z = *x;
	*x = *y;
	*y = z;
}

int gcd(int x, int y){
	int r;

	if(x < y)
		swap(&x, &y);

	while(y > 0){
		r = x % y;
		x = y;
		y = r;
	}

	return x;
}

int main(){
	int x, y, ans;

	cin>>x>>y;

	ans = gcd(x, y);

	cout<<ans<<endl;

	return 0;
}

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

flg = True
for a in A:
  if a%2 > 0:
    continue
  if a%3 == 0 or a%5 == 0:
    continue
  flg = False
  break
  
print("APPROVED" if flg else "DENIED")

Measured memory_bytes: 3060
import sys
import heapq
import random
import collections
import math

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def solve(grid):  # fix inputs here

    a,b = zip(*grid)
    a = sorted(a)
    b = sorted(b)
    
    if len(a)%2 == 1:
        return b[len(a)//2] - a[len(a)//2] + 1

    lb = (a[len(a)//2] + a[len(a)//2-1])/2
    ub = (b[len(a)//2] + b[len(a)//2-1])/2
    # print(lb,ub)
    return int(2 * (ub - lb) + 1)


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return


# for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
nrows = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer
# lst = list(map(int,input().split()))

# read matrix and parse as integers (after reading read nrows)
# lst = list(map(int,input().split()))
# nrows = lst[0]  # index containing information, please change
grid = []
for _ in range(nrows):
    grid.append(list(map(int,input().split())))

res = solve(grid)  # please change

# Google - case number required
# print("Case #{}: {}".format(case_num+1, res))

# Codeforces - no case number required
print(res)


Measured memory_bytes: 61972
#include<stdio.h>

int main(void)
{
  int n,i,j,k=0;
  int a4[25],a7[14],ans[500];
  scanf("%d",&n);
  for(i=0;i<25;i++)
    {
      a4[i] = i*4;
    }
  for(i=0;i<14;i++)
    {
      a7[i] = i*7;
    }
  for(i=0;i<25;i++)
    {
      for(j=0;j<14;j++)
	{
	  ans[k] = a4[i]+a7[j];
	  k++;
	}
    }
  for(i=0;i<k;i++)
    {
      if(ans[i] == n)
	{
	  printf("Yes\n");
	  return 0;
	}
    }
  printf("No\n");
  return 0;
}
  
      

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  set<char> t;
  rep(i, s.size()) t.insert(s[i]);
  if(t.size() == s.size())cout << "yes" << endl;
  else cout << "no" << endl;
  system("pause");
}

Measured memory_bytes: 504
import sys
readline = sys.stdin.readline

def solve():
    N, K = map(int, readline().split())
    P = [v - 1 for v in map(int, readline().split())]
    C = list(map(int, readline().split()))


    ans = -10**10

    for i in range(N):
        moves = 1
        cur = P[i]
        score = C[cur]
        ans = max(score, ans)
        visited = {cur: (moves, score)}

        while P[cur] not in visited and moves < K:
            cur = P[cur]
            moves += 1
            score += C[cur]
            visited[cur] = (moves, score)

            ans = max(ans, score)
        
        if moves == K:
            continue
        
        cur = P[cur]
        moves += 1
        score += C[cur]

        T = moves - visited[cur][0]
        D = score - visited[cur][1]

        if D < 0:
            continue
        
        nloops = K - moves
        moves += T * (nloops // T)
        score += D * (nloops // T)

        ans = max(ans, score)

        while moves < K:
            cur = P[cur]
            moves += 1
            score += C[cur]
            ans = max(ans, score)
    
    print(ans)

solve()

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

int main() {
    string s;
    cin >> s;
    ll ans = s.size();
    bool beforeHasRemain = false;
    for(int i=0;i<s.size();i++){
        ll num=1;
        
        while(i<s.size()&&s[i] ==s[i+1]){
            num++;
            i++;
        }
        
        // cerr <<"i="<<i <<"num="<<num<<endl;
        ans -= (num+1)/3;
        if((num+1)%3==0){
            i++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)
int arr[21][21];
int n;
int dp[21][1<<21];
ll rec(int m,int f)
{
    if(m==-1) return 1;
    if(dp[m][f]!=-1) return dp[m][f];
    else
    {
        int i;
        dp[m][f]=0;
        rep(i,0,n)
        {
            if(arr[m][i] && (f&(1<<i)))
            {
                dp[m][f]+=rec(m-1,f^(1<<i));
                dp[m][f]%=mod;
            }
        }
        return dp[m][f];
    }
}

int main()
{
    int i,j,t;
    boost;
    cin>>n;
    rep(i,0,n)
    {
        rep(j,0,n)
        {
            cin>>arr[i][j];
        }
    }
    rep(i,0,n)
    {
        rep(j,0,1<<21)
        {
            dp[i][j]=-1;
        }
    }
    int f=1<<n ;
    f--;
    cout<<rec(n-1,f)%mod;
    

    return 0;
}



Measured memory_bytes: 172288
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    set<int> d;
    int cnt = 0;
    bool ans = false;
    for(int i = 1; i <= b; i++){
        int e  = (a * i) % b;
        if(d.count(e))
        cnt++;
        else
        d.insert(e);
        if(c == e)
        ans = true;
    }
    if(c == 0)
    ans = true;
if(ans)
cout << "YES" << endl;
else
cout << "NO" << endl;
}

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

int main(){
	string s;
	int ocnt, xcnt, allcnt;
	cin >> s;
	ocnt = 0;
	xcnt = 0;
	for(int i=0; i<s.length(); i++){
		if(s[i] == 'o'){
			ocnt++;
		}else{
			xcnt++;
		}
	}

	if(15 - xcnt >= 8){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

sum = [[0] * (w+1) for _ in range(h+1)]
for i in range(h):
    for j in range(w):
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (1 if s[i][j] == '1' else 0)

ans = h + w - 2
for ptn in range(1<<h-1):
    cand = 0

    sep = [0]
    for i in range(h-1):
        if((ptn >> i) & 1):
            sep.append(i+1)
            cand += 1
    sep.append(h)

    left = 0
    for pos in range(w):
        cur = []
        for i in range(len(sep)-1):
            cur.append(sum[sep[i+1]][pos+1] - sum[sep[i+1]][left] - sum[sep[i]][pos+1] + sum[sep[i]][left])
        if max(cur) > k:
            if left == pos:
                cand = h * w
                break
            else:
                cand += 1
                left = pos
    ans = cand if cand < ans else ans

print(ans)


Measured memory_bytes: 43484