akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;

const int Max = 1e3 + 100;
const int MaxSq = 3e2 + 50;
const int Mx = 60;
const int Len = 1e6;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const int P = 63;

ll Phy(int m)
{
	vi tajzieResult;
	for (int i = 2; i < m; i++)
	{
		tajzieResult.pb(i);

		while (m % i == 2)
			m /= i;
	}

	ll result = m;
	for (var t : tajzieResult)
	{
		result *= (1 - 1 / t);
	}
	return result;
}

ll pw(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b == 1)
		return a;
	ll half = pw(a, b / 2);
	if (b % 2)
		return ((half * half) % MOD * a) % MOD;
	return (half * half) % MOD;
}

ll phy = -1;
//gcd(a , MOD) = 1
ll ModINV(int a)
{
	if (phy == -1)
		phy = Phy(MOD);
	ll p = pw(a, phy - 1);
	return p;
}

/*
vi N[Max];
bool seen[Max];
//While LCA is v
ll result[Max];
int h2PWR[Max][Mx];
ll fact[Mx + 1];


void FACT()
{
	fact[1] = 1;
	for (int i = 2; i <= Mx; i++)
	{
		fact[i] = fact[i - 1] * i;
	}
}

ll Select(ll a, ll b)
{
	return ((fact[a] * ModINV(fact[b])) % MOD * ModINV(fact[a - b + 1])) % MOD;
}

void DFS(int v = 0)
{
	seen[v] = true;
	ll res = 0;
	int calculating[Mx];
	bool firstChild = true;
	for (var u : N[v])
	{
		if (!seen[u])
		{
			DFS(u);
			if (firstChild)
			{
				for (int i = 0; i < Mx; i++)
				{
					calculating[i] = h2PWR[u][i];
					firstChild = false;
				}
			}
			else
			{

			}
		}
	}
}


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

	for (int i = 0; i < n; i++)
	{
		int a, b; cin >> a >> b;
		N[a].pb(b);
		N[b].pb(a);
	}
}
*/


int main()
{
	string s; cin >> s;
	bool ok = true;
	bool h = true;
	for (char c : s)
	{
		if (h)
		{
			if (c != 'h')
			{
				ok = false;
				break;
			}
		}
		else
		{
			if (c != 'i')
			{
				ok = false;
				break;
			}
		}
		h = !h;
	}
	if (ok && s[s.size() - 1] == 'i')
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define LL long long
#define end1 "\n"
#define sp " "
using namespace std;
int n,sum,ar[N];
int f(int ind)
{
	int q=0;
	int k=0;
	for(int i=ind;i<=n;i++)
	{
		if(ar[i]>ar[i+1])
			break;
		q++	;
	}
	for(int i=ind;i<=n;i++)
	{
		if(ar[i]<ar[i+1])
			break;
		k++;
	}
	//~ cout<<q<<sp<<k<<sp<<max(k,q)<<end1;
	return max(k,q);
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>ar[i];
	for(int i=1;i<=n;i++)
	{
		sum++;
		i+=f(i);
	}
	cout<<sum;
}	


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

bool sol;
string s;

int main(){

    cin >> s;
    int n = s.size();
    if (s == "keyence"){
        cout << "YES";
        return 0;
    }

    for (int i = 0; i < n; i++){
        for (int j = i; j < n; j++){
            if (s.substr(0, i) + s.substr(j+1, n-1-j) == "keyence") sol = 1;
        }
    }

    if (sol) cout << "YES";
    else cout << "NO";

    return 0;

}

Measured memory_bytes: 256
//                _                                      
//  ___ _ __ ___ (_) __ ___      ___   _ _ __ ___  _ __  
// / __| '_ ` _ \| |/ _` \ \ /\ / / | | | '_ ` _ \| '_ \ 
// \__ \ | | | | | | (_| |\ V  V /| |_| | | | | | | |_) |
// |___/_| |_| |_|_|\__, | \_/\_/  \__,_|_| |_| |_| .__/ 
//                  |___/                         |_|  
//code by smigwump
//https://codeforces.com/blog/entry/62393
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define REP(i,a,b) for(int i = a; i <= b; i++)
#define PER(i,a,b) for(int i = a; i >= b; i--)
typedef long long ll;

using namespace std;

int main() {
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,a2,a3;
	cin>>a;
	a2=a*a;
	a3=a2*a;
	cout<<a+a2+a3<<"\n";

	return 0;
}

Measured memory_bytes: 3632
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn = (1<<18) + 10, mod = 998244353, inf = 1e9 + 10;

int Pow(int a, int b){
    int ans = 1;
    for(; b; b>>=1, a = 1ll * a * a % mod)
	if(b&1)
	    ans = 1ll * ans * a % mod;
    return ans;
}
void ntt(int *a, int n, bool rev){
    int N = 1<<n;
    for(int stp = 0; stp < n; stp++){
	int ln = 1<<stp;
	for(int l = 0; l < N; l+= ln + ln){
	    for(int i = 0; i < ln; i++){
		int A = a[l + i], B = a[l + ln + i];
		a[l + i] = (A + B) % mod;
		a[l + ln + i] = (A - B) % mod;
	    }
	}
    }
    if(rev){
	int x = Pow(1<<n, mod-2);
	for(int i = 0; i < N; i++){
	    a[i] = 1ll * a[i] * x % mod;
	}
    }
}

int p[maxn];

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

    int n, sm = 0;
    cin >> n;
    for(int i = 0; i < (1<<n); i++){
	cin >> p[i];
	sm+= p[i];
    }
    for(int i = 0; i < (1<<n); i++){
	p[i] = 1ll * p[i] * Pow(sm, mod-2) % mod;
    }
    p[0]--;
    sm = 0;
    ntt(p, n, 0);
    for(int i = 1; i < (1<<n); i++){
	p[i] = 1ll * Pow(p[i], mod-2) * (1<<n) % mod;
	sm = (sm + p[i]) % mod;
    }
    p[0] = -sm;

    ntt(p, n, 1);
    for(int i = 0; i < (1<<n); i++){
	cout << (p[i] + mod) % mod << "\n";
    }
    return 0;
}


Measured memory_bytes: 3840
n=int(input())
lst=[]
for i in range(n):
  s,p=map(str,input().split())
  lst.append([s,int(p),i+1])
lst.sort(key=lambda lst:( -lst[1]))
lst.sort(key=lambda lst:(lst[0]))
for x in lst:
  print(x[2])

Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: usize,
        t: [u32; n],
        m: usize,
        p: [[usize; 2]; m]
    };
    for pe in p {
        let sum = t.iter().sum::<u32>();
        let ret = sum - t[pe[0]-1] + pe[1] as u32;
        println!("{}", ret);
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b;
  	cin >> a >> b;
  	vector<string> str(a);
  	for(int i=0;i<a;i++){
    	cin >> str.at(i);	
    }
  	sort(str.begin(),str.end());
  	string sum;
  	for(int i=0;i<a;i++){
    	sum+=str.at(i);	
    }
  	cout << sum << endl;
  	return 0;
}


Measured memory_bytes: 3588
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(heisei(s))
}

func heisei(s string) string {
	i, _ := strconv.Atoi(strings.Replace(s, "/", "", -1))
	if i <= 20190430 {
		return "Heisei"
	}
	return "TBD"
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){
  int N,M;
  vector<int> vec;
  map<int,bool> exist;
  exist.clear(),vec.clear();
  cin >> N >> M;
  
  for(int j=0;j<N;j++){
    int job;
    cin >> job;
   if(exist[job]){
     foreach(i,vec){
     	if((*i) == job){
	  vec.erase(i);
     	  vec.push_back(job);
     	  break;
     	}
     }
      
    }
    else if(vec.size() < M){
      exist[job] = true;  
      vec.push_back(job);
    }
    else if(vec.size() >= M){      
      exist[*vec.begin()] = false;
      vec.erase(vec.begin());
      vec.push_back(job);
      exist[job] = true;
    }
    else {
    }
  }
 
  for(int i=(int)vec.size()-1;i>=0;i--){
    cout << *(vec.begin()+i) << endl;
  }


  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

vi ans;

void solve(){
	int n;
	scanf("%d", &n);
	int lim = 30000;
	ll sum = 0ll;
	for(int i = 3; i < lim && (SZ(ans) < n - 2 || SZ(ans) % 2 == 1); i += 2) {
		if (i % 3 == 0 || i % 5 == 0) {
			ans.pb(i);
			sum += i;
		}
	}
	for(int i = lim; SZ(ans) < n - 1; i -= 2) {
		ans.pb(i);
		sum += i;
	}
	ans.pb(30 - sum % 30);
	SORT(ans);
	REP(i, 0, SZ(ans)) {
		printf("%d ", ans[i]);
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 512
import itertools

N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

internal = 0
for a0, a1 in itertools.combinations(A, 2):
    if a0 > a1:
        internal += 1

external = 0
for a0, a1 in itertools.permutations(A, 2):
    if a0 > a1:
        external += 1

ans = internal * K + external * K * (K - 1) // 2
ans = int(ans) % m
print(ans)

Measured memory_bytes: 9292
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

N = int(input())
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)

# 中央値を取るのがみそ


Measured memory_bytes: 26128
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, long long K, std::vector<long long> A){
    ll M = 40;
    bool isFree = false;
    ll x = 0;
    for(ll j = 39; j >= 0; j--){
        //* calculate best bit
        ll num_one=0;
        REP(i, N){
            if(A[i]>>j & 1) num_one++;
        }
        bool bit = (num_one>(N-num_one))? false: true;
        if(isFree){
            if(bit) x = (x | (1LL<<j));
        }
        else{//* need to check K
            if((K>>j & 1) && (!bit) && !isFree) isFree = true;
            if((K>>j & 1) && (bit)) x = (x | (1LL<<j));
        }
    }
    ll ans = 0;
    REP(i, N) ans += x^A[i];
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array([0] + lr() + [0])
diff = np.diff(A)
total = np.abs(diff).sum()
answer = []
for i in range(N):
    answer.append(total - abs(diff[i]) - abs(diff[i+1]) + abs(A[i+2]-A[i]))

print('\n'.join(map(str, answer)))


Measured memory_bytes: 41376
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }



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

    int N, K; cin >> N >> K;
    vector<int> T(N), D(N); rep(i, N) cin >> T[i] >> D[i];

    // list
    vector<int> top1_list, other_list;
    {
        map<int, pii> top1;
        rep(i, N) set_max(top1[T[i]], make_pair(D[i], i));

        set<int> top1_indices;
        for(auto &p : top1) top1_indices.insert(p.second.second);

        rep(i, N) (top1_indices.count(i) ? top1_list : other_list).push_back(D[i]);
    }
    while(other_list.size() < N) other_list.push_back(0);

    // sum
    auto make_sum = [] (vector<int> &l) {
        sort(all(l), greater<int>());
        vector<ll> sum(l.size() + 1);
        rep(i, l.size()) sum[i + 1] = sum[i] + l[i];
        return sum;
    };
    auto top1_sum = make_sum(top1_list);
    auto other_sum = make_sum(other_list);

    // go
    ll ans = 0;
    repeat(k, 1, K + 1) {
        ll l = K - k;
        if(k >= top1_sum.size()) continue;
        ll sum = top1_sum[k] + other_sum[l];

        if(l > 0) {
            int m = upper_bound(all(top1_list), other_list[l - 1], greater<int>()) - begin(top1_list) - 1 + 1;

            if(m - k > l) m = k + l;

            if(k < m and m < top1_sum.size()) {
                sum = top1_sum[m] + other_sum[K - m];
            }
        }
        set_max(ans, sum + (ll)k * k);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12668
def solve(n, q, t, u, v):
    parents = list(range(n+1))
    def root(x):
        if x != parents[x]:
            parents[x] = root(parents[x])
        return parents[x]
    res = []
    for i in range(q):
        a = root(u[i])
        b = root(v[i])
        if t[i] == 0:
            if a > b:
                a, b = b, a
            parents[b] = a
        else:
            res.append(int(a == b))
    return "\n".join(map(str, res))

n, q = map(int, input().split())
t, u, v = zip(*[map(int, input().split()) for i in range(q)])
print(solve(n, q, t, u, v))

Measured memory_bytes: 112776
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(), k = s.nextInt(), c = s.nextInt();
        String str = s.next();
        int[] dpl = new int[n+1];
        int[] dpr = new int[n+1];
        for(int i = 1; i <= n; i++) {
            dpl[i] = dpl[i-1];
            if(str.charAt(i-1) == 'o') {
                dpl[i] = Math.max(dpl[i], dpl[Math.max(0, i-c-1)] + 1);
            }
        }
        for(int i = n-1; i >= 0; i--) {
            dpr[i] = dpr[i+1];
            if(str.charAt(i) == 'o') {
                dpr[i] = Math.max(dpr[i], dpr[Math.min(n, i+c+1)] + 1);
            }
        }
        Map<Integer, Integer> map = new HashMap();
        for(int i = 1; i <= n; i++) {
            if(str.charAt(i-1) == 'o' && dpl[i] + dpr[i-1] - 1 == k) {
                map.put(dpl[i], map.getOrDefault(dpl[i], 0) + 1);
            }
        }
        for(int i = 1; i <= n; i++) {
            if(str.charAt(i-1) == 'o' && dpl[i] + dpr[i-1] - 1 == k && map.getOrDefault(dpl[i], 0) == 1) {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 63052
first_str =input()

input_list = list(first_str)

total_list = list()

for i in input_list:
    if i == "0":
        total_list.append("0")
        
    elif i == "1":
        total_list.append("1")
    
    else:
        if not total_list:
            pass
        else:
            total_list.pop(-1)
    
total = "".join([str(_) for _ in total_list])
print(total)

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

int main(){
    int a, b, c, d, e, k, i, j;
    cin >> a >> b >> c >> d >> e >> k;

    if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||e-c>k||e-d>k){
        cout << ":(" ;
    }
    else{
        cout << "Yay!\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  int H, W;
  
  cin >> H >> W;
  
  char A[H+2][W+2];
  
  for(int i = 1; i < H+2-1; i++){
    for(int j = 1; j < W+2-1; j++){
      cin >> A[i][j];
    }
  }
  
  for(int i = 0; i < H+2; i++){
    for(int j = 0; j < W+2; j++){
      if(i == 0 || i == H+2-1 ||
         j == 0 || j == W+2-1){
        A[i][j] = '#';
      }
    }
  }
  
  for(int i = 0; i < H+2; i++){
    for(int j = 0; j < W+2; j++){
      cout << A[i][j];
      if(j == W+2-1){
        cout << endl;
      }
    }
  }
  
  return 0;
}

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

int main(){
  int n;
  bool up=false;
  int ans=0;
  int p[20];
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  if(p[0]<p[1])up=true;
  for(int i=2;i<n;i++){
    if(p[i-1]<p[i]){
      up?ans++:up=true;
    }else{
      up?up=false:ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353


if D[0] != 0:
    print(0)
    exit()

if D.count(0) != 1:
    print(0)
    exit()


X = defaultdict(int)
for d in D:
    X[d] += 1


ans = 1
for d in D:
    if d == 0:
        continue

    ans *= X[d - 1]
    ans %= MOD

print(ans)


Measured memory_bytes: 19936
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
#include <cstring>
using namespace std;

int visited[26];

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

	int n;
	string s;
	cin >> n >> s;
	
	int best = 0;
	for (int i = 0; i < n; i++) {
		memset(visited, sizeof visited, 0);
		for (int j = 0; j <= i; j++) visited[s[j]-'a'] = 1;
		int r = 0;
		for (int j = i+1; j < n; j++) {
			int k = s[j] - 'a';
			if (visited[k] == 1) r++;
			if (visited[k]) visited[k]++;
		}
		best = max(best, r);
	}
	cout << best << endl;
}


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

#define tt template<typename T> ostream& operator <<(ostream& os, const
#define tuv template<typename U, typename V> ostream& operator<<(ostream& os, const
tt vector<T>& v)            { os << "["; for(auto & x : v) os << " " << x; os << " ]"; return os; }
tt vector<vector<T> >& m)   { for(auto & x : m) { for(auto & y : x) os << y << " "; os << "\n"; } return os; }
tt set<T>& s)               { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt unordered_set<T>& s)     { os << "{"; for(auto & x : s) os << " " << x; os << " }"; return os; }
tt queue<T>& q)             { queue<T> q2(q); while(!q2.empty()) { os << q2.front() << " "; q2.pop(); } return os; }
tt stack<T>& s)             { stack<T> s2(s); while(!s2.empty()) { os << s2.top() << " "; s2.pop(); } return os; }
tuv pair<U,V>& p)           { os << "(" << p.first << "," << p.second << ")"; return os; }
tuv map<U,V>& m)            { os << "{ "; for(auto & x : m) os << x.first << ":" << x.second << " "; os << "}"; return os; }
tuv unordered_map<U,V>& um) { os << "{ "; for(auto & x : um) os << x.first << ":" << x.second << " "; os << "}"; return os; }


int main(int argc, char * argv[])
{
    std::ios_base::sync_with_stdio(false);    
    std::cin.tie(NULL);

    int K;
    std::cin >> K;

    string S;
    std::cin >> S;

    if(S.size() <= K)
    {
	std::cout << S << std::endl;
	return 0;
    }
    else
    {
	string res = S.substr(0, K);
	res += "...";
	std::cout << res << std::endl;
	return 0;
	
    }


    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    int n;
    int a[100001], b[100001];

    cin >> n;
    int c = 0, d = 0;
    Rep(i, n) {
        cin >> a[i];
        c += a[i];
    }
    Rep(i, n) {
        cin >> b[i];
        d += b[i];
    }

    int cnt = d-c;

    if ( cnt < 0 ) {
        cout << "No" << endl;
        return 0;
    }

    int A = cnt, B = cnt;
    bool flag = true;
    Rep(i, n) {
        if ( a[i] > b[i] ) {
            B -= a[i]-b[i];

        } else if ( a[i] < b[i] ) {
            A -= (b[i]+1-a[i])/2;
            B -= ((b[i]-a[i]) % 2);
        }

        if ( A < 0 || B < 0 ) {
            flag = false;
            break;
        }
    }

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


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] strs = stdR.readLine().split(" ");
        int N = Integer.parseInt(strs[0]);
        int K = Integer.parseInt(strs[1]);
        if(N / 2 + N % 2 >= K) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 22356
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=1e6+10;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
}
const int mod=1e9+7;
int n,m,k;
char s[1000][1000];
char s1[1000][1000];
int op[N],p[N],t[N];
int main(){
    cin>>n>>m>>k;
    rep(i,1,n){
        cin>>s[i]+1;
    }
    rep(i,1,n){
        rep(j,1,m){
            s1[i][j]=s[i][j];
        }
    }
    int ans=0;
    rep(i,0,(1<<n)-1){
        rep(j,0,(1<<m)-1){
            int cnt=1;
            int ki,kj;
            ki=i;kj=j;
            //cout<<"i="<<i<<" j="<<j<<endl;
            while(ki){
                if(ki&1){
                    rep(h,1,m)s[cnt][h]='.';
                }
                cnt++;
                ki>>=1;
            }
            cnt=1;
            while(kj){
                if(kj&1){
                    rep(h,1,n)s[h][cnt]='.';
                }
                cnt++;
                kj>>=1;
            }
            int con=0;
            rep(x,1,n){
                rep(y,1,m){
                    //cout<<s[x][y];
                    if(s[x][y]=='#')con++;
                }
                //cout<<endl;
            }
            //cout<<"------"<<endl;
            if(con==k)ans++;
            rep(x,1,n){
                rep(y,1,m){
                    s[x][y]=s1[x][y];
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
line = list(input())
count = 0
if line[0] == "R":
  if line[1] == "R":
    if line[2] == "R":
      count = 3
    else:
      count = 2
  else:
    count = 1
elif line[1] == "R":
  if line[2] == "R":
    count = 2
  else:
    count = 1
elif line[2] == "R":
  count = 1
print(str(count))

Measured memory_bytes: 9072
#include "algorithm"
#include "iostream"
#include "string"
#include "vector"

using namespace std; // std::を省略して書くことができる

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int transparent = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] >= 3200) {
      transparent += 1;
    }
  }
  int num = 0;
  for (int i = 0; i < 8; i++) {
    for (int k = 0; k < N; k++) {
      if (400 * i <= a[k] && a[k] < 400 * (i + 1)) {
        num += 1;
        break;
      }
    }
  }
  cout << max(1, num) << " " << num + transparent << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i > 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t int64;

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

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


class A {
	int k;
public:
	A()
	{
		cin >> k;
	}
	void solve()
	{
		cout << ((k + 1) / 2) * (k / 2) << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// < ----------- func eh ---------------- ? //

ll dfs(string s) {
	if(s.length() && stoull(s) > n) return 0;
	ll ret = 0,i;
	for(i=3;i<=7;i+=2) {
		if(count(all(s),i+'0')==0) {
			break;
		} 
	}
	if(i==9) ret = 1;
	for(char c = '3'; c<='7'; c+=2) {
		ret += dfs(s + c);
	}
	return ret;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	cout<<dfs("");	
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3676
def main(n, a, b, c):
    ans = 0
    for i in range(n):
        ans += len(set([a[i], b[i], c[i]])) - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = input()
    b = input()
    c = input()

    main(n, a, b, c)


Measured memory_bytes: 2940
/* 
 * Project: AtCoder Beginners Contest 068 B - Break Number
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/06
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int n;

void solve() {

    if (n <= 2) {
        printf("%d\n", n);
        return;
    }
    
    for (int i=6;i>=1;i--) {
        if (n >= pow(2,i)) {
            printf("%d\n",(int)pow(2,i));
            return;
        }
    }

}

int main() {

    scanf("%d", &n);

    solve();

}

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

int main() {
    int n;cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0, active=0;

    rep(i, n) {
        if (h[i] > active) {
            ans += h[i]-active;
            active = h[i];
        }
        else if (h[i] < active) {
            active = h[i];
        }
    }
    cout << ans << endl;
}


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

int main(){
    long long A, B, C;
    long long a, b, c;
    cin >> A >> B >> C;
    if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1 ){
        cout << 0 << endl;
        return 0;
    }else if(A == B && B == C){
        cout << -1 << endl;
        return 0;
    }

    int num = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        a = A / 2;
        b = B / 2;
        c = C / 2;
        A = b + c;
        B = a + c;
        C = a + b;
        num++;
    }
    cout << num << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Prim
const long long inf=1e9+7;
const int max_v=200000;
struct edge { int to; long long cost; };
typedef pair<long long, int> P;
int mincost[max_v], v;
vector<edge> g[max_v]; //各頂点の情報を持つ
int prim(){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(mincost, mincost + v, inf);
    long long res = 0;
    mincost[0] = 0;
    que.push(P(0, 0));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int w = p.second;
        if (mincost[w] < p.first) continue;
        mincost[w] = 0;
        res += p.first;
        for (int ii = 0; ii < g[w].size(); ii++) {
            edge e=g[w][ii];
            if (mincost[e.to] > e.cost) {
                mincost[e.to] = e.cost;
                que.push(P(mincost[e.to], e.to));
            }
        }
    }
    return res;
}

int main (){
	long long n,i,j,x[100005],y[100005];
	edge em;
	vector<pair<pair<int,int>,int>> a,b;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i];
		a.push_back({{x[i],y[i]},i});
		b.push_back({{y[i],x[i]},i});
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	v=n;
	for(i=1;i<n;i++){
		em.to=a[i].second;
		em.cost=a[i].first.first-a[i-1].first.first;
		g[a[i-1].second].push_back(em);
		em.to=a[i-1].second;
		g[a[i].second].push_back(em);
	}
	for(i=1;i<n;i++){
		em.to=b[i].second;
		em.cost=b[i].first.first-b[i-1].first.first;
		g[b[i-1].second].push_back(em);
		em.to=b[i-1].second;
		g[b[i].second].push_back(em);
	}
	long long ans=prim();
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21292
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s; cin >> s;
    for (int i = 0; i < s.size(); i += 2) cout << s[i];
}


Measured memory_bytes: 592
#include <stdio.h>
int main()
{
  int h,w,r=0,g,cou;
  scanf("%d %d",&h,&w);
  while(h!=0||w!=0){
    while(1){
      while(1){
      if(r<w){
	printf("#");
      }else break;
      r=r+1;
      if(r<w){
	printf(".");
      }else break;
      r=r+1;
      }
    g=g+1;
      if(g>=h){
      break;
      }
      printf("\n");
      r=0;
      while(1){
      if(r<w){
	printf(".");
      }else break;
      r=r+1;
      if(r<w){
	printf("#");
      }else break;
      r=r+1;
	}
    g=g+1;
      if(g>=h){
      break;
      }
      printf("\n");
      r=0;
    }
    printf("\n\n");
    scanf("%d %d",&h,&w);
    r=0;
    g=0;
  }
  return 0;
}
      

Measured memory_bytes: 1016
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	int ans = 0;
	REP(i, S.size())if (S[i] == '1')ans++;
	cout << ans << endl;
		
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		int n = Integer.parseInt(br.readLine());
		for(int k = 0; k < n; k++){
			String str1 = br.readLine();
			/*if(str1.length() > 80){
				System.out.println("overflow");
				continue;
			}*/
			String str2 = br.readLine();
			if(str2.length() > 80 || str1.length() > 80){
				System.out.println("overflow");
				continue;
			}
			int len1 = (str1.length()-1)/9 +1;
			int len2 = (str2.length()-1)/9 +1;

			int arr1[] = new int[len1];
			int arr2[] = new int[len2];
			for(int i = 0; i < len1; i++){
				if(i == len1-1){
					arr1[i] = Integer.parseInt(str1.substring
					(0, (str1.length()-9*i)));
				}
				else{
					arr1[i] = Integer.parseInt(str1.substring
					(str1.length()-9*(i+1)
					, str1.length()-9*i));
				}

			}

			for(int i = 0; i < len2; i++){
				if(i == len2-1){
					arr2[i] = Integer.parseInt(str2.substring
					(0, (str2.length()-9*i)));
				}
				else{
					arr2[i] = Integer.parseInt(str2.substring
					(str2.length()-9*(i+1)
					, str2.length()-9*i));
				}

			}

			int max;
			int min;
			if(len1 > len2){
				max = len1;
				min = len2;
			}
			else{
				max = len2;
				min = len1;
			}
			int[] sum = new int[max+1];
			for(int i = 0; i < min; i++){
				sum[i] += arr1[i] + arr2[i];
				if(sum[i] > 999999999){
					sum[i+1]++;
					sum[i] -= 1000000000;
				}
			}
			for(int i = min; i < max; i++){
				if(max == len1)
					sum[i] += arr1[i];
				else
					sum[i] += arr2[i];
				if(sum[i] > 999999999){
					sum[i+1]++;
					sum[i] -= 1000000000;
				}
			}

			if(max  == 9  && sum[max-1] >= 100000000){
				System.out.println("overflow");
				continue;
			}

			if(sum[max] != 0){
				System.out.print(sum[max]);
			}
			for(int i = 1; i < max+1; i++){

				if(sum[max] == 0 && i == 1){
					System.out.print(sum[max-i]);
				}
				else
					System.out.print(String.format("%1$09d", sum[max-i]));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
using namespace std;
int main()
{
  int n,x,s=0,t,i;
  cin >> n >> x;
  for(i=1;i<=n;i++){
    cin >> t;
    s+=t;
    if(s>x) break;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef pair<int, int> lo;
int h, w;

int bfs(vector<vector<int> > maze) {
	vector<vector<int> > dist(h * 2 + 3, vector<int>(w * 2 + 3, 1));
	int dix[] = { -2,0,0,2 }, diy[] = { 0,-2,2,0 };
	int ddix[] = { -1,0,0,1 }, ddiy[] = { 0,-1,1,0 };
	queue<lo> que;
	que.push(make_pair(2, 2));
	while (!que.empty()) {
		lo q = que.front(); que.pop();
		for (int i = 0; i < 4; ++i) {
			if (q.first == h * 2 && q.second == w * 2) return dist[q.first][q.second];
			int xtmp = q.first + dix[i], ytmp = q.second + diy[i];
			if (maze[xtmp - ddix[i]][ytmp - ddiy[i]] == 0 && maze[xtmp][ytmp] == 0 && dist[xtmp][ytmp] == 1) {
				dist[xtmp][ytmp] = dist[q.first][q.second] + 1;
				que.push(make_pair(xtmp, ytmp));
			}
		}
	}
	return 0;
}

int main() {
	while (cin >> w >> h && w) {
		vector<vector<int> > maze(h * 2 + 3, vector<int>(w * 2 + 3, 1));
		maze[2][2] = 0; maze[h * 2][w * 2] = 0;
		cin.ignore();
		string s;
		for (int i = 2; i < h * 2 + 1; ++i) {
			getline(cin, s);
			for (int j = 2; j < w * 2 + 1; ++j) {
				if (s[j - 2] == ' ' || s[j - 2] == '\0') maze[i][j] = 0;
				else maze[i][j] = s[j - 2] - '0';
				if (maze[i][j] == 1) {
					if (i % 2) maze[i][j - 1] = 1;
					else maze[i - 1][j] = 1;
				}
			}
		}

		cout << bfs(maze) << endl;
	}

	return 0;
}


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

#include <math.h> 

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int n, judge = 0;
  cin >> n;
  n -= 1;
  while(judge == 0){
    n++;
    if(IsPrime(n)){
      judge++;
    }
  }
  cout << n << endl;
}

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

int main(int argc, const char * argv[]) {
    int N,A;
    cin>>N>>A;
    int rem = N%500;
    if(rem <= A)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  char c[1301];
  int i=0,j;
  while(1){
    scanf("%c",&c[i]);
    if(c[i]=='\n'){
      break;
    }
    i++;
  }
  for(j=0; j<i; j++){
    if(c[j]>='A'&&c[j]<='Z')c[j]+=32;
    else if(c[j]>='a'&&c[j]<='z')c[j]-=32;
    printf("%c",c[j]);
    if(j==i-1)printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2144
import bisect

N=int(input())
L=[int(i) for i in input().split()]

count=0
L.sort()
for i in range(0,N-1):
    for j in range(i+1,N):
        index=bisect.bisect_left(L,L[i]+L[j])
        count+=max(0,index-j-1) #indexは条件に当てはまらない最も左の値から１を引く
print(count)

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

int main(){
	int a,b,p,j,c,maxv;
	cin>>a>>b;
	p=a+b;
	j=a-b;
	c=a*b;
	maxv=p;
	if(j>maxv) maxv=j;
	if(c>maxv) maxv=c;
	cout<<maxv;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
struct Edge{
	int v,nxt;
}e[400010];int tot;
int first[200010];
void build(int u,int v)
{
	e[++tot]=(Edge){v,first[u]};
	first[u]=tot;
	return ;
}
int f[200010],g[200010];
int work(int u,int lst,int lim)
{
	if(u>lim)return 0;
	int sz=1;
	for(int i=first[u];i;i=e[i].nxt)
		if(e[i].v!=lst)sz+=work(e[i].v,u,lim);
	return sz;
}
bool vis[200010];
void dfs(int u,int lst,int pre)
{
	if(u>pre)vis[u]=true;
	if(!vis[u]){
		if(!vis[lst])f[u]=f[lst];
		else f[u]=f[lst]+work(u,lst,pre)-g[u];
	}
	else{
		f[u]=f[lst]+1;
		for(int i=first[u];i;i=e[i].nxt)
			if(e[i].v!=lst)f[u]+=(g[e[i].v]=work(e[i].v,u,pre));
	}
	for(int i=first[u];i;i=e[i].nxt)
		if(e[i].v!=lst)dfs(e[i].v,u,max(pre,u));
	return ;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		build(u,v);
		build(v,u);
	}
	dfs(1,0,0);
	for(int i=2;i<=n;i++)
		printf("%d ",f[i]-1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 21888
#include<bits/stdc++.h>
using namespace std;
int dp[10050],a[1050],b[1050];
int main()
{
	memset(dp,0x7f,sizeof(dp));
	dp[0]=0;
	int h,n;
	cin>>h>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for (int i=1;i<=n;i++)
		for (int j=a[i];j<=h+a[i];j++)
			dp[min(h,j)]=min(dp[min(h,j)],dp[j-a[i]]+b[i]);
	/*for (int i=0;i<=h;i++)
		cout<<dp[i]<<endl;*/
	cout<<dp[h];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<pair<int, int> > score(n);
        for(int i=0; i<n; ++i){
            cin >> score[i].second;
            score[i].second = -score[i].second;

            vector<vector<int> > pin(10, vector<int>(2, 0));
            for(int j=0; j<10; ++j){
                cin >> pin[j][0];
                if(j == 9 || pin[j][0] != 10)
                    cin >> pin[j][1];
                score[i].first += pin[j][0] + pin[j][1];

                if(j > 0 && pin[j-1][0] == 10){
                    score[i].first += pin[j][0] + pin[j][1];
                    if(j > 1 && pin[j-2][0] == 10)
                        score[i].first += pin[j][0];
                }
                else if(j > 0 && pin[j-1][0] + pin[j-1][1] == 10)
                    score[i].first += pin[j][0];
            }
            if(pin[9][0] == 10 || pin[9][0] + pin[9][1] == 10){
                int a;
                cin >> a;
                score[i].first += a;
            }
        }

        sort(score.rbegin(), score.rend());
        for(int i=0; i<n; ++i)
            cout << -score[i].second << ' ' << score[i].first << endl;
    }
}

Measured memory_bytes: 0
from collections import deque

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

player = ''
ans = 0
d = []
d = deque(d)
for i in range(k):
	if t[i] == 'r':
		ans += p
		d.append('p')
	elif t[i] == 's':
		ans += r
		d.append('r')
	else:
		ans += s
		d.append('s')

#print(ans)
for i in range(k,n):
	player = d.popleft()
	if t[i] == 'r':
		if player != 'p':
			ans += p
			d.append('p')
		else:
			d.append('')
	elif t[i] == 's':
		if player != 'r':
			ans += r
			d.append('r')
		else:
			d.append('')
	else:
		if player != 's':
			ans += s
			d.append('s')
		else:
			d.append('')
	#print(ans)
print(ans)


Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

vector<string> v;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);
    map<char, int> mp;
    mp['M'] = 1000;
    mp['D'] = 500;
    mp['C'] = 100;
    mp['L'] = 50;
    mp['X'] = 10;
    mp['V'] = 5;
    mp['I'] = 1;
    string s;
    while (cin >> s)
    {
        int n = s.size();
        int sum = mp[s[n - 1]];
        for (int i = n - 1; i >= 1; --i)
        {
            if (mp[s[i]] > mp[s[i - 1]])
            {
                sum -= mp[s[i - 1]];
            }
            else
            {
                sum += mp[s[i - 1]];
            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
use std::cmp::*;
fn main(){
    println!("{}",if(0..read::<i32>()).filter(|_|read::<String>().find('Y')!=None).count()>0{"Four"}else{"Three"})
}



Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
  int x,y;
  for(;;){
  scanf("%d%d",&x,&y);
   if(x==0 && y==0)
    break;
      if(x>y)
        printf("%d %d\n",y,x);
      else
        printf("%d %d\n",x,y);
      }
    return 0;
    }



Measured memory_bytes: 2132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a;
  a.push_back(0);
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end());
  for(int i = 0; n >= i; i+=2){
    a[i] = (24 - a[i])%24;
  }
  sort(a.begin(),a.end());
  int ans = 10000;
  for(int i = 1; n >= i; i++){
    ans = min(ans,a[i]-a[i-1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256