akhauriyash/Code-Regression huggingface dataset:
import random


class Dice():

    def __init__(self, label):
        self.label = label

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def change(self, convert):
        num = []
        for i in range(6):
            num.append(self.label[convert[i] - 1])
        self.label = num


def main():
    dice = Dice([int(x) for x in input().split()])
    n = int(input())
    for i in range(n):
        upper, front = [int(x) for x in input().split()]
        while dice.label[0] != upper or dice.label[1] != front:
            direction = random.randint(0, 3)
            if direction == 0:
                dice.north()
            elif direction == 1:
                dice.west()
            elif direction == 2:
                dice.east()
            elif direction == 3:
                dice.south()
        print(dice.label[2])


if __name__ == '__main__':
    main()

Measured memory_bytes: 11724
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = input()
r = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    else:
        b += 1

print('Yes' if r>b else 'No')


Measured memory_bytes: 38384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, m, ans, a[MAXN];

bool check(int mid)
{
    for(rint i=mid*2+1, j=2*n; i<=j; i++, j--)
        if(a[i]+a[j]<m) return false;
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(rint i=1; i<=n*2; ++i) scanf("%d", &a[i]);
    sort(a+1, a+n*2+1);
    int l=0, r=n, pos=0;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check(mid)) pos=mid, r=mid-1;
        else l=mid+1;
    }
    for(rint i=1, j=pos*2; i<=j; ++i, --j) ans=max(ans, a[i]+a[j]);
    for(rint i=pos*2+1, j=2*n; i<+j; ++i, --j) ans=max(ans, a[i]+a[j]-m);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, X, Y; cin >> N >> X >> Y;
  X--; Y--;
  vector<int> ans(N+1,0);

  rep(i,N){
    for (int j=i+1;j<N;j++){
      int d = min({abs(i-j), abs(X-i)+abs(Y-j)+1, abs(X-j)+abs(Y-i)+1});
      ans[d]++;
    } 
  }

  rep(j,N-1) cout << ans[j+1] << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

	string s;
	cin >> s;

	string t = "";
	rep(i, s.length()){
		t += s[i];
		if(t + "FESTIVAL" == s){
			cout << t << endl;
		}
	}

    return 0;
}






Measured memory_bytes: 256
num = input()

def enum(num):  # str -> list[str]
    enumerated = [num]
    for i in range(1, len(num)):
        head = num[:i]
        for tail in enum(num[i:]):
            enumerated.append(head + '+' + tail)
    return enumerated

candidates = enum(num)
ans = sum([eval(eq) for eq in candidates])
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;
    int l[N];
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            if(l[i]<l[j]){
                swap(l[i],l[j]);
            }
        }
    }
    int sum=0;
    for(int i=0;i<K;i++)
        sum+=l[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
	int i,j,k;
	char S[100];
	int Count[26] = {0};

	scanf("%s",S);

	for (i = 0; i < strlen(S); i++){
		for(j=0;j<26;j++){
			if(S[i] == 'a'+j){
				Count[j]++;
				break;
			}
		}
	}

	for(i=0;i<26;i++){
		// printf("%c is %d\n",'a'+i,Count[i]);
		if(Count[i]%2 !=0){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	

	return 0;
}

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

using namespace std;

#define rep(i,n) for(int (i)=1;(i)<=(n);(i)++)

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int x = b/a;
  if(x<c)cout << x << endl;
  else cout << c << endl;
}


Measured memory_bytes: 256
function Main(input) {
	const [n, k] = input.split("\n").map(n => Number(n));
  	let result = 1;
  	for (let i = 0; i < n; i++) {
		result += Math.min(result, k);
    }
  	console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<cstdio>

int n,q;
int A[2000],m[2000];

bool solve(int i,int m){
  bool res;
  
  if(m == 0) return true;
  if(i >= n) return false;

  res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}
  
int main(){
  std::scanf("%d",&n);

  for(int i = 0;i < n;i++){
    std::scanf("%d",&A[i]);
  }

  std::scanf("%d",&q);

  for(int i = 0;i < q;i++){
    std::scanf("%d",&m[i]);
    if(solve(0,m[i])){
      std::printf("yes\n");
    }else{
      std::printf("no\n");
    }
  }

  return 0;
}

  



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

int keta(const ll x){

  if(x==0) return 0;
  int keta = 0;
  ll q = x;
  
  while(q > 0){
    q /= 10;
    ++keta;
  }
  
  return keta;
}

int main(){
  ll n;
  cin >> n;
  
  vector<int> v;
  
  ll i = 1;
  while(i*i <= n){
    if(n % i == 0){
      v.push_back(max(keta(i), keta(n/i)));
    }
    ++i;
  }
  
  sort(v.begin(), v.end());
  cout << v[0] << endl;
}

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

using namespace std;

class Solution {
public:
	string normalize(string s) {
		stack<char> st;
		for (char c : s) {
			if (c == '(')
				st.push('(');
			else {
				if (!st.empty() && st.top() == '(')
					st.pop();
				else
					st.push(')');
			}
		}
		string ret;
		while (!st.empty()) {
			ret += st.top();
			st.pop();
		}
		reverse(ret.begin(), ret.end());
		return ret;
	}

	void solve() {
		int n;
		cin >> n;
		vector<string> ss(n);
		for (int i = 0; i < n; i++) {
			string t;
			cin >> t;
			ss[i] = normalize(t);
		}
		int d = 0, e = 0;
		vector<pair<int, int>> mp, mm;
		for (int i = 0; i < n; i++) {
			if (ss[i][0] == '(') {
				d += ss[i].length();
				continue;
			}
			if (ss[i].back() == ')') {
				e += ss[i].length();
				continue;
			}
			int m = 0, p = 0;
			for (int j = 0; j < ss[i].length(); j++) {
				if (ss[i][j] == ')')
					m++;
				else
					p++;
			}
			if (p >= m) {
				mp.push_back({m, p - m});
			} else {
				mm.push_back({m - p, m});
			}
		}
		sort(mp.begin(), mp.end());
		sort(mm.begin(), mm.end());
		for (int i = 0; i < mp.size(); i++) {
			if (mp[i].first > d) {
				cout << "No\n";
				return;
			}
			d += mp[i].second;
		}
		for (int i = 0; i < mm.size(); i++) {
			if (mm[i].second > d) {
				cout << "No\n";
				return;
			}
			d -= mm[i].first;
		}
		if (d != e) {
			cout << "No\n";
			return;
		}
		cout << "Yes\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 34616
function Main(input) {
  
	readlines = input.split("\n");
	var n = readlines[0];
	var a = readlines[1].split(" ").map(Number);
	var ans = 0;
	for(let i = 0; i < n; i++){
	  if(i % 2 === 0 && a[i] % 2 === 1){
	    ans++;
	  }
	}
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    ll now_s;
    rep(__,15){
        int init = rnd1(mt);
        rep(i,d)now[i] = (init+i)%26;
        now_s = score();
        if(best < now_s){
            best = now_s;
            rep(j,d)t[j] = now[j];
        }        
        rep(_,500){
            // cout << best << endl;
            // rep(i,d)now[i] = rnd1(mt);
            int choice = rnd2(mt);
            rep(i,26){
                now[choice] = i;
                now_s = score();
                if(best < now_s){
                    best = now_s;
                    rep(j,d)t[j] = now[j];
                }
            }
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3672
H, W, K = [int(str) for str in input().strip().split()]

MOD = 1000000007

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1

for h in range(H):
    for w in range(W):
        for bit in range(2 ** (W - 1)):
            if bit & (bit << 1):
                continue

            
            if w > 0 and bit & (1 << (w - 1)):
                dp[h + 1][w - 1] += dp[h][w]
                dp[h + 1][w - 1] %= MOD
            
            elif w < W - 1 and bit & (1 << w):
                dp[h + 1][w + 1] += dp[h][w]
                dp[h + 1][w + 1] %= MOD

            else:
                dp[h + 1][w] += dp[h][w]
                dp[h + 1][w] %= MOD

print(dp[H][K - 1])

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

set<string> ans;
int N;

void dfs(int depth, vector<int> a) {
	if (depth != N) {
		for (int i = 0; i < depth + 1; i++) {
			a.push_back(i);
			dfs(depth + 1, a);
			a.pop_back();
		}
	}
	else {
		vector<int> s(10, -1);
		string S = "";
		for (int i = 0, j = 0; i < a.size(); i++) {
			if (s[a[i]] == -1) {
				s[a[i]] = j;
				j++;
			}
		}
		for (int i = 0; i < a.size(); i++) {
			S += 'a' + s[a[i]];
		}
		ans.insert(S);
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	dfs(1, vector<int>(1, 0));
	for (auto itr = ans.begin(); itr != ans.end(); itr++) {
		cout << *itr << '\n';
	}
}

Measured memory_bytes: 14208
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var a = input[0];
            var b = input[1];
            var c = input[2];
            bool f = false;
            for (int i = 0; i < b; i++)
            {
                if (a % b * i % b == c)
                    f = true;
            }
            if (f)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");


            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
n = int(input())
dp = [[-float("inf") for x in range(3)] for x in range(n)]
dp[0] = list(map(int,input().split()))
for i in range(1,n):
    a = list(map(int,input().split()))
    for x in range(3):
        for y in range(3):
            if(x == y):
                continue
            if(dp[i-1][x]+a[y]>dp[i][y]):
                dp[i][y] = dp[i-1][x]+a[y]
print(max(dp[-1]))


Measured memory_bytes: 24412
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;
const int MOD = 2019;

int main(){
  std::string s;
  std::cin >> s;
  int N = s.size();

  vt<int> p(N);
  int ten = 1;
  rep(i,N){
    if(s[N-1-i] != '0'){
    int x = (s[N-1-i]-'0')*ten;
    p[i] = (x + (i > 0 ? p[i-1] : 0))%MOD;
    }
    ten*=10;
    ten%=MOD;
  }

  vt<int> v(2019);
  rep(i,p.size()){
    v[p[i]]++;
  }
  int ans = 0;
  rep(i,2019){
    if(i==0)
      ans += v[0];
    ans += v[i]*(v[i]-1)/2;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4452
package main

import "fmt"

func main() {
	var iStr string
	fmt.Scanf("%s", &iStr)

	var curForward, curBack, ans int
	iStrLen := len(iStr)

	curForward = (iStrLen - (iStrLen % 2)) / 2 - 1
	curBack = (iStrLen - (iStrLen % 2)) / 2
	if iStrLen % 2 == 1 {
		curBack++
	}

	for i:= curBack; i < iStrLen; i++ {
		if iStr[i] != iStr[curForward] {
			ans++
		}
		curForward--
	}

	fmt.Print(ans)
}


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

void solve(long long N, long long M){
    if (N > M) {swap(N, M);}
    long long ans = 0;

    if (M == 1) { ans = 1; }
    else if (N == 1) { ans = max(0LL, M - 2); }
    else if (N == 2 or M == 2) { ans = 0; }
    else { ans = (N - 2) * (M - 2); }
	cout << ans << endl;
}

int main(){	
	long long N;
	long long M;
	cin >> N >> M;
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    for (int i = 1; i <= K; i++){
        if (A >= B){
            B *= 2;
        }
        else{
            C *= 2;
        }
    }
    if (A < B && B < C){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int n; ll k; 
VL a, f;
bool check(ll x) {
    ll cnt = 0;
    FOR(i, 0, n) {
        if (a[i] * f[i] <= x)continue;
        cnt += a[i] - x / f[i];
    }
    return cnt <= k;
}

int main() {
    init();

    cin >> n >> k;
    a.resize(n), f.resize(n); cin >> a >> f;

    SORT(a), rSORT(f, greater<ll>());
    ll ng = -1LL, ok = 1000000000000LL;
    while (ok - ng > 1) {
        ll mid = (ng + ok) / 2;
        if (check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
}


Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return set([i for i in range(n + 1) if is_prime[i]])
sosuu = primes(10**5*2+2)
lst=[0]*(10**5+1)
for i in range(10**5):
 if (i+1) in sosuu and int((i+2)/2) in sosuu and (i+1)!=2:
  lst[i+1]=lst[i]+1
 else:
  lst[i+1]=lst[i]
ans=0
Q=int(input())
for j in range(Q):
 l,r = map(int,input().split())
 print(lst[r]-lst[l-1])


Measured memory_bytes: 5864
/*
  AtCoder Beginner Contest 093
  C - Same Intergers
*/

#include<iostream>
#include<algorithm>
using namespace std;

int X[3];

int main() {
  scanf("%d%d%d", &X[0], &X[1], &X[2]);
  sort(X, X+3);

  int count = X[2] - X[1];
  X[0] += count;
  int div = (X[2] - X[0]) / 2;
  if (X[2] == X[0] + 2 * div) printf("%d\n", count + div);
  else printf("%d\n", count + div + 2);

  return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

long s[100001];

int main(void){
	int n, i;
	long k;
	scanf("%d%ld", &n, &k);
	for(i=0; i<n; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		s[a]+=b;
	}
	long now=0;
	for(i=0; i<=100000; i++){
		now+=s[i];
		if(now>=k) break;
	}
	printf("%d\n", i);
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string S;
  cin >> S;
  int len = S.length();
  for (int i = 1; i < len; i++) {
    int len1 = (len-i)/2;
    int len2 = len-i-len1;
    if (len1!=len2) continue;

    string s1 = S.substr(0, len1);
    string s2 = S.substr(len1, len2);
    if (s1==s2) {
      cout << len1+len2 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)


int main(){
	
    std::string S; std::cin >> S;

    if((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3]))std::cout << "Yes";
    else std::cout << "No";

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int N;
    int a[100];
    cin >> N;
    for(int i=0; i<N; i++)
    {
    	cin >> a[i];
    }
    double sum = 0;
    for(int i=0; i<N; i++)
    {
    	sum += (double) (a[i]);
    }
    double ave = sum/N, opt=fabs(a[0]-ave);
    int ans = 0;
    for(int i=1; i<N; i++)
    {
        if(fabs((double) (a[i])-ave)<opt)
        {
        	ans = i;
        	opt = fabs((double) (a[i])-ave);
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		int ans = S.replace("-", "").length() - S.replace("+", "").length();
		System.out.println(ans);
		scanner.close();
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int m,n=inf;
    cin >> m;
    vector<string> name(m);
    vector<set<int>> vs(m);
    rep(i,0,m){
        int lb,ub;
        cin >> name[i] >> lb >> ub;
        rep(j,lb,ub+1) vs[i].insert(j);
    }
    cin >> n;

    stack<set<int>> stk;
    rep(i,0,n){
        string e;
        cin >> e;
        if(e=="+" or e=="-" or e=="*" or e=="/"){
            set<int> s2=stk.top(); stk.pop();
            set<int> s1=stk.top(); stk.pop();
            set<int> tmp;
            for(auto a:s1) for(auto b:s2){
                if(e=="+") tmp.insert((a+b)%256);
                if(e=="-") tmp.insert((a-b+256)%256);
                if(e=="*") tmp.insert(a*b%256);
                if(e=="/"){
                    if(b==0){
                        cout << "error" << endl;
                        return;
                    }
                    tmp.insert(a/b);
                }
            }
            stk.push(tmp);
            continue;
        }

        bool flag=true;
        rep(j,0,m) if(name[j]==e){
            stk.push(vs[j]);
            flag=false;
            break;
        }
        if(flag){
            set<int> tmp;
            tmp.insert(stoi(e));
            stk.push(tmp);
        }
    }
    cout << "correct" << endl;
}

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

Measured memory_bytes: 3384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;
int r[20000];
int main(void){

	int n, s;
	while (true){
		cin >> n >> s;
		int cnt[101] = { 0 };
		if (n == 0 && s == 0)return 0;
		for (int i = 0; i < n; i++)
		{
			cin >> r[i];
			for (int j = 0; j <= r[i]; j++)
				cnt[j]++;
		}
		int res = 0;
		for (int i = 0; i < n; i++)
		{
			res += cnt[max(0, s - r[i]+1)];
			if (r[i] * 2 > s)res--;
		}
		cout << res/2 << endl;
		

	}

	return 0;
}

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

#define FOR(i,s,t) for(int i = s ; i < t ; i++)

int main() {

	string s;
	while (cin >> s) {
		if (s == "#")break;
		int y, m, d; cin >> y >> m >> d;
		bool ok = 0;
		if (y < 31 || (y == 31 && m <= 4)) {
			ok = 1;
		}
		else {
			y -= 30;
		}


		if (ok) {
			cout << "HEISEI" << " " << y << " " << m << " " << d << endl;
		}
		else {
			cout << "?" << " " << y << " " << m << " " << d << endl;
		}
	}
}


Measured memory_bytes: 3224
import java.util.*;
 
// ABC 19-C
// http://abc019.contest.atcoder.jp/tasks/abc019_3
 
public class Main {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		System.out.println(b - a == c - b ? "YES" : "NO");
		
//		int t = in.nextInt();
//		int num = 1;
//		while (t-- > 0) {
//			int n = in.nextInt();
//			
//			while (!isTidy(n)) {
//				n--;
//			}
//			System.out.printf("Case #%d: %d\n", num, n);
//			num++;
//		}
	}	
	
	public static boolean isTidy(int n) {
		if (n < 10) {
			return true;
		}
		int pre = n % 10;
		n /= 10;
		int curr = n % 10;
		
		while (n > 0) {
			if (pre < curr) {
				return false;
			}
			pre = curr;
			n /= 10;
			curr = n % 10;
		}
		return true;
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <string>
#include <set>
#define llint long long

using namespace std;

string s;
string t = "qwertasdfgzxcvb";
bool used[26];

int main(void)
{
	for(int i = 0; i < t.size(); i++) used[t[i]-'a'] = true;
	
	while(1){
		cin >> s;
		if(s == "#") break;
		
		llint ans = 0;
		for(int i = 1; i < s.size(); i++){
			if(used[s[i]-'a'] != used[s[i-1]-'a']) ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3184
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    int n = IO.GetInt();
	    List<int> c = IO.GetIntList();
	    c.Sort();
	    List<Modular> two = new List<Modular>();
	    two.Add(new Modular(1));
	    for(int i=1;i<n+1;i++){
	        two.Add(two[i-1] * 2);
	    }
	    Modular ans = new Modular(0);
	    for(int i=0;i<n;i++){
	        int r = n-1-i;
	        Modular temp = two[r];
	        if(r != 0)temp = temp + (two[r-1] * r);
	        temp = temp * new Modular(c[i]);
	        temp = temp * two[i];
	        ans = ans + temp;
	    }
	    ans = ans * two[n];
	    Console.WriteLine((int)ans);
	    
	}
    
}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    private static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
        case 0:
            return 1;
        case 1:
            return a;
        default:
            var p = Pow(a, n / 2);
            return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    private static readonly List<int> facs = new List<int> { 1 };
    private static Modular Fac(int n)
    {
        for (int i = facs.Count; i <= n; ++i)
        {
            facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
        }
        return facs[n];
    }
    public static Modular Ncr(int n, int r)
    {
        return (n < r)  ? 0
             : (n == r) ? 1
                        : Fac(n) / (Fac(r) * Fac(n - r));
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}

Measured memory_bytes: 45220
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int h,w,n;

main(){
  cin>>w>>h>>n;
  vector<P> v;

  rep(i,n){
    int a,b;
    cin>>a>>b;
    v.PB(P(b,a));
  }

  
  sort(all(v));
  vector<int> res[210000];
  rep(i,n){
    res[v[i].F].PB(v[i].S);
  }

  int r=0;
  int ans=w;

 
  FOR(i,1,h+1){
    r++;
    while(find(all(res[i]),r)!=res[i].end()) r++;
    auto it = lower_bound(all(res[i]),r);
    //cout<<r<<' ';
    if(it==res[i].end()) continue;
    ans=min(ans,*it-1);
  }
  //cout<<endl;

  cout<<ans<<endl;
}



Measured memory_bytes: 12908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ll k,n;
  cin >> k >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(all(vec));
  ll maxi = 0;
  rep(i,n-1){
    chmax(maxi,vec[i+1]- vec[i]);
  }
  chmax(maxi,vec[0] + k - vec[n-1]);
  cout << k-maxi << endl;
}


Measured memory_bytes: 1792
import math
a, b, h, m = map(int, input().split())
if (h==12):
  h= 0
if (m == 60):
  m = 0
hour_angle = 0.5 * (h * 60 + m) 
minute_angle = 6 * m  
angle = abs(hour_angle - minute_angle)  
angle = min(360 - angle, angle)
dis = (a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
dis = dis**(0.5)
print("{0:.12f}".format(dis))

Measured memory_bytes: 9548
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans=0
    for i in range(1,N+1):
        if i%3==0 or i%5==0:
            pass
        else:
            ans+=i
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9048
S = input()
length = len(S)
ans = [0] * length
pre_s = ""
start_i = 0
for i, s in enumerate(S):
    if pre_s == 'R' and s == 'L':
        r_i = i - 1
        l_i = i
    elif pre_s == 'L' and s == 'R':
        end_i = i - 1
        n = end_i - start_i + 1
        ans[r_i] = 1 + (end_i - l_i + 1) // 2 + (r_i - start_i) // 2
        ans[l_i] = n - ans[r_i]
        start_i = i
    if i == length - 1:
        end_i = i
        n = end_i - start_i + 1
        ans[r_i] =  1 + (end_i - l_i + 1) // 2 + (r_i - start_i) // 2
        ans[l_i] = n - ans[r_i]
    pre_s = s
print(" ".join([str(i) for i in ans]))

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<pair<lint, lint>> A(N);
  REP(i, N) {
    lint a;
    cin >> a;
    A[i] = make_pair(a, i);
  }
  sort(A.begin(), A.end(), [](auto const &a, auto const &b) { return a.first > b.first;});
  vector<vector<lint>> dp(N+1, vector<lint>(N+1));
  REP(i, N) {
    REP(j, i+1) {
      if(dp[i][j] + A[i].first*abs(A[i].second - j) > dp[i+1][j+1]) {
        dp[i+1][j+1] = dp[i][j] + A[i].first*abs(A[i].second - j);
      }
      if(dp[i][j] + A[i].first*abs(A[i].second - (N-1-(i-j))) > dp[i+1][j]) {
        dp[i+1][j] = dp[i][j] + A[i].first*abs(A[i].second - (N-1-(i-j)));
      }
    }
  }
  lint ans = 0;
  REP(i, N+1) {
    if(dp[N][i] > ans) ans = dp[N][i];
  }
  cout << ans << endl;
}

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

main() {
    for(;;){
        int a; char c; int b;
        cin >> a >> c >> b;
        if(c=='+'){
            cout << a+b << endl;
        }
        else if(c=='-'){
            cout << a-b << endl;
        }
        else if(c=='*'){
            cout << a*b << endl;
        }
        else if(c=='/'){
            cout << a/b << endl;
        }
        else break;
    }

    return 0;
}


Measured memory_bytes: 3084
a, b, c, d = gets.chomp.split().map(&:to_i)

ac = (a-1) / c
ad = (a-1) / d
bc = b / c
bd = b / d
cd_lcm = c.lcm(d)
acd_lcm = (a-1) / cd_lcm
bcd_lcm = b / cd_lcm

l = b - a + 1

puts l - (bc - ac) - (bd - ad) + (bcd_lcm - acd_lcm)


Measured memory_bytes: 14120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  ll x, y; cin >> x >> y;

  int cnt = 0;
  while(x <= y){
    cnt++;
    x *= 2;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include<tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-7)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define R pair<pair<int, int>, pair<int, int>>
#define S(i,j,k,l) mkp(mkp(i,j),mkp(k,l))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(n,i) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem(x,k) memset(x,k,sizeof(x))
#define vec vector
#define pb emplace_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'a')
#define itoc(c) (char)(c+'a')
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
#define pppp(x,y,z,w) pb(S(x,y,z,w))
#define cyes cout<<"Yes\n"
#define cno cout<<"No\n"
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
const vec<int>dx{ -1,1,0,0 }, dy{ 0,0,-1,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; }
ll read() { ll u, k = scanf("%lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 1000005;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//--------------------------------------------------------------
signed main() {
	int n = read();
	map<string, int>ma;
	rep(i, n) ma[reads()]++;
	vec<pair<string, int>>v;
	int k = 0;
	for (auto g : ma) {
		v.pb(g);
		k = max(k, g.sc);
	}
	sort(all(v));
	rep(i, v.size()) {
		if (v[i].sc == k) cout << v[i].fs << endl;
	}
}

Measured memory_bytes: 29556
#include<stdio.h>
#include<stdlib.h>


int main()
{
	int N, A, B;
	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);
	if (N*A < B) 
	{
		printf("%d", N*A);
	}
	else
	{
		printf("%d", B);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(W-x>=r&&x>=r&&H-y>=r&&y>=r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
return 0;

}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define display(v,c) for(auto x:v) cout<<x<<c;
#define P_Q priority_queue<ll>
#define p_q priority_queue<ll,vi(ll),greater<ll>>
#define loop(i,x,y,z) for(int i=x; i<=y; i+=z)
#define vi(type) vector<type>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool isPrime(ll n)
{
    for(ll i=2;i*i<n;i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
    IOS
    ll n;
    cin>>n;
    ll ans=0;
    ll maxans=INT_MIN;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=i-1;
            ans+=(n/i - 1);
        }
        maxans=min(maxans,ans);
    }
    if(ans!=0)
        cout<<ans<<endl;
    else
    {
        cout<<n-1<<endl;
    }
    
    // set<pair<ll,ll>> s;
    // if(isPrime(n))  cout<<n-1<<endl;
    // else
    // {
    //     // queue<vector<ll>> q;
    //     // q.push({1,1,1,0});
    //     // s.insert({1,1});
    //     // while(!q.empty())
    //     // {
    //     //     auto v=q.front();
    //     //     q.pop();
    //     //     if(v[2]==n)
    //     //     {
    //     //         cout<<v[3]<<endl;
    //     //         return 0;
    //     //     }
            
    //     //     if(s.count({v[0]+1,v[1]})==0 && v[1]*(v[0]+1)<n)
    //     //     {
    //     //         s.insert({v[0]+1,v[1]});
    //     //         q.push({v[0]+1,v[1],v[1]*(v[0]+1),v[3]+1});
    //     //     }
    //     //     if(s.count({v[0],v[1]+1})==0 && v[0]*(v[1]+1)<n)
    //     //     {
    //     //         s.insert({v[0],v[1]+1});
    //     //         q.push({v[0],v[1]+1,v[0]*(v[1]+1),v[3]+1});
    //     //     }
    //     // }

    // }
    
    return 0;
}

Measured memory_bytes: 256
def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

A,B,C,D = map(int, input().split())
B_C = B // C
B_D = B // D
g = gcd(C,D)
l = C * D // g
duplicate_B = B // l
answer_B = B - B_C - B_D + duplicate_B

A_C = (A - 1) // C
A_D = (A - 1) // D
duplicate_A = (A - 1) // l
answer_A = (A - 1) - A_C - A_D + duplicate_A
print(int(answer_B - answer_A))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main() {
	string line;
	long long m=0;
	getline(cin, line);
	for(int i=0;i<line.size();i++) m += line[i]-'0';

	for(int i=0;i<line.size();i++){
		if(line[i]=='0') continue;
		long long a=0;
		for(int j=0;j<i;j++) a += line[j]-'0';
		a += line[i]-'0'-1;
		a += (line.size()-i-1)*9;
		if(m<a)m=a;
	}
	cout<<m<<endl;

	return 0;
}

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

int main ()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	int r;
	cin >> r;
	
	const long double pi = 3.141592653;
	cout << (long double)r * 2 * pi;
	
    return 0;
}


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

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

    int ans = 0;
    for(int i = 0; i < N; i++){
        string t1 = S.substr(0, i);
        string t2 = S.substr(i);

        int tmp = 0;
        for(char c = 'a'; c <= 'z'; c++){
            if((t1.find(c) != string::npos) && (t2.find(c) != string::npos))
                tmp++;
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x[10000];
    int i;
    int length=0;
    do{
        scanf("%d", &x[length]);
        length += 1;
    }while(x[length-1] != 0);
    for(i=0; i<length-1; i++){
        printf("Case %d: %d\n", i+1, x[i]);
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    int dx, dy;
    int d;
    dx = x2 - x1;
    dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x1 - dy;
    y4 = y1 + dx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}




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

signed main() {
  string S;
  cin >> S;
  int N = (int)S.size();
  
  int ans = 0;
  for( int i = 0; i < N/2; i++ ){
    if( S.at(i) != S.at(N-1-i) ) ans++;
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=deque([])
for w,v in WV:
    nlst=deque([[w,v]])
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1+w<=W:
            if w1:
                nlst.append([w1+w,v1+v])
    if not lst:
        lst=copy.copy(nlst)
        continue
    Xlst=lst
    lst=deque()

    if Xlst or nlst:
        w1,v1=nlst[0]
        w2,v2=Xlst[0]
        if w1<w2:
            lst.append(nlst.popleft())
        else:
            lst.append(Xlst.popleft())
    while Xlst or nlst:
        w,v=lst[-1]
        if Xlst and nlst:
            w1,v1=nlst[0]
            w2,v2=Xlst[0]

            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            elif w==w2:
                if v>=v2:
                    Xlst.popleft()
                else:
                    lst.pop()
                    lst.append(Xlst.popleft())
            else:
                if w1<w2:
                    if v>=v1:
                        nlst.popleft()
                    else:
                        lst.append(nlst.popleft())
                else:
                    if v>=v2:
                        Xlst.popleft()
                    else:
                        lst.append(Xlst.popleft())
        elif nlst:
            w1,v1=nlst[0]
            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            else:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.append(nlst.popleft())
        elif Xlst:
            nlst=Xlst
            Xlst=deque()



lst.append([0,0])
print(max([v for w,v in lst if w<=W]))


Measured memory_bytes: 3700
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())

    ret = float('inf')
    for i in range(1, 10000000):
        q, mod = divmod(N, i)
        if mod == 0:
            j = N // i
            ret = min(ret, ((j-1)+(i-1)))

    print(ret)


if __name__ == '__main__':
    main()

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

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

  ll ans = 0;
  rep(i, n - 1) {
    ll cost = min((x[i + 1] - x[i]) * a, b);
    ans += cost;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4036
#include <stdio.h>
#include <math.h>
#include <string.h>
int abs(int n){
    if(n > 0){
        return n;
    } else {
        return -n;
    }
}

int min(int a, int b){
    if(a > b){
        return b;
    } else {
        return a;
    }
}

int max(int n[]){
    int m = 0;
    for(int i = 0; i < 100; i++){
        if(n[i] > m){
            m = n[i];
        }
    }
    return m;
}


int main(){
  int n;
  scanf("%d", &n);
  int l[100] = {};
  for(int i = 0; i < n; i++){
    scanf("%d", &l[i]);
  }

  int m = max(l);
  int sum = 0;
  int count = 0;
  for(int i = 0; i < n; i++){
    if(l[i]!=m){
        sum+=l[i];
    } else {
        if(count!=0){
          sum+=l[i];      
        } else {
          count++;
        }
    }
  }
  
  if(sum > m){
      printf("Yes");
  } else {
      printf("No");
  }
  return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#define INFTY 1000000000

int c=0;
int n1,n2;

void merge(int A[], int l, int m, int r){
  n1=m-l;
  n2=r-m;
  int L[n1], R[n2];
  int i=0, j=0, k=0;
  for(i=0;i<n1;i++)L[i]=A[l+i];
  for(i=0;i<n2;i++)R[i]=A[m+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=l;k<r;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
      c++;
    }else{
      c++;
      A[k]=R[j];
      j=j+1;
    }
  }
}

void mergesort(int A[], int l, int r){
  if(l+1<r){
    int m;
    m = (l+r)/2;
    mergesort(A, l, m);
    mergesort(A, m, r);
    merge(A, l, m, r);
  }
}

int main(){
  int n,i;
  int A[500000];
  scanf("%d",&n);
   for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  mergesort(A,0,n);
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",A[i]);
      break;
    }
    printf("%d ",A[i]);
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 5672
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#define ll long long
using namespace std;

ll n;
ll w;
vector<pair<ll, ll>> v;
map<pair<ll, ll>, ll> mp;

ll f(ll i, ll wlimit){
    ll ret;

    if (wlimit < 0 || i >= n) return 0;

    auto itr = mp.find(make_pair(i, wlimit));
    if (itr != mp.end()){
        ret = itr -> second;
    } else {
        if (v[i].first <= wlimit) {
            ret = max(f(i + 1, wlimit - v[i].first) + v[i].second, f(i + 1, wlimit));
        } else {
            ret = f(i + 1, wlimit);
        }
    }

    mp[make_pair(i, wlimit)] = ret;
    return ret;
}

int main(void){
    cin >> n >> w;
    for(ll i=0; i<n; i++){
        ll a,b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    cout << f(0, w) << endl;
}


Measured memory_bytes: 6272