akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<pair<pair<string,int>, int>> s;
	string S;
	int P;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>S>>P;
		s.push_back(make_pair(make_pair(S,-P),i+1));
	}
	
	sort(s.begin(), s.end());
	
	
	for(int i = 0; i  < N; i++){
		cout<<s[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N = int(readline())
    cnt = 0
    ans = -1
    for _ in range(N):
        x, y = map(int, readline().split())    
        if x == y:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    if ans >=3:
        print('Yes') 
    else:
        print('No')
if __name__ == '__main__':
    main()


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

e1, e2, e3, e4 = map(int, input().split())
if ((e1 == e2) and (e3 == e4)) or ((e1 == e3) and (e2 == e4)) or ((e1 == e4) and (e2 == e3)):
   print("yes")
else:
   print("no")


Measured memory_bytes: 5596
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N, D = map(int,input().split())
    X = [0] * N
    Y = [0] * N
    L = [0] * N
    ans = 0
    for i in range(N):
        X[i], Y[i] = map(int, input().split())
        L[i] = X[i] ** 2 + Y[i] ** 2
        if L[i] <= D ** 2:
            ans += 1
    print(ans)


    
if __name__ == "__main__":
    main()

Measured memory_bytes: 35644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
const int maxn=1e5+10;

int cot(int a,int b)
{
    if((b-a)%2)return (b-a)/2+2;
    return (b-a)/2;
}
int main()
{
    int a[3];
    while (scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF) {
        sort(a,a+3);
        if((a[0]-a[1])%2)
        {
            printf("%d\n",cot(a[0],a[2])+cot(a[1],a[2]));
            continue;
        }
        if((a[1]-a[2])%2)
        {
            printf("%d\n",cot(a[1],a[2]-1)+cot(a[0], a[2]-1)+1);
            continue;
        }
        printf("%d\n",cot(a[1],a[2])+cot(a[0], a[2]));
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
using ll=long long int;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

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

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

	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc048b()
}

fun abc048b() {
    val (a, b, x) = readLine()!!.split(" ").map { it.toLong() }
//    var result = (b - a) / x
//    if (a % x == 0L) result++
//    println(result)
    val big = b / x
    val small = a/ x
    println(big - small + if (a % x == 0L) 1 else 0)
}

Measured memory_bytes: 37872
#include<bits/stdc++.h>
using namespace std;
int main(void){
    long long a,b,c;
    cin >> a >> b >> c;
    if(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		String s;
		s = scan.next();

		char[] cs = new char[4];
		cs[0] = s.charAt(0);
		cs[1] = s.charAt(1);
		cs[2] = s.charAt(2);
		cs[3] = s.charAt(3);

		if (cs[0] == cs[1]) {
			System.out.println("Bad");
			return;
		}
		if (cs[1] == cs[2]) {
			System.out.println("Bad");
			return;
		}
		if (cs[2] == cs[3]) {
			System.out.println("Bad");
			return;
		}

		System.out.println("Good");
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21844
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut a = scan.readn::<i64>(n);
    let mut ret = 0i64;
    loop {
        let (i, &v) = max_with_index(&a);
        if v < n as i64 {break;}
        let cnt = v / n as i64;
        ret += cnt;
        for j in 0..n {
            if i == j {
                a[j] -= cnt * n as i64;
            } else {
                a[j] += cnt;
            }
        }
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn max_with_index<T: Ord>(slice: &[T]) -> (usize, &T) {
    let mut value: Option<&T> = None;
    let mut index = 0;
    for i in 0..slice.len() {
        if let Some(v) = value {
            if v < &slice[i] {
                index = i;
                value = Some(&slice[i]);
            }
        } else {
            index = i;
            value = Some(&slice[i]);
        }
    }
    (index, value.expect("not found max value"))
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    stringstream ss;
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        ss << accs[r] - accs[l - 1] << '\n';
    }
    cout << ss.str();
}


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

int main(){
   vector<ll> v(10000000,0);
   v[1]=1;
    for(ll i=1; i<=10000000; i++){
       ll j=1;
       while(i*j<=10000000){
           v[i*j]=v[i*j]+1;
           j++;
       }
    }
    ll n,count=-1;
    cin>>n;
    for(ll i=1; i<=n;i++){
       count+=i*v[i]; 
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 81204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DMixingExperiment {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        const int INF = 10101010;
        int N, MA, MB;
        in>>N>>MA>>MB;
        vc<int> A(N), B(N), C(N);
        REP(i, N) in>>A[i]>>B[i]>>C[i];
        vector<vvc<int>> dp(N+1, vvc<int>(401, vc<int>(401, INF)));
        dp[0][0][0] = 0;
        REP(i, N) REP(j, 401) REP(k, 401){
            if(dp[i][j][k]==INF) continue;
            chmin(dp[i+1][j][k], dp[i][j][k]);
            chmin(dp[i+1][j+A[i]][k+B[i]], dp[i][j][k]+C[i]);
        }
        int ans = INF, na = MA, nb = MB;
        while(na<=400 and nb<=400){
            chmin(ans, dp[N][na][nb]);
            na += MA, nb += MB;
        }
        if(ans==INF) ans = -1;
        out<<ans<<'\n';
    }
};


int main() {
	DMixingExperiment solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int m;
    cin >> m;
    string t[m];
    for (int i = 0; i < m; i++)
    {
        cin >> t[i];
    }

    /*int ans = -m;
    int yen = 0;
    for (int i = 0; i < n-1; i++)
    {   
        yen++;
        for (int j = i+1; j < n; j++)
        {
            if (s[i] == s[j]) { yen++; }
        }
        for (int k = 0; k < m; k++)
        {
            if (s[i] == t[k]) { yen--; }
        }
        ans = max(ans, yen);
        yen = 0;
    }*/

    int ans = 0;
    int yen = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (s[i] == s[j]) { yen++; }
        }

        for (int k = 0; k < m; k++)
        {
            if (s[i] == t[k]) { yen--; }
        }

        ans = max(yen, ans);
        yen = 0;
    }

    if (ans < 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e; 
  cin >> a>>b>>c>>d>>e;
  int ans = 0; 
  if (a == 0) ans=1;
  if (b == 0) ans=2;
  if (c == 0) ans=3;
  if (d == 0) ans=4;
  if (e == 0) ans=5;
  cout << ans << endl;
  return 0;
 }

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

int selectionSort(vector<int> &A, int N) {
  int changeTimes = 0;
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = minj; j < N; j++) {
      if (A[minj] > A[j]) {
        minj = j;
      }
    }
    if (i == minj) {
      continue;
    }
    changeTimes += 1;
    swap(A[i], A[minj]);
  }

  return changeTimes;
};

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

  int ans = selectionSort(A, N);
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << A[i] << endl;
    } else {
      cout << A[i] << ' ';
    }
  }

  cout << ans << endl;
};



Measured memory_bytes: 3092
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

S = input()
print('2018' + S[4:])

Measured memory_bytes: 62212
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <limits>

#define phb push_back
#define mkp make_pair
#define frs first
#define scn second
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef pair< int, int > Pr;
typedef pair< int, Pr > Prr;
const int kInf = numeric_limits< int >::max() / 2;

int N, M;
vector< Prr > E;

int nset[110];

void read();
void solve();

int find_set(int x) {
  if (~nset[x])
    return nset[x] = find_set(nset[x]);
  return x;
}

void union_set(int x, int y) {
  nset[find_set(y)] = find_set(x);
}

int main() {
  while (cin >> N >> M, N != 0)
    read(), solve();

  return 0;
}

void read() {
  int u, v, c;

  E.clear();
  for (int i = 0; i < M; ++i) {
    cin >> u >> v >> c;
    E.phb(mkp(c, mkp(u, v)));
  }
}

void solve() {
  int res = kInf;

  stable_sort(all(E));
  for (int ei = 0; ei < sz(E); ++ei) {
    fill(&nset[0], &nset[110], -1);

    int i = ei, j = 0, t = 0, u, v;
    while (i < sz(E) && j < N - 1) {
      u = E[i].scn.frs, v = E[i].scn.scn;
      if (find_set(u) != find_set(v))
        union_set(u, v), ++j, t = E[i].frs;
      ++i;
    }

    if (j == N - 1)
      res = min(res, t - E[ei].frs);
  }

  cout << (res < kInf ? res : -1) << "\n";
}

Measured memory_bytes: 1332
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))


n=int(input())
s=input()


i=0
c=0
while i<len(s):
    if s[i]=="(" and c<0:
        s="("*(-c)+s
        i-=c
        c=0
    elif s[i]=="(":
        c+=1
        i+=1
    else:
        c-=1
        i+=1

if c<0:
    s="("*(-c)+s
elif c>0:
    s=s+")"*c
print(s)

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

typedef int cost_t;
const int INF = (int)(1.05e9);
const int MAX_W = 12;

int H, W;
const int dy[] = {1,-1,0,0}, dx[] = {0,0,1,-1};
int board[MAX_W][MAX_W];

int toIndex(int y, int x) {
	return y * W + x;
}

cost_t minimumSteiner(vector< vector<cost_t> > costMatrix, const vector<int> terminals) {
	const int n = costMatrix.size(), numTerminal = terminals.size();
	if (numTerminal <= 1) {
		return 0;
	}

	for (int k = 0; k < n; ++k) {
		costMatrix[k][k] = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				costMatrix[i][j] = min( costMatrix[i][j], costMatrix[i][k] + costMatrix[k][j] );
			}
		}
	}

	vector< vector<cost_t> > minCost(1<<numTerminal, vector<cost_t>(n, 0));

	for (int t = 0; t < numTerminal; ++t) {
		for (int v = 0; v < n; ++v) {
			minCost[1<<t][v] = costMatrix[terminals[t]][v];
		}
	}

	for (int occupiedBit = 1; occupiedBit < (1 << numTerminal); ++occupiedBit) if (occupiedBit & (occupiedBit - 1)) {
		for (int v = 0; v < n; ++v) {
			minCost[occupiedBit][v] = INF;
			for (int subMask = occupiedBit & (occupiedBit - 1); subMask > 0; subMask = (subMask - 1) & occupiedBit) {
				minCost[occupiedBit][v] = min( minCost[occupiedBit][v], minCost[subMask][v] + minCost[subMask ^ occupiedBit][v] );
			}
		}
		for (int v = 0; v < n; ++v) {
			for (int u = 0; u < n; ++u) {
				minCost[occupiedBit][v] = min( minCost[occupiedBit][v], minCost[occupiedBit][u] + costMatrix[u][v] );
			}
		}
	}

	return minCost[(1<<numTerminal) - 1][terminals[0]];
}

bool init() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			scanf("%d", board[i] + j);
		}
	}

	return H > 0;
}

int solve() {
	vector< vector<int> > costMatrix(H*W, vector<int>(H*W, INF));
	for (int y = 0; y < H; ++y) {
		for (int x = 0; x < W; ++x) {
			for (int k = 0; k < 4; ++k) {
				const int ny = y + dy[k], nx = x + dx[k];
				if ( 0 <= ny && ny < H && 0 <= nx && nx < W ) {
					costMatrix[toIndex(y, x)][toIndex(ny, nx)] = 1;
				}
			}
		}
	}

	vector<int> terminals;
	for (int y = 0; y < H; ++y) {
		for (int x = 0; x < W; ++x) {
			if (board[y][x] == 1) {
				terminals.push_back(toIndex(y, x));
			}
		}
	}

	int minS = minimumSteiner(costMatrix, terminals);
	return H * W - (minS + 1);
}

int main() {
	for (; init(); ) {
		printf("%d\n", solve());
	}

	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int> > A(N, vector<int>(M));
	forn(i, N)
	{
		cin >> C[i];
		forn(j, M)
		{
			cin >> A[i][j];
		}
	}
	
	int best = -1;

	forn(i, 1 << N)
	{
		vector<int> lev(M);
		int cost = 0;
		forn(j, N)
		{
			if ((1 << j)&i)
			{
				cost += C[j];
				forn(k, M)
					lev[k] += A[j][k];
			}
		}
		bool ok = true;

		forn(j, M)
		{
			if (lev[j] < X)
				ok = false;
		}
		if (ok && (cost < best || best == -1))
			best = cost;
	}
	cout << best << endl;
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, ans=0;

	cin>> n;

	if(105<=n) ans++;
	if(165<=n) ans++;
	if(195<=n) ans++;
	if(5*27<=n) ans++;
	if(7*27<=n) ans++;

	cout<< ans << endl;
}

Measured memory_bytes: 256
q,h,s,d = map(int,input().split())
n = int(input())
a = 0
if n%2 == 1:
  n -= 1
  a += 1
ans = n//2*min(8*q,4*h,2*s,d)+a*min(4*q,2*h,s)
print(ans)


Measured memory_bytes: 2940
#include <iostream> 
#include <vector> 
#include <algorithm> 
using namespace std; 
long long arr[100005];
int main()
{ 

int n; 
cin>>n; 
long long sum = 0; 
for (int i = 0; i < n; i++)
{
int x; 
cin >> x; 		
arr[x] += 1; 	
sum += x; 
} 	
int q;
cin >> q; 
while (q--)
{ 		
int b, c; 	
cin >> b >> c; 	
arr[c] += arr[b]; 	
sum = sum + arr[b] * c-arr[b]*b ; 
arr[b] = 0; 	
cout << sum << '\n'; 	} 	
}


Measured memory_bytes: 4344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class State
{

    public struct AB
    {
        public int A;
        public int B;

        public AB(int a,int b)
        {
            this.A = a;
            this.B = b;

        }
    }

    public static void Main()
    {
        int N, M;
        var split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = split[0];
        M = split[1];
        AB[] ab = new AB[N];
        for (long i = 0; i < N; i++)
        {
            split = Console.ReadLine().Split().Select(int.Parse).ToArray();

            ab[i] = new AB(split[0], split[1]);
        }
        Array.Sort(ab,comparer);
        long store = 0;
        int need = M;
        int[] buy = new int[N];

        while (need >0)
        {
            if (ab[store].B <= need)
            {
                buy[store] = ab[store].B;
                need -= ab[store].B;
                store++;
            }
            else
            {
                buy[store] = need;
                break;
            }
        }
        long pay = 0;
        for (int i = 0; i < N; i++)
        {
            if (buy[i] == 0) break;
            long temp = ab[i].A;
            temp *= buy[i];
            pay += temp;
        }
        Console.WriteLine(pay);

    }

    public static int comparer(AB a,AB b)
    {
        if (a.A > b.A) return 1;
        else if (a.A < b.A) return -1;
        else return 0;
      
    }



}



Measured memory_bytes: 18492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  vector<long>s(n);
  s[0] = a[0];
  for(i=1;i<n;i++){
    s[i] = a[i] + s[i-1];
  }
  map<long,long>m;
  for(i=0;i<n;i++){
    m[s[i]]++;
  }
  long ans = 0;
  for(i=0;i<n;i++){
    ans += (m[s[i]]*(m[s[i]]-1))/2;
    m[s[i]] = 1;
  }
  for(i=0;i<n;i++){
    if(s[i]==0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=1e9+7;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
inline int rd() { return rand()|(rand()<<15); }
const int N=1e6+5;
int n,a[N],b[N],m,q;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),m=read(),q=read();
  int Mn1=inf,Mn2=inf;
  for(ri i=1;i<=n;++i) ckmin(Mn1,a[i]=read());
  for(ri i=1;i<=m;++i) ckmin(Mn2,b[i]=read());
  int res=Mn1+Mn2;
  for(ri x,y;q;--q) x=read(),y=read(),ckmin(res,a[x]+b[y]-read());
  cout<<res;
  return 0;
}

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


int main() {
  vector<int> A(3);
  for(int i=0; i<3; i++) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[1]-A[0]+A[2]-A[1] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        String s = sc.next();

        int length = s.length();

        String ans = "";

        for (int i = 0; i < length; i++) {
            ans = ans + "x";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        if ((str.Contains('W') &&
            str.Contains('N') &&
            str.Contains('E') &&
            str.Contains('S'))||
            (str.Contains('W')&&
            str.Contains('E')&&
            !str.Contains('N')&&
            !str.Contains('S'))||
            (str.Contains('N')&&
            str.Contains('S')&&
            !str.Contains('W')&&
            !str.Contains('E')))WriteLine("Yes");
        else WriteLine("No");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[110000][2][110];
const int mod = 1000000007;
signed main(){
    string s;cin >> s;
    int n = s.size();
    int d;cin >> d;
    dp[0][0][0] = 1;
    rep(i,n)rep(j,2)rep(k,d){
        int x = s[i] - '0';
        rep(a,10){
            int ni = i+1,nj = j,nk = (k + a)%d;
            if(j == 0 && a > x)continue;
            if(a < x)nj = 1;
            dp[ni][nj][nk] = (dp[ni][nj][nk] + dp[i][j][k])%mod;
        }


    }
    cout << (dp[n][0][0] + dp[n][1][0]-1 + mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 20812
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<n;i++)
int main() {
	ll n,i;
	cin>>n;
	string s;
	cin>>s;
	ll temp1=0,temp2=0,nw=0,ne=0,tturn,ans=INT_MAX;
	for(i=0;i<n;i++) {
		if(s[i]=='E') ne++;
		else if(s[i]=='W') nw++;
	}
	for(i=0;i<n;i++) {
		if(s[i]=='W') {
			tturn=temp1+ne;
			if(tturn<ans) ans=tturn;
			temp1++;
			nw--;
		}
		else {
			ne--;
			tturn=temp1+ne;
			if(tturn<ans) ans=tturn;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 900
n,q=map(int,input().split())
k=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  k[a-1].append(b-1)
  k[b-1].append(a-1)
s=[0]*n
for i in range(q):
  p,x=map(int,input().split())
  s[p-1]+=x
from collections import deque
d=deque()
d.append(0)
v=[False]*n
v[0]=True
while d:
  g=d.popleft()
  for i in k[g]:
    if v[i]:
      continue
    d.append(i)
    v[i]=True
    s[i]+=s[g]
print(*s)

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

const bool DEBUG = false;

long long euclidean_gcd(const long long lhs, const long long rhs) {
  return (rhs != 0) ? euclidean_gcd(rhs, lhs % rhs) : lhs;
}

int main(int argc, char const* argv[]) {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  long long amax = -1;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] > amax) amax = A[i];
  }

  if (K > amax) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  long long gcd = A[0];
  for (size_t i = 1; i < N; i++) {
    gcd = euclidean_gcd(gcd, A[i]);
  }

  if (K % gcd == 0) {
    cout << "POSSIBLE" << endl;
    return 0;
  }

  cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int l,r,a,b,c,d;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c>>d;
    l = a+b;
    r = c+d;
    if(l<r){cout<<"Right\n";}
    else if(l>r){cout<<"Left\n";}
    else {cout<<"Balanced\n";}
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    VI A(3); REP(i,3) cin >> A[i]; SORT(A);
    cout << A[1]-A[0] + A[2]-A[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;
// lower_bound 
 // it returns pos of the elmnt which is not less then the query elmnt
int main(){
    int r; cin >> r;
    cout << (pow(r,2))<< endl;
}




Measured memory_bytes: 3792
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	int Q=in();
	auto P=enum_prime(100000);
	sort(ALL(P));
	vector<int> S(100000+1,0);
	REP(i,100000){
		S[i+1] = S[i];
		int V=i+1;
		int H=(V+1)/2;
		auto res1=binary_search(ALL(P),V);
		auto res2=binary_search(ALL(P),H);
		if(V%2 && res1 && res2) S[i+1]++;
	}
	
	LOOP(Q){
		int L=in(),R=in();
		out(S[R]-S[L-1]);
	}
	return 0;
}


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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var q = p[1];
		var s = Console.ReadLine();
		var t = new int[n+2];
		for(int i = 1; i < n; i++)
		{
			if(s[i-1] == 'A' && s[i] == 'C')
				t[i] = t[i-1] + 1;
			else
				t[i] = t[i-1];
		}
		
		for(int i = 0; i < q; i++)
		{
			p = Input().ToInt();
			Console.WriteLine(t[p[1] - 1] - t[p[0] - 1]);
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 17688
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int n,m;
	cin>>n>>m;
	int res=0;
	int has=1;
	while(has<m){
		has+=n;
		res++;
		has--;
	}
	cout<<res<<endl; 
	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
s=""
m=""
ss=[]
mm=[]
s1=set()
m1=set()
res = 0
for i in range(N):
  s=S[0:i+1]
  m=S[i+1:N]
  ss=list(s)
  mm=list(m)
  s1=set(ss)
  m1=set(mm)
  s_intersection = s1 & m1
  res= max(res,len(s_intersection))
print(res)

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,l;
  cin >> n >> l;
  int sum=n*l+n*(n+1)/2-n;
  if(l>=0){
    cout << sum-l << endl;
  }
  else if(l+n-1>=0){
    cout << sum << endl;
  }
  else{
    cout << sum-(n+l)+1 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
const int N = 200100;
ll a[N], b[N];

int main(){
	int a, b, c;
	int flag = 0;
	while(~scanf("%d %d %d", &a, &b, &c)){
		for(int i = 1; i <= 500; i++){
			int d = b * i + c;
			int e = d / a;
			if(e * a == d){
				flag = 1;
				break;
			}
		}
		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
}

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

int main() {
    int N, A, num = 0, min = INT_MAX;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> A;
        while (A % 2 == 0) {
            A /= 2;
            num++;
        }
        if (num < min) {
            min = num;
        }
        num = 0;
    }
    
    cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int n,m;
    cin>>n>>m;
    int c[100010]={};
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        c[a]++;
        c[b]++;
    }
    for(int i=1;i<=n;i++){
        if(c[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
ll l;
ll a[120000];

int main() {
	scanf("%d%lld", &n, &l);
	for (int i = 0; i < n; ++i)
		scanf("%lld", a + i);
	for (int i = 0; i < n - 1; ++i) {
		if (a[i] + a[i + 1] >= l) {
			printf("Possible\n");
			for (int j = 1; j <= i; ++j)
				printf("%d\n", j);
			for (int j = n - 1; j >= i + 2; --j)
				printf("%d\n", j);
			printf("%d\n", i + 1);
			return 0;
		}
	}
	printf("Impossible\n");
	return 0;
}




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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int __sv;scanf("%d", &(__sv));vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

ll a, b, n;

int main ()
{
  scanf("%lld%lld%lld", &a, &b, &n);
  ll x = min(b - 1, n);
  printf("%lld\n", (a * x) / b - a * (x / b));
  return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int n,d,m;
  map<int,int> s;
  cin>>n;
  fr(i,n){cin>>d;s[d]++;}
  cin>>m;
  fr(i,m){
    cin>>d;
    if(s[d]==0){cout<<"NO"<<endl;return 0;}
    s[d]--;
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
# ABC149 C - Next Prime
X = int(input())

def isPrime(n):
    cnt = 0
    for i in range(1, n + 1):
        if n % i == 0:
            cnt += 1
    if cnt == 2:
        return True
    else:
        return False

while True:
    if isPrime(X):
        print(X)
        break
    else:
        X += 1

Measured memory_bytes: 2940
#include <stdio.h>
#include <inttypes.h>

int N, C;
int s[114514], t[114514], c[114514];

int horieyui[114514];
uint32_t start_exists[114514], end_exists[114514];

int main(void) {
	int i;
	int mareitaso = 0;
	if (scanf("%d%d", &N, &C) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d%d", &s[i], &t[i], &c[i]) != 3) return 1;
		start_exists[s[i]] |= UINT32_C(1) << c[i];
		end_exists[t[i]] |= UINT32_C(1) << c[i];
	}
	for (i = 0; i < N; i++) {
		if (!((end_exists[s[i]] >> c[i]) & 1)) horieyui[s[i] - 1]++;
		if (!((start_exists[t[i]] >> c[i]) & 1)) horieyui[t[i]]--;
	}
	for (i = 1; i < 111111; i++) {
		horieyui[i] += horieyui[i - 1];
	}
	for (i = 0; i < 111111; i++) {
		if (horieyui[i] > mareitaso) mareitaso = horieyui[i];
	}
	printf("%d\n", mareitaso);
	return 0;
}

/*
具体的なスケジューリングは考えず、重なっている数を数える
ただし、同じチャンネルの連続する番組はマージする
*/


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[1005];
ll tmp[1005];
ll sum[2];

int main(void){
	bool flag=false;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(a[i]>=0){
			flag=true;
			sum[i%2]+=a[i];
		}
	}
	if(!flag){
		ll ma=a[0];
		int v=0;
		for(int i=0;i<n;i++){
			ma=max(a[i],ma);
			if(ma==a[i])v=i;
		}
		printf("%lld\n",ma);
		printf("%d\n",n-1);
		for(int i=0;i<v;i++){
			printf("1\n");
		}
		for(int i=v;i<n-1;i++){
			printf("%d\n",n-i);
		}
		return 0;
	}
	printf("%lld\n",max(sum[0],sum[1]));
	vector<int> vec;
	bool side=true;
	if(sum[1]>sum[0])side=false;
	int ele=n;
	while(ele>1){
		memset(tmp,0,sizeof(tmp));
		/*
		for(int i=0;i<ele;i++){
			printf("%d ",a[i]);
		}
		printf("\n");
		*/
		if(side){
			if(a[0]>=0LL && a[2]>=0LL){
				vec.push_back(2);
				tmp[0]=a[0]+a[2];
				for(int j=3;j<ele;j++){
					tmp[j-2]=a[j];
				}
				ele-=2;
			}else if(a[0]<0LL){
				vec.push_back(1);
				for(int j=1;j<ele;j++){
					tmp[j-1]=a[j];
				}
				ele--;
				side=false;
			}else if(a[2]<0LL){
				vec.push_back(3);
				tmp[0]=a[0];
				if(ele>=4){
					tmp[1]=a[1]+a[3];
					for(int j=4;j<ele;j++){
						tmp[j-2]=a[j];
					}
					ele-=2;
				}else{
					ele--;
					for(int j=0;j<ele;j++){
						tmp[j]=a[j];
					}
				}
				
			}
		}else{
			vec.push_back(1);
			for(int j=1;j<ele;j++){
				tmp[j-1]=a[j];
			}
			ele--;
			side=true;
		}
		for(int i=0;i<ele;i++){
			a[i]=tmp[i];
		}
		for(int i=ele;i<n;i++){
			a[i]=0;
		}
	}
	printf("%d\n",vec.size());
	for(int i=0;i<vec.size();i++){
		printf("%d\n",vec[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define shousuutenika(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using ll = long long int;
using ld = long double;

int main(){
  kyopro;
  ld N, K;
  cin >> N >> K;
  ld sum{};
  for(int i{}; i <= N; i++){
    sum += 1 / N / max(pow(2, ceil(log2(K / i))), 1.0L);
  }
  cout << shousuutenika(20) << sum << rt;
}

Measured memory_bytes: 384
/*ex4_2
  TKC001*/
 
#include<stdio.h>
#include<math.h>
#define PAI 3.14159265358979323846
 
int main(void){
    //distanceは2つの針の端点の距離、radは2つの針の間の角度(cosを使うので、0<=rad<=PAIでなくてもよい。)
    double short_hands, long_hands, hours, minutes, distance, rad;
 
    //入力
    scanf("%lf%lf%lf%lf", &short_hands, &long_hands, &hours, &minutes);
    //12時の方向から長身は6*minutes°, 短針は(30*hours + minutes/2)°移動
    rad = (30*hours - 11*minutes/2)*PAI / 180;
 
    //余弦定理で距離を求める
    distance = sqrt(pow(long_hands, 2) + pow(short_hands, 2) - 2*long_hands*short_hands*cos(rad));
 
    //出力(.10がないと小数点以下6桁しか出力してくれない)
    printf("%.10f\n", distance);
 
    return 0;
}

Measured memory_bytes: 2568