akhauriyash/Code-Regression huggingface dataset:
S = input()

ans="No"
if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] and S[2] == S[3]:
  ans = "Yes"
elif S[1] == S[2] and S[1] != S[0] and S[1] != S[3] and S[0] == S[3]:
  ans = "Yes"
elif S[2] == S[3] and S[2] != S[0] and S[2] != S[1] and S[0] == S[1]:
  ans = "Yes"
elif S[3] == S[0] and S[3] != S[1] and S[3] != S[2] and S[1] == S[2]:
  ans = "Yes"
elif S[1] == S[3] and S[1] != S[0] and S[1] != S[2] and S[2] == S[0]:
  ans = "Yes"

print(ans)

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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int K;
	cin >> K;

	vector<bool> A(K, false);
	int s = 0;

	for (int i = 0;; i++)
	{
		s = s * 10 + 7;
		if (s%K == 0)
		{
			cout << i + 1 << endl;
			break;
		}
		else if (A[s%K])
		{
			cout << -1 << endl;
			break;
		}
		else
		{
			A[s%K] = true;
			s %= K;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    
    rep(i,b){
        rep(j,a) cout<<0;
        rep(j,w-a) cout<<1;
        cout<<endl;
    }
    rep(i,h-b){rep(j,a)
        cout<<1;
        rep(j,w-a) cout<<0;
        cout<<endl;
    }
}


Measured memory_bytes: 1280
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    h, w, k = MI()
    C = []
    for _ in range(h):
        C.append(input())
    c_h = [0]*h
    c_w = [0]*w
    cnt = 0
    for i in range(h):
        for j in range(w):
            if C[i][j] == '#':
                c_h[i] += 1
                c_w[j] += 1
                cnt += 1
    ans = 0
    for i in range(2**h):
        for j in range(2**w):
            cnt_temp = cnt
            row = []
            col = []
            for ii in range(h):
                if ((i >> ii) & 1):
                    cnt_temp -= c_h[ii]
                    row.append(ii)
            for jj in range(w):
                if ((j >> jj) & 1):
                    cnt_temp -= c_w[jj]
                    col.append(jj)
            for ro in row:
                for co in col:
                    if C[ro][co] == '#':
                        cnt_temp += 1
            if cnt_temp == k:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9280
def main():
    import heapq
    
    def dijkstra(graph,s,cd,c):
        dist = [[float("inf")]*2505 for _ in range(n)]
        q = []
        dist[s][c] = 0
        heapq.heappush(q, (0,s,c))
        
        while q:
            d, p,c = heapq.heappop(q)
            
            if dist[p][c] < d:
                continue
            
            for nn,nc,nt  in graph[p]:
                if c >= nc and dist[nn][c-nc] >   d+nt:
                    dist[nn][c-nc] =    d+nt
                    heapq.heappush(q,(d+nt,nn,c-nc))
            if c+cd[p][0] < 2500:
                if dist[p][c+cd[p][0]] >  d+cd[p][1]:
                    dist[p][c+cd[p][0]] = d+cd[p][1]
                    heapq.heappush(q, (d+cd[p][1],p,c+cd[p][0]))
            else:
                if dist[p][2500] >  d+cd[p][1]:
                    dist[p][2500] = d+cd[p][1]
                    heapq.heappush(q, (d+cd[p][1],p,2500))
                    
        for i in dist[1:]:
            print(min(i))
    n,m,s = map(int,input().split())
    E = [[] for i in range(n)]
    la = []
    for i in range(m):
        u,v,a,b = map(int,input().split())
        u -= 1
        v-= 1
        la.append(a)
        E[u].append((v,a,b))
        E[v].append((u,a,b))

    cd = [list(map(int,input().split())) for i in range(n)]

    dijkstra(E,0,cd,min(s,2500))
if __name__ == "__main__":
    main()

Measured memory_bytes: 26236
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0

msg='No'

if a1[0] == 0:
    if a1[1] == 0:
        if a1[2] == 0:
            msg='Yes'
    if a2[0] == 0:
        if a3[0] == 0:
            msg='Yes'
    if a2[1] == 0:
        if a3[2] == 0:
            msg='Yes'
if 0 == a1[1] == a2[1] == a3[1]:
    msg='Yes'
if 0 == a1[2] == a2[2] == a3[2]:
    msg='Yes'
if 0 == a2[0] == a2[1] == a2[2]:
    msg='Yes'
if 0 == a3[0] == a3[1] == a3[2]:
    msg='Yes'
if 0 == a1[2] == a2[1] == a3[0]:
    msg='Yes'
print(msg)

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

int top,S[1000];
void push(int x){
S[++top]=x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main()
{
    int a,b;
    top=0;
    char s[100];
    while (scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(s[0]=='-'){
            b=pop();
            a=pop();
            push(a-b);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    return 0;
}




Measured memory_bytes: 2052
N = int(input())
A = list(map(int, input().split()))
A_even = [i for i in A if i % 2 == 0]
flag_list = list(map(lambda x: (x % 3 == 0) or (x % 5 == 0), A_even))
print('APPROVED' if False not in flag_list else 'DENIED')


Measured memory_bytes: 2940
n=int(input())

import math

def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def prime_factorization_2(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1

        return dict_counter

l=prime_factorization_2(n)
ans=0

if l==False:pass
else:

    for div,nums in l.items():
        num=nums
        num-=1
        i=2
        while num>=0:
            ans+=1
            num-=i
            i+=1


print(ans)

Measured memory_bytes: 49336
from collections import defaultdict
from operator import itemgetter


def sub(prefers, canceled):
    res = defaultdict(int)
    for pref in prefers:
        p = pref[-1]
        while p in canceled:
            pref.pop()
            p = pref[-1]
        res[p] += 1

    return max(res.items(), key=itemgetter(1))


def solve(m, prefers):
    canceled = set()
    ans = float('inf')
    for _ in range(m):
        s, c = sub(prefers, canceled)
        canceled.add(s)
        ans = min(ans, c)
    return ans


n, m = map(int, input().split())
prefers = [list(reversed(list(map(int, input().split())))) for _ in range(n)]

print(solve(m, prefers))


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

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

    int A, B, K;
    cin >> A >> B >> K;

    int ans=0;
    int c=0;
    for (int i = min(A, B); i > 0; i--) {
        if (A % i == 0 && B % i == 0) {
            c++;
            if (c == K) {
                ans = i;
                break;
            }
        }
    }

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


Measured memory_bytes: 256
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    int n,i,k;
    char j;
    cin>>n;
    char s[90000];
    scanf("%s",s);
    k=strlen(s);
    for(i=0;i<k;i++)
    {
        if(s[i]+n<=90)
        {
            j=s[i]+n;
            cout<<j;
        }
        else{
            j=s[i]+n-26;
            cout<<j;
        }
    }

    return 0;
}



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

int main () {
  int A, B, X;
  cin >> A >> B >> X;
  
  if (A + B + 1 > X && X > A - 1)  {
    
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}

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


int main(){
	
	string str;

	getline(cin , str);
	
   if(str.length() <= 19)
   {
   	 for(int i =0 ; i< str.length(); i++)
   {
   	if(str.at(i) == ',')
		{
			str.at(i) = ' ';
		}	
    }
   
	cout<<str;
   }
  
}

Measured memory_bytes: 256
require 'bigdecimal'
input = STDIN.read.split("\n")
result = input.shift.to_i.times do
  x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| BigDecimal.new(e) }
  puts((y1 == y2 && y3 == y4) || (y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) ? 'YES' : 'NO')
end

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin>>s;  
    n=s.size();
    int ans = 1;
    bool prewas2=false;;
    for(int i=1;i<n;i++){
    	if(prewas2){
    		ans++;
    		prewas2=false;
    	}
    	else{
    		if(s[i]==s[i-1]){
    			if(i!=n-1)
    				ans++;
    			prewas2=true;
    			i++;
    		}
    		else{
    			ans++;
    		}
    	}
    }  
    cout<<ans;

    return 0;
}




Measured memory_bytes: 720
// https://atcoder.jp/contests/abc049/tasks/abc049_a
#include <bits/stdc++.h>
using namespace std;

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel";
  else
    cout << "consonant";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}


int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = lcm(A, B);
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque


def main():
    s = sys.stdin.readline().strip()
    q = int(sys.stdin.readline().strip())
    r = 0
    head = []
    bottom = []
    do_reverse = False
    for _ in range(q):
        command = sys.stdin.readline().strip().split(" ")
        # if command[0] == "1":
        #     s = s[::-1]
        # else:
        #     if command[1] == "1":
        #         s = command[2] + s
        #     else:
        #         s = s + command[2]
        if command[0] == "1":
            do_reverse = not do_reverse
            r += 1
        else:
            position_head = command[1] == "1"
            if do_reverse:
                position_head = not position_head
            if position_head:
                head.append(command[2])
            else:
                bottom.append(command[2])
    if r % 2 == 0:
        print("".join(head[::-1]) + s + "".join(bottom))
    else:
        print("".join(bottom[::-1]) + s[::-1] + "".join(head))


if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    unsigned long long arr[N];
    for (int i = 0; i < N;++i){
        cin >> arr[i];
        if(arr[i] == 0){
            cout << "0" << endl;
            return 0 ;
        }
    }
    unsigned long long ans=1;
    unsigned long long tei = 1000000000000000000;
    int flag = 1; 

    for (int i = 0; i < N;++i){
        if(double(tei/arr[i])< ans){
            flag = 0;
            break;
        }
        ans *= arr[i];
    }
    
    if(flag==0){
        cout << "-1" << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3920
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
ll add(ll x,ll y,ll mod=hell) { x += y; if(x >= mod) x -= mod; return x;}
ll sub(ll x,ll y,ll mod=hell) { x -= y; if(x < 0) x += mod; return x;}
ll mul(ll x,ll y,ll mod=hell) { return (x * 1ll * y) % mod;}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,k;
		cin>>n>>k;
		ll a[n],cnt1[n]={0},cnt2[n]={0};
		rep(i,0,n) cin>>a[i];
		ll ans=0;
		rep(i,0,n){
			rep(j,0,n){
				if(a[j]>=a[i]) continue;
				if(j>i) cnt1[i]++;
				cnt2[i]++;
			}
			ans=add(ans,add(mul(k,cnt1[i]),mul((k*k-(k*(k+1))/2)%hell,cnt2[i])));
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto N = lread();
    long ok = (N + 1);
    long ng = -1;
    while (abs(ok - ng) > 1)
    {
        long mid = (ok + ng) / 2;
        if (((mid + 1) * ((mid + 1) + 1)) / 2 >= N)
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    // writeln(ok + 1);
    foreach (i; 1 .. (ok + 1) + 1)
    {
        // writeln('t', (ok + 1) * ((ok + 1) + 1) / 2 - i);
        if ((ok + 1) * ((ok + 1) + 1) / 2 - i == N)
        {
            continue;
        }
        else
        {
            writeln(i);

        }

    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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 print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

ll n,k;
vector<ll> a;

bool solve(ll mid){
    ll now = 0;
    rep(i, n) now += (a[i] - 1) / mid;
    return now <= k;
}

ll binary_search(){
  ll ok = INF;
  ll ng = 0;
  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(solve(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  return ok;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> n >> k;
    a.resize(n);
    rep(i, n) cin >> a[i];
    print(binary_search());

}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	int a, b, c;
	cin >>a >> b >> c;
	cout << (a + b) * c / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
using LL = long long;


int main() {
	string s;
	map<char, int> mp;
	while (getline(cin, s)) {
		for (auto & e : s) {
			if (e >= 'A' && e <= 'Z') e += 32;
			mp[e]++;
		}
	}
	for (int i = 0; i < 26; i++) {
		char c = (i + 'a');
		cout << c << " : " << mp[c] << endl;
	}
	return 0;
}



Measured memory_bytes: 3176
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
    ll A,B;
    ll V,W;
    ll T;
    cin>>A>>V;
    cin>>B>>W;
    cin>>T;
    ll realDist=abs(A-B);
    ll limitDist=(V-W)*T;
    string ans;
    if(realDist <= limitDist){
        ans="YES";
    }else{
        ans="NO";

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

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

int main() {
  char S;
  cin >> S;

    if (S == 'a')
      cout << "vowel" << endl;
  
    else if(S == 'i')
      cout << "vowel" << endl;
    
    else if(S == 'u')
      cout << "vowel" << endl;
  
    else if(S == 'e')
      cout << "vowel" << endl;
  
    else if(S == 'o')
      cout << "vowel" << endl;
  
    else
      cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char Str[53];
	char Str2[53];
	while(scanf("%s%s",Str,Str2)!=EOF)
	{
		if(strlen(Str)<strlen(Str2))
		{
			for(int i=0;i<strlen(Str);i++)
			{
				printf("%c",Str[i]);
				printf("%c",Str2[i]);
			}
			printf("%c",Str2[strlen(Str)]);
		}
		else if(strlen(Str)>strlen(Str2))
		{
			for(int i=0;i<strlen(Str2);i++)
			{
				printf("%c",Str[i]);
				printf("%c",Str2[i]);
			}
			printf("%c",Str[strlen(Str2)]);
		}
		else
		{
			for(int i=0;i<strlen(Str);i++)
			{
				printf("%c",Str[i]);
				printf("%c",Str2[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
N, L = map(int,input().split())

# 各りんごの味の絶対値を算出し、最小の物を食べればよい
Apple_taste = [L+i for i in range(N)]
eaten_Apple = min(Apple_taste, key=abs)
Apple_taste.remove(eaten_Apple)
print(sum(Apple_taste))

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

int main(){
  int n,count,i;
  
  cin >> n;
  
  for(i = 0; i <= n; i++){
    if((i>=1 && i<=9)||(i>=100 && i<=999)||(i>=10000 && i<=99999)){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  string a, b;
  cin>>a>>b;

  ll ans = 0;
  for (int i=0; i<a.length(); i++)
    if (a[i] != b[i])
      ans++;
  cout<<ans<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3788
import java.util.Scanner;
class KnapsackProblem1 {
    public int knapsack (int[] value, int[] weight, int maxWeight) {
	int n = value.length;
	int[][] dp = new int[n + 1][maxWeight + 1];
	for (int i = n - 1; i >= 0; i--) {
	    for (int j = 0; j <= maxWeight; j++) {
		if (j < weight[i]) {
		    dp[i][j] = dp[i+1][j];
		}
		else {
		    dp[i][j] = Math.max(dp[i + 1][j], dp[i + 1][j - weight[i]] + value[i]);
		}
	    }
	}
	return dp[0][maxWeight];
    }
}

public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] input = scan.nextLine().split(" ");
	int n = Integer.parseInt(input[0]);
	int maxWeight = Integer.parseInt(input[1]);
	int[] value = new int[n];
	int[] weight = new int[n];
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    value[i] = Integer.parseInt(input[0]);
	    weight[i] = Integer.parseInt(input[1]);
	}
	KnapsackProblem1 kp = new KnapsackProblem1();
	System.out.println(kp.knapsack(value, weight, maxWeight));
    }
}

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

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

    int n;
    cin >> n;
    vector<int> v(n);

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        s += v[i];
    }

    cout << ((s % 2) ? "NO" : "YES") << '\n';
    return (0);
}


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

int gcd(int a, int b){
    if(a<b) swap(a,b);
    if(a%b==0) return b;
    return gcd(a%b,b);
}

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v.at(i);
    if(n==2){
        std::cout << max(v.at(0), v.at(1)) << endl;
        return 0;
    }
    vector<vector<int>> dp(n+1,vector<int>(2));
    dp.at(2).at(0) = gcd(v.at(0),v.at(1));
    dp.at(3).at(0) = gcd(dp.at(2).at(0),v.at(2));
    int a = gcd(v.at(0),v.at(1));
    int b = gcd(v.at(0),v.at(2));
    int c = gcd(v.at(1),v.at(2));
    dp.at(3).at(1) = max(max(a,b),c);

    for(int i=3;i<n;i++){
        dp.at(i+1).at(0) = gcd(dp.at(i).at(0), v.at(i));
        dp.at(i+1).at(1) = max(dp.at(i).at(0), gcd(dp.at(i).at(1), v.at(i)));
        // std::cout << i+1 << " " << dp.at(i+1).at(0) << " " << dp.at(i+1).at(1) << endl;
    }
    int res =  max(dp.at(n).at(0), dp.at(n).at(1));
    std::cout << res << endl;
    return 0;
}

Measured memory_bytes: 6144
import java.util.*;
import java.util.Arrays;
public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int []a=new int [10];
		for(int i=0;i<a.length;i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		for(int i=9;i>6;i--){
			System.out.println(a[i]);
		}
		

 }
}

Measured memory_bytes: 17332
import copy

n = int(input())
a = list(map(int, input().split()))
b = copy.deepcopy(a)

def f1(a):
    memo = 0
    count = 0
    for i in range(n):
        if i % 2 == 0:
            if a[i] <= 0:
                count += 1 - a[i]
                memo = 1 - a[i]
        else:
            if a[i] >= 0:
                count += a[i] + 1
                memo = -(a[i] + 1)
        if i + 1 < n:
            a[i + 1] = a[i + 1] + a[i] + memo
            memo = 0
    else:
        return count

def f2(a):
    memo = 0
    count = 0
    for i in range(n):
        if i % 2 == 0:
            if a[i] >= 0:
                count += a[i] + 1
                memo = -(a[i] + 1)
        else:
            if a[i] <= 0:
                count += 1 - a[i]
                memo = 1 - a[i]
        if i + 1 < n:
            a[i + 1] = a[i + 1] + a[i] + memo
            memo = 0
    else:
        return count


print(min(f1(a), f2(b)))

Measured memory_bytes: 15160
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    vi data(N); ll count[N]; F0R(i, N) count[i] = 0;
    F0R(i, N) {
        int X; cin >> X;
        X--;
        data[i] = X;
        count[X]++;
    }

    ll ans = 0;
    F0R(i, N) {
        ans += (count[i] * (count[i] - 1)) / 2;
    }

    F0R(i, N) {
        int X = data[i];
        ll cur = ans; cur -= (count[X] * (count[X] - 1)) / 2;
        cur += (count[X] - 1) * (count[X] - 2) / 2;
        cout << cur << endl;
    }

	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

INF = 1<<32
    
def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [[INF] * ((1<<N)+1) for i in range(M+1)]
    # for i in map(bin, c):
    #     print(i)

    dp[0][0] = 0
    for i in range(M):
        for j in range(1<<N):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][j | c[i]] = min(dp[i+1][j | c[i]], dp[i][j]+a[i])

    # for i in dp:
    #     print(i)
    print(dp[M][(1<<N)-1] if (dp[M][(1<<N)-1]) < INF else -1)


# Generated by 1.1.5 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():
    # Failed to predict input format
    N, M = map(int, input().split())
    a = []
    b = []
    c = []
    for i in range(M):
        ax, bx = map(int, input().split())
        cx = map(int, input().split())
        a.append(ax)
        b.append(bx)
        ct = 0
        for j in cx:
            ct |= (1<<(j-1))
        c.append(ct)
    solve(N, M, a, b, c)

    
    

if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  int i, count;
  cin >> n;
  vector<int> a(n-1), josi(n,0);
  for(i=0; i<n-1; i++)
  {
    cin >> a[i];
  }
  for(i=0; i<n-1; i++)
  {
    josi[a[i]-1]++;
  }
  for(i=0; i<n; i++)
  {
    cout << josi[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4780
package main

import (
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  P := make([]int, N)
  Q := make([]int, N + 1)
  for i := range P {
    fmt.Scan(&P[i])
    Q[i] = 1
  }
  cnt := 1
  for _, p := range P {
    if cnt < Q[p - 1] { cnt = Q[p - 1] }
    Q[p] = Q[p - 1] + 1
  }
  fmt.Println(N - cnt)
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=-INF;
	cin >>n;
	vector<int> hash(n,0);
	vector<vector<int>> pro(n,vector<int>(12,0));
	int bef;
	rep(i,n){
		rep(j,10){
			cin>>bef;
			hash[i]|=((bef)<<j);
		}
	}
	rep(i,n){
		rep(j,11){
			cin>>pro[i][j];
		}
		
	}
	int cnt =0;
	int tmp=0;
	for(int bit =1;bit<(1<<10);bit++){
		cnt=0;
		if(__builtin_popcount(bit)==0){
			continue;
		}
		for(int i=0;i<n;i++){
			tmp=bit & hash[i];

			cnt += pro[i][__builtin_popcount(tmp)];
			
		}
		if(chmax(ans,cnt))
		clog << bitset<10>(bit)<<" "<<cnt<<endl;
	}
	cout<<ans<<endl;
}

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

int main()
{
	int a, b, x;
	cin >> a >> b >> x;
	if(a + b >= x && a <= x) printf("YES\n");
	else printf("NO\n");
}

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

int main() {
	string A,B;
	cin >> A >> B;
	if(A.length()>B.length()){
		cout <<"GREATER";
	}else if(A.length()<B.length()){
		cout<<"LESS";
	}else{
		if(A==B){
			cout << "EQUAL";
		}else if(A>B){
			cout << "GREATER";
		}else{
			cout << "LESS";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,a[100005];
ll ans=0,sum[100005];
int main(){
	cin>>n;
	for(ll i=1;i<=n+1;i++)cin>>a[i];
	for(ll i=n+1;i>=0;i--)sum[i]=sum[i+1]+a[i];
	if(n==0){
		if(a[1]==1)cout<<1;
		else cout<<-1;
		return 0;
	}
	if(n==1){
		if(a[1]>0)return cout<<-1,0;
		if(a[2]>2)return cout<<-1,0;
		return cout<<a[2]+1,0;
	}
	bool flag=0;
	for(ll i=1,x=1,y=0;i<=n;i++){
		ans+=x+y+a[i];
		ll w=x*2+y-a[i+1];
		ll X=min(sum[i+2]-w,1ll*w);
		if(X<0){
			ans=0,flag=1;
			break;
		}
		x=X,y=w-X;
	}
	if(!flag)return cout<<ans+a[n+1],0;
	for(ll i=1,x=0,y=1;i<=n;i++){
		ans+=x+y+a[i];
		ll w=x*2+y-a[i+1];
		ll X=min(sum[i+2]-w,1ll*w);
		if(X<0)return cout<<-1,0;
		x=X,y=w-X;
	}
	cout<<ans+a[n+1];
}


Measured memory_bytes: 5172
#include <iostream>
#include <string>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <bitset>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct dd{
    int d,f;
    dd(){
        d=0;
        f=0;
    }
};
bool data[101][101]={};
void f1(dd*,int,int&,int);

int main()
{
    int N,M,num1,num2;
    dd ddata[101]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>num1;
        cin>>M;
        for(int j=0;j<M;j++){
            cin>>num2;
            data[num1][num2]=true;
        }
    }
    int time=1;
    for(int i=1;i<=N;i++){
        if(!ddata[i].d)f1(ddata,i,time,N);
    }
    for(int i=1;i<=N;i++){
        cout<<i<<' '<<ddata[i].d;
        if(ddata[i].d){
            cout<<' '<<ddata[i].f;
        }
        cout<<endl;
    }
}
void f1(dd* ddata,int num,int& time,int N)
{
    if(!ddata[num].d)ddata[num].d=time++;
    else return;
    data[num][num]=false;
    for(int i=1;i<=N;i++){
        if(data[num][i]){
            data[num][i]=false;
            data[i][num]=false;
            f1(ddata,i,time,N);
        }
    }
    ddata[num].f=time++;
}

Measured memory_bytes: 1172
n = str(input())
list_n = [int(n[0]),int(n[1]),int(n[2])]

for i in range(len(list_n)):
    if list_n[i] == 1:
        list_n[i] = 9
    elif list_n[i] == 9:
        list_n[i] = 1
    else:
        pass

print(''.join(map(str,list_n)))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main()
{
	for(;;){
		int n;
		vector<int>a;
		scanf("%d",&n);
		if(n==0)return 0;

		while(n!=0){
			a.push_back(n%8);
			n/=8;
		}

		for(int i=a.size()-1;i>=0;i--){
			if(a[i]<=3)printf("%d",a[i]);
			if(a[i]==4)printf("%d",a[i]+1);
			if(a[i]>=5)printf("%d",a[i]+2);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1212
unittest
{
	assert( [ "2 5" ].parse.expand.solve == 10 );
	assert( [ "5 10" ].parse.expand.solve == -1 );
	assert( [ "9 9" ].parse.expand.solve == 81 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	if( a <= 9 && b <= 9 ) return a * b;
	else                   return -1;
}


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



int main(){
  vector<uint64_t> L(87, 0);
  L.at(0) = 2;
  L.at(1) = 1;
  int N = 0;
  cin >> N;
  for(int i = 2 ;i < N + 1; i++){
    L.at(i) = L.at(i - 1) + L.at(i - 2);
  }
  
  cout << L.at(N) << endl;
}

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

#define ld long double

using namespace std;

int main()
{
    int n;
    ld x;
    cin >> n;
    ld sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        sum += 1.0 / x;
    }
    cout << fixed << setprecision(10) << 1.0 / sum;
}


Measured memory_bytes: 256
#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;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

const ll MAX = 10000;

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n),sosu(MAX+1,1),vec_sosu,check_sosu(n,1);
  rep(i,n){
    cin >> vec[i];
  }
  sosu[0] = 0;
  sosu[1] = 0;
  REP(i,2,100){
    ll piv = 2;
    while(i * piv <= MAX){
      sosu[i*piv] = 0;
      piv++;
    }
  }
  rep(i,MAX+1){
    if(sosu[i]){
      vec_sosu.push_back(i);
    }
  }
//  cout << endl;
//  rep(i,vec_sosu.size()){
//    cout << vec_sosu[i] << endl;
//  }


  sort(all(vec));

  rep(i,n){
    rep(j,vec_sosu.size()){
      if(vec[i] % vec_sosu[j] == 0){
        if(vec[i] == vec_sosu[j]){
          break;
        }
        check_sosu[i] = 0;
        //cout << vec[i] << " " << vec_sosu[j] << endl;
        break;
      }
    }
  }

  ll ans = 0;
  rep(i,n){
    if(check_sosu[i]){
      ans++;
    }
  }
  cout << ans << endl;

}



Measured memory_bytes: 3252
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[N], d[N];
string ss;

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 0; i <= k; i++){
		if (!d[i]){
			for (int j = 0; j < n; j++){
				if (a[j] + i <= k)
					d[a[j] + i] = 1;
			}
		}
	}
	if (d[k]) cout << "First";
	else cout << "Second";
	return 0;
}












Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
string s;
signed main(){
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size()/2;i++){
		if(s[i]!=s[s.size()-i-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int A,B;
  cin>>A>>B;
  
  int ans=0;
  for(int i=A; i<=B; i++){
   int a=i/10000, b=i%10, c=i/1000%10, d=i/10%10;
   if(a==b && c==d){ans++;} 
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

typedef pair <ll, ll> pll;

const int N = 1e5 + 5;

vector <ll> days[N];

int main() {
  int n, m; cin >> n >> m;
  for(int i = 0; i < n; i++) {
    ll x, y; cin >> x >> y;
    if(x > m) continue;
    days[m - x].push_back(y);
  }
  ll ans = 0;
  priority_queue <ll> pq;
  for(int i = m - 1; i >= 0; i--) {
    while(!days[i].empty()) {
      pq.push(days[i].back());
      days[i].pop_back();
    }
    if(not pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5632
ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))

n,m = ai()

from collections import defaultdict as dd
edge = dd(list)
for _ in range(m):
    a,b,c = ai()
    edge[a-1].append([b-1, -c])

dist = [float('inf')] * n
dist[0] = 0

for i in range(n):
    for cur_v in range(n):
        for v, c in edge[cur_v]:
            if dist[v] > dist[cur_v] + c:
                dist[v] = dist[cur_v] + c
                if i == n-1 and v == n-1:
                    print('inf')
                    exit()
print(-dist[-1])


Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		String n = n();
		if ("ABC".equals(n)) {
			out("ARC");
		} else {
			out("ABC");
		}

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 35672
N,M=map(int,input().split())
H=list(map(int,input().split()))
isGood=[1]*N
for i in range(M):
  a,b=map(int,input().split())
  if not(isGood[a-1] and H[a-1]>H[b-1]):
    isGood[a-1]=0
  if not(isGood[b-1] and H[b-1]>H[a-1]):
    isGood[b-1]=0
print(sum(isGood))

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

using namespace std;
typedef long long ll;
const int N = 3001;
const int inf = 1e9;
int dp[N][N][2];
int a[N], b[N];
int n;

int rec(int i, int t, int take) {
  if(take && t < 0) {
    return -inf;
  }
  if(i == n) {
    return 0;
  }
  if(dp[i][t][take] != -1) return dp[i][t][take];
  int res = -inf;
  res = b[i] + rec(i + 1, t - (take | a[i] <= t) * a[i], take | (a[i] > t));
  if(!take) {
    res = max(res, b[i] + rec(i + 1, t, 1));
  }
  res = max(res, rec(i + 1, t, take));
  return dp[i][t][take] = res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  memset(dp, -1, sizeof dp);
  int t; cin >> n >> t;
  for(int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  cout << rec(0, t - 1, 0) << '\n';
  return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x,y,z, ans = 0;
	cin >>x >>y >>z;
	swap(x, y);
	swap(x, z);
	cout << x <<" "<<y <<" "<<z <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String s = br.readLine();
            String t = br.readLine();
            int ans = n * 2;
            for (int i = 0; i < n; i++) {
                String tmp1 = s.substring(i);
                String tmp2 = t.substring(0, t.length() - i);
                if (tmp1.equals(tmp2)) {
                    ans -= tmp1.length();
                    break;
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}


Measured memory_bytes: 21076