akhauriyash/Code-Regression huggingface dataset:
n = int(input().strip())
c = 0

if 1 <= n:
    if n < 10:
        c += n
    else:
        c += 9

if 100 <= n:
    if n < 1000:
        c += n - 99
    else:
        c += 900

if 10000 <= n:
    if n < 100000:
        c += n - 9999
    else:
        c += 90000

print(c)

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

using namespace std;

#define int long long

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

	//freopen("output", "w", stdout);

	int n, l;
	cin >> n >> l;
	int sum = 0, best = 1e9, help = 1;
	for (int i = 1; i <= n; i++)
	{
		sum += l + i - 1;
		if (best > abs(l + i - 1))
		{
			best = abs(l + i - 1);
			help = l + i - 1;
		}
	}

	cout << sum - help << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=list(map(int,list(input())))
    N=len(S)
    if N%2==0:
        left=N//2-1
        right=N//2
        ans=N//2
        if S[left]==S[right]:
            x=S[left]
            while left-1>=0 and S[left-1]==x:
                left-=1
            while right+1<N and S[right+1]==x:
                right+=1
            ans+=min(N//2-left,right-N//2+1)
    else:
        left=N//2
        right=N//2
        x=S[N//2]
        ans=N//2+1
        if left-1>=0 and S[left-1]==x:
            while left-1>=0 and S[left-1]==x:
                left-=1
        if right+1<N and S[right+1]==x:
            while right+1<N and S[right+1]==x:
                right+=1
        ans+=min(N//2-left,right-N//2)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49392
x=int(input())
if x==2:
    print(2)
else:
    t=1
    if x%2==0:
        x+=1
    while t==1:
        t=0
        k=int(x/2)
        for i in range(3,k):
            if x%i==0:
                t=1
                x+=2
                break
    print(x)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a,b,men,shuu;
		a=scan.nextInt();
		b=scan.nextInt();
		men=a*b;
		shuu=2*(a+b);
		System.out.println(men + " " + shuu);

	}

}

Measured memory_bytes: 26124
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

ll lcm (ll a, ll b) {
	return (a / gcd (a, b)) * b;
}

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	int n,m;
	cin >> n >> m;
	pii ps;
	vector<pair<int, int>> vss;
	REP(i, m) {
		pii pss = make_pair(i+1, 0);
		vss.pb(pss);
	}
	REP(i, n) {
		int k;
		cin >> k;
		REP(j, k) {
			int a;
			cin >> a;
			vss.at(a-1).second += 1;
		}
	}
	int ans = 0;
	for(auto v:vss) {
		if (v.second == n) {
			ans += 1;
		}
	}
	p(ans);
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=200005,INF=0x3F3F3F3F,MAXLG=25;

int N,V,lgV,X[MAXN];
int f1[MAXN*4],f2[MAXN*4];
vector<int> seg[MAXLG];
bool ans[MAXN];

int main()
{
	scanf("%d%d",&N,&V);
	for(int i=1;i<=N;i++)
		scanf("%d",&X[i]);
	X[0]=-INF;
	X[N+1]=INF;

	for(int d=V;;d/=2)
	{
		lgV++;
		for(int i=1;i<=N+1;i++)
			if(X[i]-X[i-1]>d)
				seg[lgV].push_back(i-1);
		seg[lgV].push_back(N+1);
		if(d==0)
			break;
	}

	if((int)seg[1].size()-2>lgV)
	{
		for(int i=1;i<=N;i++)
			puts("Impossible");
		return 0;
	}

	f1[0]=0;
	for(int s=1;s<(1<<lgV);s++)
		for(int i=1;i<=lgV;i++)
			if((s&(1<<(i-1))))
			{
				int ts=s^(1<<(i-1));
				f1[s]=max(f1[s],f1[ts]);
				if(f1[s]==N)
					continue;
				auto it=upper_bound(seg[i].begin(),seg[i].end(),f1[ts]);
				f1[s]=max(f1[s],*it);
			}
	memset(f2,0x3F,sizeof f2);
	f2[0]=N+1;
	for(int s=1;s<(1<<lgV);s++)
		for(int i=1;i<=lgV;i++)
			if((s&(1<<(i-1))))
			{
				int ts=s^(1<<(i-1));
				f2[s]=min(f2[s],f2[ts]);
				if(f2[s]==1)
					continue;
				auto it=lower_bound(seg[i].begin(),seg[i].end(),f2[ts]-1);
				if(it==seg[i].begin())
                    continue;
                it--;
				f2[s]=min(f2[s],*it+1);
			}

    for(int i=1;i<(int)seg[1].size()-1;i++)
	{
		int l=seg[1][i-1]+1,r=seg[1][i];
		for(int s=0;s<(1<<lgV);s+=2)
		{
			int ts=((1<<lgV)-1)^s^1;
			if(f1[s]>=l-1&&f2[ts]<=r+1)
			{
				ans[i]=true;
				break;
			}
		}
	}
	for(int i=1,j=1;i<=N;i++,j=(i>seg[1][j]?j+1:j))
		puts(ans[j]?"Possible":"Impossible");

	return 0;
}


Measured memory_bytes: 10740
<?php
fscanf(STDIN, "%s", $s);
$s_1 = substr($s, 0, 1);
$s_2 = substr($s, 1, 1);
$s_3 = substr($s, 2, 1);
$s_4 = substr($s, 3, 1);

if ($s_1 === $s_2 && (substr_count($s, $s_1) === 2) && substr_count($s, $s_4) === 2) {
    echo 'Yes';
} elseif ($s_1 === $s_3 && (substr_count($s, $s_1) === 2) && substr_count($s, $s_4) === 2) {
    echo 'Yes';
} elseif ($s_1 === $s_4 && (substr_count($s, $s_1) === 2) && substr_count($s, $s_2) === 2) {
    echo 'Yes';
} elseif ($s_3 === $s_2 && (substr_count($s, $s_3) === 2) && substr_count($s, $s_4) === 2) {
    echo 'Yes';
} else {
    echo 'No';
}


Measured memory_bytes: 16116
N = int(input().strip())
H = list(map(int, input().strip().split()))
counter = 0
maxi = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        counter += 1
    else:
        maxi = max(maxi, counter)
        counter = 0
maxi = max(maxi, counter)

print(maxi)


Measured memory_bytes: 14252
#include <stdio.h>
int main(void)
{
	int n,a,b,c,d;
	scanf("%d",&n);
	a=n/1000; b=n/100%10; c=n/10%10; d=n%10;
	if(a==b && b==c){
		printf("Yes\n");
	}else if(b==c && c==d){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
# Problem A - Kenken Race

# input
N, A, B, C, D = map(int, input().split())
S = input()

# initialization
is_ok = True

# search
if C>D:
    # b check
    if "##" in S[B-1:D] or not "..." in S[B-2:D+1]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False
else:
    # b check
    if "##" in S[B-1:D]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False

# output
if is_ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 40816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0064
{
	class Program
	{
		static void Main(string[] args)
		{
			int	secret_num	= 0;
			var	s	= "";
			while( (s = Console.ReadLine()) != null ) {
				for( int i = 0; i < s.Length; i++ ) {
					if( (s[ i ] >= '0') && (s[ i ] <= '9') ) {
						int	num	= s[ i ] - '0';
						for( i += 1; i < s.Length; i++ ) {
							if( (s[ i ] >= '0') && (s[ i ] <= '9') ) {
								num	*= 10;
								num	+= s[ i ] - '0';
							} else {
								break;
							}
						}
						secret_num	+= num;
					}
				}
			}
			Console.WriteLine( secret_num );
		}
	}
}

Measured memory_bytes: 5576
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
li = []
temp = input().split()
for i in range(n):
    temp1 = [int(temp[i]), True]
    li.append(temp1)
    
for i in range(m):
    a,b = map(int,input().split())
    
    if li[a-1][0] < li[b-1][0]:
        li[a-1][1] = False
    elif li[a-1][0] > li[b-1][0]:
        li[b-1][1] = False
    else :
        li[a-1][1] = li[b-1][1] = False
cnt = 0
for elem in li:
    if elem[1] == True:
        cnt += 1
print(cnt)

Measured memory_bytes: 28064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

vector<int> x, y, h;

bool solve(const int cx, const int cy, const int pos, int &H) {
  int cand = h[pos] + abs(x[pos] - cx) + abs(y[pos] - cy);
  for(int i = 0; i < x.size(); i++) {
    int work = max(cand - abs(x[i] - cx) - abs(y[i] - cy), 0);
    if(h[i] != work) return false;
  }
  H = cand;
  return true;
}

int main() {
  int N; cin>>N;
  x = vector<int>(N);
  y = vector<int>(N);
  h = vector<int>(N);
  int pos = 0;
  REP(i,N) {
    cin>>x[i]>>y[i]>>h[i];
    if(h[i] > 0) pos = i;
  }
  for(int cx = 0; cx <= 100; cx++) {
    for(int cy = 0; cy <= 100; cy++) {
      int H;
      bool ret = solve(cx, cy, pos, H);
      if(ret) {
	cout << cx << " " << cy << " " << H << endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[939131],b[30000];
main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];

    }
    int s1=0,s2=0;
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        s2+=b[i];
    }
    int ans=0;
    for (int i=0; i < n; i++)
    {
        ans =max(ans, s1+s2+a[i]);
        s1+=a[i];
        s2-=b[i];
    }
    cout << ans << endl;
}


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

int calcfrog1(vector<int> &arr){
	vector<int> dp(arr.size(), 0);
	int N = arr.size();
	dp[N-1] = 0;
	dp[N-2] = abs(arr[N-2] - arr[N-1]);
	for(int i=N-3;i>=0;i--){
		//f(i,i+2) + f(i+2,N)
		int val1 = abs(arr[i] - arr[i+2]) + dp[i+2];
		//f(i,i+1) + f(i+1,N)
		int val2 = abs(arr[i] - arr[i+1]) + dp[i+1];
		dp[i] = min(val1, val2);
	}
	return dp[0];
}

int main() {
	// your code goes here
	int N = 0;
	cin>>N;
	vector<int> arr;
	while(N--){
		int val = 0;
		cin>>val;
		arr.push_back(val);
	}
	cout<<calcfrog1(arr);
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<algorithm>
#define  M 1e6
using namespace std;
typedef long long int ll;
vector<ll> x,y;
ll f(int n){
	return n*(n+1)*(n+2)/6;
}
void make(void){
	int i=1;
while(f(i)<M){
x.push_back(f(i));
if(f(i)%2==1){
	y.push_back(f(i));
}
	i++;
}
}
int main(void){
	make();
vector<ll> num(M,6),num2(M,1000000);
for(ll i=0;i<x.size();i++){
num[x[i]]=1;
}
for(ll i=0;i<y.size();i++){
	num2[y[i]]=1;
}
for(ll i=0;i<x.size();i++){
	for(ll j=x[i];j<M;j++){
		num[j]=min(num[j],num[j-x[i]]+1);
	}
}
for(ll i=0;i<y.size();i++){
	for(ll j=y[i];j<M;j++){
		num2[j]=min(num2[j],num2[j-y[i]]+1);
	}
}
int n;

while(1){
	cin>>n;
	if(n==0)break;

	cout<<num[n]<<" "<<num2[n]<<endl;
}
return 0;
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ((A - C)*(A - C) <= D*D){
    cout << "Yes" <<endl;
  }else{
    if ((A-B)*(A-B) <= D*D and (C-B)*(C-B) <= D*D){
      cout << "Yes" <<endl;
    }else{
      cout << "No" <<endl;
    }
  }

}

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

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];

  double sum = 0.0;
  rep(i, n) sum += 1.0 / a[i]; 

  cout << fixed << setprecision(6) << 1.0 / sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

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

    if(sz(s) <= k)cout << s << endl;
    else{
        rep(i,0,k-1)cout << s[i];
        cout << "..." << endl;
    }

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int chcnt[] = new int[26];
        String str = "";
        while(sc.hasNext()){
            str = sc.nextLine();
            str = str.toLowerCase();
            for(int i = 0; i < str.length(); i++ ){
                char ch = str.charAt(i);
                if(ch <= 'z' && ch >= 'a') chcnt[ch - 'a']++;
            }
        }
        for(int i = 0; i < chcnt.length; i++){
            System.out.println((char)('a' + i) + " : " + chcnt[i]);
        }
    }
}

Measured memory_bytes: 26120
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    int i;
    for(i=0;i<n;i++)
    {
        int f=n-4*i;
        if(f>=0 && f%7 ==0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        
    }
     cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List (foldl')
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V

main :: IO ()
main = do
  [n, m] <- map read <$> words <$> getLine
  solve n <$> replicateM n getLine >>= print

solve :: Int -> [String] -> Int
solve n ss = minimum ps
  where v = V.unfoldr (\(ss, (w,b,r)) ->
                        case ss of
                         (s:ss) -> let (w',b',r') = cnt s in Just ((w+w',b+b',r+r'), (ss, (w+w',b+b',r+r')))
                         _ -> Nothing
                      ) (ss,(0,0,0))
        ps = do
          wi <- [0 .. n-3]
          bi <- [wi+1 .. n-2]
          let (w1, b1, r1) = v ! wi
          let (w2, b2, r2) = v ! bi
          let (w3, b3, r3) = v ! (n-1)
          return $ b1 + r1 + w2 - w1 + r2 - r1 + w3 - w2 + b3 - b2
          
cnt :: String -> (Int, Int, Int)
cnt s = foldl' (\(w, b, r) c -> case c of
                       'W' -> (w+1, b, r)
                       'B' -> (w, b+1, r)
                       _ -> (w, b, r+1)
               ) (0, 0, 0) s



Measured memory_bytes: 5892
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: u128,
        a: [u128;n],
        b: [u128;m],
    }

    let mut cumulative_sum_a = vec![0; n + 1];
    for i in 1..n + 1 {
        cumulative_sum_a[i] = cumulative_sum_a[i - 1] + a[i - 1];
    }

    let mut cumulative_sum_b = vec![0; m + 1];
    for i in 1..m + 1 {
        cumulative_sum_b[i] = cumulative_sum_b[i - 1] + b[i - 1];
    }

    let mut ans = 0;
    let a_max = lower_bound(&cumulative_sum_a, k);
    for a_pos in 0..a_max {
        let b_pos = lower_bound(
            &cumulative_sum_b,
            std::cmp::max(k - cumulative_sum_a[a_pos], 0),
        ) - 1;

        //println!("a = {}, b = {}", a_pos, b_pos);
        ans = std::cmp::max(ans, a_pos + b_pos);
    }

    println!("{}", ans);
}

fn lower_bound(sorted_array: &Vec<u128>, key: u128) -> usize {
    //println!("{:?}", sorted_array);
    //println!("key = {}", key);
    let (mut left, mut right) = (0, sorted_array.len() - 1);
    while left <= right {
        let middle = (right + left) / 2;
        if sorted_array[middle] > key {
            right = middle - 1;
        } else {
            left = middle + 1;
        }
    }
    //println!("left = {}", left);
    left
}


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

struct data{
  int left;
  int right;
  int depth;
  data(int a=-1,int b=-1,int c=-1){
    left=a;
    right=b;
    depth=c;
  }
};

data t[1000000];
int sz=1;

ll N,L;
ll ans=0;

void dfs(int pos,ll depth=0){
  if(pos==-1){
    ll d=(L-depth)+1;
    ans^= (  d&-d );
    return;
  }
  if(depth==L)return;
  if( t[pos].left == t[pos].right )return;
  dfs(t[pos].left,depth+1);
  dfs(t[pos].right,depth+1);
}



int main(){

  vector<int> a(100005);
  /*
  for(int i=0;i<=50;i++){
    set<int> st;
    st.insert(0);
    
    int tmp=0;
    for(int j=i-1;j>=0;j--){
      tmp^=a[j];
      st.insert(tmp);
    }

    int p=0;
    while(st.count(p)==1)p++;
    int k=i+1;
    cout<<i<<' '<<p<<' '<< (k&-k) <<endl;

    a[i]=p;
  }
  */
  t[0]=data(-1,-1,0);
  
  cin>>N>>L;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    
    int pos=0;  
    for(char ch:s){
      int next;
      if(ch=='0'){
        if(t[pos].left==-1){
          t[pos].left = sz;
          sz++;
        }
        next=t[pos].left;
      }else{
        if(t[pos].right==-1){
          t[pos].right = sz;
          sz++;
        }
        next=t[pos].right;
      }
      t[next].depth=t[pos].depth+1;
      pos=next;
    }
  }

  dfs(0);

  cout<< (ans ? "Alice" : "Bob" )<<endl;
  return 0;
}


Measured memory_bytes: 14108
def f(b, n):
    if n < b:
        return n
    elif n >= b:
        return f(b, n//b) + (n % b)

n, s = [int(input()) for _ in range(2)]
if s == n:
    ans = n+1
elif n < s:
    ans = -1
else:
    ans = -1
    for i in range(2, int(n**0.5)+1):
        if f(i, n) == s:
            ans = i
            break
    if ans == -1:
        for i in range(int(n**0.5), 0, -1):
            b = (n - s) / i + 1
            if b == int(b) and f(int(b), n) == s:
                ans = int(b)
                break
print(ans)

Measured memory_bytes: 3316
#include<iostream>

using namespace std;

int main() {
	int n;
	int a, b;
	int Sa = 0, Sb = 0;
	
	while(1) {
		cin >> n;
		if(!n) break;
		Sa = Sb = 0;
		for( int i=0; i<n; i++) {
			cin >> a >> b;
			if(a>b) Sa += a + b;
			else if(a<b) Sb += a + b;
			else { Sa += a; Sb += b;}
		}
		cout << Sa << " " << Sb << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int res = 0;
    for (int i = 1; i < N; ++i) {
        set<char> set_a;
        set<char> set_b;
        for (int j = 0; j < i; ++j) set_a.insert(S[j]);
        for (int j = i; j < N; ++j) set_b.insert(S[j]);
        int tmp = 0;
        for (auto x: set_a) {
            if (set_b.count(x) > 0) ++tmp;
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}



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

const int mod = 998244353;

template<int MOD>
struct ModInt {
  unsigned x;
  ModInt() : x(0) { }
  ModInt(signed sig) : x(sig) {  }
  ModInt(signed long long sig) : x(sig%MOD) { }
  int get() const { return (int)x; }
  ModInt pow(int p) { ModInt res = 1, a = *this; while (p) { if (p & 1) res *= a; a *= a; p >>= 1; } return res; }
 
  ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
  ModInt &operator/=(ModInt that) { return (*this) *= that.pow(MOD - 2); }
 
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  bool operator<(ModInt that) const { return x < that.x; }
  friend ostream& operator<<(ostream &os, ModInt a) { os << a.x; return os; }
};
typedef ModInt<mod> mint;

signed main() {
	int n,s;cin>>n>>s;
	vector<int>a(n);
	for(int &i:a)cin>>i;
	mint dd[n+1][s+1];
	memset(dd,0,sizeof dd);
	mint two=2;
	dd[0][0]=two.pow(n);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=s;j++){
			dd[i][j]+=dd[i-1][j];
			if(j>=a[i-1])
				dd[i][j]+=dd[i-1][j-a[i-1]]/two;
		}
	}
	cout<<dd[n][s];
}


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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  int sum = N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++)
    for (int j = 1; j <= D; j++)
      if ((j * A.at(i) + 1) <= D)
        sum++;
      else
        break;
  cout << sum + X << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

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) || (b < c && c < a)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll mod=1000000007;
int main(){
    string s;
    cin>>s;
    string t;
    vector<string> n;
    for(int i=0;i<s.size();i++){
        t+=s.at(i);
        if(i==0){
            n.push_back(t);
            t={};
        }
        else {
            if(n.at(n.size()-1)==t)continue;
            else{
                n.push_back(t);
                t={};
            }
        }
}
cout<<n.size()<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string s, ans="Yes";
	map<char, int> m;
	cin >> s;
	for(char x: s)++m[x];
	for (auto const& x: m)
		if(x.second % 2 == 1) ans = "No";
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n, h[nax], k;


int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1 ;i <= n; i ++){
        scanf("%d", h + i);
    }
    sort(h + 1 , h + 1 + n);
    if(k >= n ){
        return !printf("%d\n", 0);
    }
    long long sum = 0;
    for(int i = 1 ;i <= n - k; i ++){
        sum += h[i];
    }
    cout << sum << endl;
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int arr[100001] = {};
  rep(i, 0, n) {
    int a;
    cin >> a;
    arr[a]++;
  }

  int ans = 0;
  rep(i, 2, 100001) { chmax(ans, arr[i] + arr[i - 1] + arr[i - 2]); }
  cout << ans << endl;
}


Measured memory_bytes: 640
a_s, b_s = input().split()
a_i = int(a_s)
b_i = int(b_s)

a,b = "",""
for _ in range(a_i):
  b += b_s
for _ in range(b_i):
  a += a_s

ans = []
ans.append(a)
ans.append(b)

ans.sort()

print(ans[0])

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
odd = 0
even = 0
even4 = 0
 
for num in A:
    if num % 2 == 1:
        odd += 1
    else:
        even += 1
    if num % 2 == 0 and num % 4 != 0:
        even4 += 1
even4 = even - even4
    
if odd == 0 or odd <= even4 or (odd + even4 == N and odd == even4 + 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20076
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin. tie(0);
using namespace std;
typedef long long ll;
ll a,b,k,n,m,sum,h,w;
const ll maxn=100005;
const ll mod=1e9+7;
ll num[maxn];
char g[2005][2005];
ll l[2005][2005],r[2005][2005],u[2005][2005],d[2005][2005];
string s;
int main()
{
    //IOS
    while(cin>>h>>w)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        memset(u,0,sizeof(u));
        memset(d,0,sizeof(d));
        rep1(i,h) rep1(j,w) cin>>g[i][j];
        ll now=0;
        rep1(i,h)
        {
            now=0;
            rep1(j,w)
            {
                if(g[i][j]=='#') now=j;
                else
                {
                    l[i][j]=now;
                }
            }
        }
        rep1(i,w)
        {
            now=0;
            rep1(j,h)
            {
                if(g[j][i]=='#') now=j;
                else
                {
                    u[j][i]=now;
                }
            }
        }
        for(int i=h;i>0;i--)
        {
            now=w+1;
            for(int j=w;j>0;j--)
            {
                if(g[i][j]=='#') now=j;
                else
                {
                    r[i][j]=now;
                }
            }
        }
        for(int i=w;i>0;i--)
        {
            now=h+1;
            for(int j=h;j>0;j--)
            {
                if(g[j][i]=='#') now=j;
                else
                {
                    d[j][i]=now;
                }
            }
        }
        ll ans=0;
        rep1(i,h)
        {
            rep1(j,w)
            {
                if(g[i][j]=='.')
                {
                    ans=max(ans,r[i][j]-l[i][j]+d[i][j]-u[i][j]-2);
                    //cout<<ans<<" "<<i<<" "<<j<<" "<<l[i][j]<<" "<<r[i][j]<<" "<<u[i][j]<<" "<<d[i][j]<<"\n";
                }
            }
        }
        cout<<ans-1<<"\n";
    }

}


Measured memory_bytes: 129792
#include<cstdio>

using namespace std;

int main(void){
	char in[12][12],data[10];
	int i,j,flag=0,out=0,y,x;

	for(i=0;i<12;i++){
		for(j=0;j<12;j++){
			in[i][j]='0';
		}
	}

	while(1){
		for(i=2;i<10;i++){
			if(scanf("%s",data)==EOF)	flag=1;
			if(flag==1)	break;
			for(j=0;j<8;j++){
				in[i][j+2]=data[j];
			}
		}
		if(flag==1)	break;

		for(i=2;i<10;i++){
			for(j=2;j<10;j++){
				if(in[i][j]=='1'){
					y=i;
					x=j;
					out=1;
					break;
				}
			}
			if(out==1)	break;
		}
		out=0;

		if(in[y][x+1]=='1' && in[y+1][x]=='1' && in[y+1][x+1]=='1')	printf("A\n");
		if(in[y+1][x]=='1' && in[y+2][x]=='1' && in[y+3][x]=='1')	printf("B\n");
		if(in[y][x+1]=='1' && in[y][x+2]=='1' && in[y][x+3]=='1')	printf("C\n");
		if(in[y+1][x-1]=='1' && in[y+1][x]=='1' && in[y+2][x-1]=='1')	printf("D\n");
		if(in[y][x+1]=='1' && in[y+1][x+1]=='1' && in[y+1][x+2]=='1')	printf("E\n");
		if(in[y+1][x]=='1' && in[y+1][x+1]=='1' && in[y+2][x+1]=='1')	printf("F\n");
		if(in[y][x+1]=='1' && in[y+1][x-1]=='1' && in[y+1][x]=='1')	printf("G\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n,a,b,c,d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	a --;
	b --;
	c --;
	d --;
	
	if(c<d){
		for(int i = b ; i+1 <= d ; i ++){
			if(s[i] == '#' && s[i+1] == '#'){
				puts("No");
				return 0;
			}
		}
		for(int i = a ; i+1 <= c ; i ++){
			if(s[i] == '#' && s[i+1] == '#'){
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	else {
		for(int i = b ; i+1 <= d ; i ++){
			if(s[i] == '#' && s[i+1] == '#'){
				puts("No");
				return 0;
			}
		}
		bool ret = false;
		for(int i = b ; i <= d ; i ++){
			ret |= s[i-1] == '.' && s[i] == '.' && s[i+1] == '.';
		}
		if(!ret){
			puts("No");
			return 0;
		}
		for(int i = a ; i+1 <= c ; i ++){
			if(s[i] == '#' && s[i+1] == '#'){
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
}

Measured memory_bytes: 640
#include <math.h>
#include <stdio.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  char a;
  cin >> a;
  if (a >= 'a' && a <= 'z') {
    cout << 'a' << endl;
  } else if (a >= 'A' && a <= 'Z') {
    cout << 'A' << endl;
  }
}

Measured memory_bytes: 3636
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			




x = input1()
result=100
for i in range(10**1000000):
	result=int(result*1.01)
	if result>=x:
		print(i+1)
		break
















Measured memory_bytes: 29132
X = int(input())
N = X//100
mod100 = X%100
loop= min(N,100)
for a1 in range(loop):
    for a2 in range(loop-a1+1):
        for a3 in range(loop-(a1+a2)+1):
            for a4 in range(loop-(a1+a2+a3)+1):
                for a5 in range(loop-(a1+a2+a3+a4)+1):
                    if a1+2*a2+3*a3+4*a4+5*a5 == mod100:
                        print(1)
                        exit()
print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;


using P=pair<int,int>;
void solve(){
  int h,w;
  cin>>h>>w;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  const int infty=1e6;
  vector<vector<int>>dp(h+5,vector<int>(w+5,infty));
  dp[0][0]=s[0][0]=='#';
  rep(i,h){
    rep(j,w){
      if(i!=h-1)chmin(dp[i+1][j],dp[i][j]+(int)((s[i+1][j]=='#')&&(s[i][j]!=s[i+1][j])));
      if(j!=w-1)chmin(dp[i][j+1],dp[i][j]+(int)((s[i][j+1]=='#')&&(s[i][j]!=s[i][j+1])));
    }
  }
  cout<<dp[h-1][w-1];
}

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

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int N;

map<int, int> cnter;
vector<int> unzue;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int ipt; cin >> ipt;
		if (cnter.find(ipt) == cnter.end()) {
			cnter[ipt] = 1;
			unzue.push_back(ipt);
		}
		else cnter[ipt] += 1;
	}
	sort(unzue.begin(), unzue.end());

	if (unzue.size() == 1){
		if (unzue[0] == 0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (unzue.size() == 2) {
		int x = unzue[0];
		int y = unzue[1];
		if (x == 0 && N % 3 == 0 && cnter[x] * 2 == cnter[y]) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (unzue.size() == 3) {
		int x = unzue[0];
		int y = unzue[1];
		int z = unzue[2];
		if (cnter[x] == cnter[y] && cnter[y] == cnter[z]
			&& (x^y) == z) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}






	return 0;
}


Measured memory_bytes: 4216
#include<stdio.h>

int a[20][20],i,j,n;

int main(){
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		a[n][n]=0;
		for(i=0;i<n;i++){
			a[i][n]=0;
			a[n][i]=0;
			for(j=0;j<n;j++){
				scanf("%d",&a[i][j]);
				a[i][n]+=a[i][j];
			}
			a[n][n]+=a[i][n];
		}
		for(j=0;j<n;j++){
			for(i=0;i<n;i++){
				a[n][j]+=a[i][j];
			}
		}
		for(i=0;i<n+1;i++){
			for(j=0;j<n+1;j++){
				printf("%5d",a[i][j]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

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

#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)


#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define vi vector<int>
#define ll long long

bool cmp(pair<ll,ll>p1,pair<ll,ll>p2){
    if(p1.first>p2.first){
        return true;
    }
    return false;
}
int main()
{
    int n;
    cin>>n;
    ll dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    vector<pair<ll,ll>>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first,v[i].second=i+1;
    }
    sort(v.begin(),v.end(),cmp);
    dp[0][0]=0;
    ll ans=0;
    for(int i=0;i<n;i++){
       // cout<<v[i].first<<" ";
        for(int j=0;j<=i;j++){
            int l=j,r=i-j;
            dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(l+1-v[i].second)*v[i].first);
            dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(n-r-v[i].second)*v[i].first);
            if(i==n-1){
                ans=max(ans,max(dp[l+1][r],dp[l][r+1]));
               
            }
            // cout<<dp[l+1][r]<<" "<<dp[l][r+1]<<endl;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 34912
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //N,Mの入力を受け取る
          var NKQ = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var N = NKQ[0];
          var K = NKQ[1];
          var Q = NKQ[2];
          
          var points = new int[N+1];
          for(int i = 0; i < Q ; i++){
            var respond = int.Parse(Console.ReadLine());
            points[respond] = points[respond]+1;
           }
          
          for(int i = 1; i < N+1 ; i++){
            if(points[i] >= Q-K+1){
              Console.WriteLine("Yes");
            }else{
              Console.WriteLine("No");
            }
          }
        }
 }
 


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

struct position{
  int x, y;
};

int h, w, n, ans = 0;
position cheese[10];
char map[1001][1001];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {-1, 0, 1, 0};

int solve(int times)
{
  bool pushed[1001][1001];
  int cost[1001][1001];
  queue<position> candidate;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      pushed[i][j]=false;
      cost[i][j]=0;
    }
  }
  candidate.push(cheese[times-1]);

  while(!cost[cheese[times].x][cheese[times].y]){
    position now = candidate.front();
    candidate.pop();
    for(int i = 0; i < 4; i++){
      position next={now.x + dx[i], now.y + dy[i]};
      if(0 < next.x && next.x <= h && 0 < next.y && next.y <= w && map[next.x][next.y] == '.' && !pushed[next.x][next.y]){
		cost[next.x][next.y] = cost[now.x][now.y] + 1;
		position in = {next.x, next.y};
		candidate.push(in);
		pushed[next.x][next.y] = true;
      }
    }
  }
  return cost[cheese[times].x][cheese[times].y];
}

int main()
{
  cin >> h >> w >> n;
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      char in;
      cin >> in;
      if(in == 'S'){
	cheese[0] = {i, j};
	map[i][j] = '.';
      }
      else if('1' <= in && in <= '9'){
	cheese[in - '0'] = {i, j};
	map[i][j] = '.';
      }
      else{
	map[i][j] = in;
      }
    }
  }

  for(int i = 1; i <= n; i++){
    ans+=solve(i);
  }

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

Measured memory_bytes: 7080
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,e,f,suger,water,i,j;
	double ans=0;
	cin >> a >> b >> c >> d >> e >> f;
	double E = double(e*100)/(e+100);
	for(int A=0;A<=100;A++){
		for(int B=0;B<=100;B++){
			for(int C=0;C<=100;C++){
				for(int D=0;D<=100;D++){
					int ryou = (A*a+B*b)*100+C*c+D*d;
					double noudo = double(C*c+D*d)*100/ryou;
					if(ryou>f||(A*a+B*b)==0||noudo>E)	break;
					if(ans<=noudo){
						ans = noudo;
						i = ryou;
						j = C*c+D*d;
					}
				}
			}
		}
	}
	cout << i << ' ' << j << endl;
}

Measured memory_bytes: 256
#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()
using i64 = int_fast64_t;

int main(){
    int N;
    string S;
    cin >> N >> S;

    for(char& c : S){
        char d = c + N;
        if(d > 'Z') d -= 26;
        c = d;
    }

    cout << S << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    if ((a < b) && (b < c)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26220
x1, y1, x2, y2 = [int(i) for i in input().split()]
x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x

x4 = x1 - y
y4 = y1 + x

print("{0} {1} {2} {3}".format(x3,y3, x4, y4))


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


ll _pow(ll x, ll n) {
    ll res = 1;
    REP(_, n) res *= x;
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    ll N; cin >> N;
    const ll D = 32;

    string ans = "";
    FOR(i, 0, D + 1) {
        if (N % _pow(2, i + 1) != 0) {
            ans = '1' + ans;
            N -= _pow(-2, i);
        } else {
            ans = '0' + ans;
        }
    }

    int x = ans.find('1');
    if (x == -1) {
        ans = "0";
    } else {
        ans = ans.erase(0, x);
    }
    cout << ans << '\n';

    return 0;
}


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

#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(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n, m, r;
  int a, b, c;

  scanf("%d %d %d",&n, &m, &r);

  vector<int> rs(r);
  REP (i, r) scanf("%d",&rs[i]);

  int cost[n][n];
  REP (i, n) {
    REP (j, n) {
      if (i == j) cost[i][j] = 0;
      else cost[i][j] = INF;
    }
  }

  REP (i, m) {
    scanf("%d %d %d",&a, &b, &c);
    a--;
    b--;
    cost[a][b] = c;
    cost[b][a] = c;
  }

  REP (i, n) REP (j, n) REP (k, n) {
    cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
  }

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

  int min_sum = INF;
  do {
    int sum = 0;
    REP (i, r - 1) {
      sum += cost[rs[i] - 1][rs[i + 1] - 1];
    }
    if (min_sum > sum) min_sum = sum;
  } while (next_permutation(rs.begin(), rs.end()));

  printf("%d\n", min_sum);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll k;
  cin>>k;
  ll r=7;
  ll ans=1;
  r%=k;
  while(r!=0){
    ans++;
    r*=10;
    r+=7;
    r%=k;
    if(ans==1000000){ans=-1;
      break;
      
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3672
PDList = list(input())


for index, PD in enumerate(PDList):
    if PD != '?': continue

    if PD == '?' and len(PDList) == 1:
        PDList[index] = 'D'
        break

    if index == 0:
        if PDList[index + 1] == 'D' or PDList[index + 1] == '?': PDList[index] = 'P'
        else: PDList[index] = 'D'
        continue

    if PD == '?' and index == len(PDList) - 1:
        PDList[index] = 'D'
        continue


    if PDList[index - 1] == 'P':
        PDList[index] = 'D'
        continue

    if PDList[index + 1] == 'D':
        PDList[index] = 'P'
        continue

    if PDList[index - 1] == 'D' and PDList[index + 1] == '?':
        PDList[index] = 'P'
        continue


    PDList[index] = 'D'
    continue


print(''.join(PDList))

Measured memory_bytes: 10648
#include <bits/stdc++.h> //色々大嘘
//二つ目違うし比較も違う
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;

long modinv(long a) {
    long  b = MOD, u = 1, v = 0;
    while (b) {
        long  t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

template< typename T >
T binomial(T N, T K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret%=MOD;
    ret *=modinv(i);
    ret%=MOD;
  }
  return ret%MOD;
}

int main(void){
    //cout<<binomial((long)10,(long)3)<<endl;
    long N,M,K;
    cin>>N>>M>>K;
    long ans=0,kasami=binomial(N*M-2,K-2);
    for(long d=1;d<N;d++){
        long pat=(N-d)*M*M;
        pat%=MOD;
        
        pat*=kasami;
        pat%=MOD;
        
        ans+=d*pat;
        ans%=MOD;
    }
    for(long d=1;d<M;d++){
        long pat=(M-d)*N*N;
        pat%=MOD;
        
        pat*=kasami;
        pat%=MOD;
        
        ans+=d*pat;
        ans%=MOD;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    int N ; 
    cin >> N ;
    int a;
    a = N / 15 ;

    cout << (N * 800) -( a * 200) << endl;
    return 0;
}

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

int main()
{
	ll n,k;
  	cin>>n>>k;
  	vector<ll> v(n);
  	for(int i=0;i<n;i++)
      cin>>v[i];
  	sort(v.begin(),v.end());
  	ll ans = 0;
  	for(int i=(int)v.size()-1;i>=0;i--)
    {
      	if(k){
          k--;
        }
      	else{
          ans+=v[i];
        }
    }
  	cout<<ans;
  	return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

r = INT()
print(r**2)


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int num[10],s[100]; char c[1000][1000];
int main()
{	int n,m; cin>>n>>m;
	for(rint i=1;i<=n;i++) scanf("%s",c[i]+1);
	for(rint i=1;i<=n;i++)
	for(rint j=1;j<=m;j++)
	if(n-i+1!=i&&m-j+1!=j);
	else if(n-i+1==i&&m-j+1==j) num[1]++;
	else num[2]++;
	for(rint i=1;i<=n;i++)
	for(rint j=1;j<=m;j++) ++s[c[i][j]-'a'];
	for(rint i=0;i<26;i++)
	{	if(s[i]&1) num[1]--;
		if(s[i]%4>=2) num[2]-=2;
		if(num[1]<0||num[2]<0) return !printf("No");
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 384
import sys
i = int(sys.stdin.readline())
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(n[i-1])

Measured memory_bytes: 3060