akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  ll max_n=0,min_n=1e10,temp;
  rep(i,n){
  	cin>>temp;
  	max_n=max(max_n,temp);
  	min_n=min(min_n,temp);
  }
  cout<<abs(max_n-min_n)<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    read(k) reads(s)

    int n = sz(s);

    if(n <= k) print(s)

    else 
    {
        fori (i, 0, k-1) cout << s[i];
        cout << "...";
    }

    return 0;
}


Measured memory_bytes: 3640
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def frog(n, k, h):
    d = [float('inf')] * n
    d[0] = 0

    for i in range(1, n):
        d[i] = min(
            d[j] + abs(h[i] - h[j]) for j in range(max(i - k, 0), i)
        )
    return d[n - 1]


print(frog(n, k, h))


Measured memory_bytes: 13980
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcider
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int P = int.Parse(x[0]);
            int Q = int.Parse(x[1]);
            int R = int.Parse(x[2]);

            int[] kyori = { P+Q, Q+R, R+P };
            int min = kyori[0];
            for (int i = 0; i < kyori.Length; i++)
                if (kyori[i] < min)
                {
                    min = kyori[i];
                }
            Console.WriteLine(min);
        }

    }  
}


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

constexpr int M = 1000000000 + 7;

void add(int& a, int b) {
    a += b;
    if(a >= M) a -= M;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    int d;
    cin >> s >> d;
    int n = (int) s.size();
    
    vector<int> dp[2] {vector<int>(d, 0), vector<int>(d, 0)};
    dp[1][0] = 1;
    for(int i = 0; i < n; ++i) {
        int digit = s[i] - '0';
        vector<int> new_dp[2] {vector<int>(d, 0), vector<int>(d, 0)};
        for(int j = 0; j < d; ++j) {
            add(new_dp[1][(j + digit % d) % d], dp[1][j]);
        }
        for(int x = digit - 1; x >= 0; --x) {
            for(int j = 0; j < d; ++j) {
                add(new_dp[0][(j + x % d) % d], dp[1][j]);
            }
        }
        for(int x = 0; x < 10; ++x) {
            for(int j = 0; j < d; ++j) {
                add(new_dp[0][(j + x % d) % d], dp[0][j]);
            }
        }
        swap(dp, new_dp);
    }

    cout << (-1LL + dp[1][0] + dp[0][0] + M) % M << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);
const ll mod = 1000000007;


ll gcd(ll a, ll b){
    a = abs(a), b = abs(b);
    if(b == 0) return a;
    ll aa = a, bb = b;
    if(aa > bb){
        ll temp = aa;
        aa = bb;
        bb = temp;
    }

    while(bb != 0){
        ll temp = bb;
        bb = aa%bb;
        aa = temp;
    }
    return aa;
}

ll modpow(ll base, ll t){
    ll ret = 1;
    if(t == 0) return 1LL;
    rep(i, t){
        ret = (ret * base) % mod;
    }
    return ret;
}

int main(){
    ll n;
    cin >> n;
    map<pair<ll, ll>, pair<ll, ll>> ab;
    ll zero = 0;
    rep(i, n){
        ll a, b, c;
        cin >> a >> b;
        if(a == 0 && b == 0){
            zero++;
            continue;
        }
        ll abg = gcd(a, b);
        a /= abg, b /= abg;
        //cout << abg << endl;
        if(b < 0) a = -a, b = -b;
        if(b == 0 && a < 0) a = -a, b = -b;
        if(a <= 0){
            ll temp = a;
            a = b;
            b = -temp;
            ab[{a,b}].second++;
        }else{
            ab[{a,b}].first++;
        }
    }
    ll ans = 1;
    for(auto i : ab){
        ll tmp = 1;
        tmp += (modpow(2, i.second.first) - 1)%mod;
        tmp += (modpow(2, i.second.second) - 1)%mod;
        //cout << i.second.first << " " << modpow(2, i.second.first) << " " << i.second.second << " " << modpow(2, i.second.second) << endl;
        ans = (ans * tmp)%mod;
    }
    if(ans == 0) ans = mod - 1;
    else ans -= 1;
    if(ans + zero >= mod) ans = ans + zero - mod;
    else ans += zero;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19040
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let (a,b,k):(i64,i64,i64)=(read(),read(),read());
    let mut index:i64 =0;
    for i in (1..101).rev(){
        if (a%i==0) & (b%i==0) {
            index+=1;
        }
        if index==k{
            println!("{}",i);
            return;
        }
    }
}


Measured memory_bytes: 2152
/**
 *    created by : PawPaw       
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  

using namespace __gnu_pbds;  
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,  
        tree_order_statistics_node_update>  
        ordered_set;  

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LL long long
#define PHI acos(-1)
#define EPS 0.000000001
#define N 1000001
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define FbO find_by_order
#define OoK order_of_key

int solve(){
  LL n, f5 = 5, ans = 0;
  cin >> n;
  if(n % 2) cout << "0\n";
  else {
    while(f5*2 <= n){
      ans += (n/(f5*2));
      f5 *= 5;
    }
    cout << ans << '\n';
  }
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100005],z=0,x=0,y=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	if(a[i]%4==0) x++;
    	if(a[i]%2==0&&a[i]%4!=0) y++;
    	if(a[i]%2!=0) z++;
	}
	if(z>x+1){cout<<"No";return 0;}
	if(y>0&&z>x) cout<<"No";	
	else cout<<"Yes";
    return 0;
} 

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  VI a(n), b(n), c(n);
  rep(i, n) cin >> a[i] >> b[i];
  iota(all(c), 0);
  sort(all(c), [=](int x, int y){return a[x] < a[y];});
  VVI dp(n+1, VI(t+1, 0));
  rep(i, n) rep(j, t) {
    dp[i + 1][j] = j < a[c[i]] ? dp[i][j] : max(dp[i][j - a[c[i]]] + b[c[i]], dp[i][j]);
  }
  int ans = 0;
  rep(i, n+1) {
    for(int j = i; j < n; ++j) {
      ans = max(ans, dp[i][t-1] + b[c[j]]);
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 35572
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto T = RD!string;

	writeln(T ~ S);
	stdout.flush;
	debug readln;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N);

    for (int i=0; i<N; i++){
        cin >> a[i];
    }
    int ans = 0;
    int c = 0;
    for (int i=0; i<N; i++){
        if (a[i] == c+1){
            c++;
        } else{
            ans++;
        }
    }
    if (ans == N){
        cout << -1 << endl;
    } else{
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

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

        int n = Integer.parseInt(br.readLine());

        Deque<Integer> list = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            String sp = br.readLine();
            if (sp.startsWith("insert")) {
                list.addFirst(Integer.parseInt(sp.substring(sp.indexOf(" ") + 1)));
            } else if (sp.equals("deleteFirst")) {
                list.removeFirst();
            } else if (sp.equals("deleteLast")) {
                list.removeLast();
            } else {
                list.remove(Integer.parseInt(sp.substring(sp.indexOf(" ") + 1)));
            }
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        StringBuilder ans = new StringBuilder();
        ans.append(list.poll());
        for (Integer s : list) {
            ans.append(" ");
            ans.append(s);
        }
        bw.write(ans.toString());
        bw.newLine();
        bw.close();
        br.close();
    }
}



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

int main(void){
 int a,b,c,d;
 cin>>a>>b>>c>>d;
 if(a+b>c+d){
     cout<<"Left"<<endl;
 }else if(a+b<c+d){
     cout<<"Right"<<endl;
 }else{
     cout<<"Balanced"<<endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXIM 1000003

ll mod = 1e9 + 7;


void solve(){ 
    ll n;
    cin >> n;
    ll c = 0;
    bool found = false;
    rep(i,0,n){
        ll a,b;
        cin >> a >> b;
        if(a == b) c++;
        else if(a != b) c=0;
        if(c == 3) found = true;
    }
    if(found) cout << "Yes" << br;
    else cout << "No" << br;
}
	

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 3644
import sys
from operator import itemgetter
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    txy = []
    for x, y in XY:
        t = math.atan2(y, x)
        txy.append([t, x, y])

    txy.sort()

    ans = 0
    for i in range(N):
        tmpx = 0
        tmpy = 0
        for j in range(N):
            tmpx += txy[(i + j) % N][1]
            tmpy += txy[(i + j) % N][2]
            ans = max(ans, math.sqrt(tmpx ** 2 + tmpy ** 2))


    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  vector<int> time(5);
  for (int i=0 ; i<5 ; i++)
    cin >> time.at(i);
  
  int n;
  vector<int> ten(5);
  for (int i=0 ; i<5 ; i++){
    n = time.at(i)/10;
    n *= 10;
    if (time.at(i)%10 != 0)
      n += 10;
    ten.at(i) = n;
  }
  
  int mini = ten.at(0)-time.at(0), min = 0;
  for (int i=1 ; i<5 ; i++){
    if (ten.at(i)-time.at(i) > mini){
      mini = ten.at(i)-time.at(i);
      min = i;
    }
  }
  
  int ans = 0;
  for (int i=0 ; i<5 ; i++){
    if (i == min){
      ans += time.at(i);
      continue;
    }
    ans += ten.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[1<<20];
llint b[1<<20];


void zeta_transform(llint a[], llint n)
{
	int S = 1<<n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < S; j++){
			if(j&(1<<i)) a[j] += a[j^(1<<i)];
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	int N = 1<<n;
	for(int i = 0; i < N; i++) cin >> a[i];
	
	int ans = 0;
	for(int i = 0; i < N; i++){
		if(a[i] == 0) continue;
		bool flag = true;
		for(int j = 0; j < n; j++){
			if((i & (1<<j)) == 0) continue;
			if(a[i^(1<<j)] == 1){
				flag = false;
				break;
			}
		}
		if(flag) b[i] = true, ans++;
	}
	
	
	//for(int i = 0; i < N; i++) cout << b[i] << " "; cout << endl;
	zeta_transform(b, n);
	//for(int i = 0; i < N; i++) cout << b[i] << " "; cout << endl;
	
	for(int i = 0; i < N; i++){
		if(a[i] && !b[i] || !a[i] && b[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 19600
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c):
  return c-a-b >= 0 and pow(c-a-b,2) > 4*a*b



def main():
  a,b,c = map(int,input().split())
  print("Yes" if solve(a,b,c) else "No")
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9084
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy

def main():
    n, *a = map(int, read().split())
    if n == 1:
        if a[0] % 2 == 1:
            print(1)
        else:
            print(0)
        sys.exit()
    r = 0
    for i1 in range(0,n,2):
        r += a[i1] % 2 == 1
    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9216
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

X = INT()
a = 100
count = 0
while(a < X):
    a += a//100
    count += 1

print(count)

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

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

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


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

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 



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

int N, Q; string S;
cin >> N >> S >> Q;

vector<set<int>> pos(26, set<int>({1<<30}));
rep(i, 0, N) {
    pos[S[i] - 'a'].insert(i+1);
}

while(Q--){
    int q; cin >> q;
    if (q == 1){
        int i; char c; cin >> i >> c;
        pos[S[i-1] - 'a'].erase(i);
        pos[c - 'a'].insert(i);
        S[i-1] = c;
    }
    else {
        int l, r; cin >> l >> r;
        int c = 0;
        for(set<int> &p: pos) if (!p.empty())
            if (*p.lower_bound(l) < *p.lower_bound(r+1)) ++c;

        cout << c << "\n";
    }
}

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double t = h * 30 + m * 0.5;
  double w = m * 6;

  double at = min(abs(t - w), abs(360 - (t - w)));

  // cout << a << ' ' << b << ' ' << t << ' ' << w << ' ' << at << '\n';
  // cout << cos(at * M_PI / 180) << '\n';

  cout << Fixed(10) << sqrtl(a * a + b * b - 2 * a * b * cos(at * M_PI / 180))
       << '\n';
  return 0;
}
//困った時の神頼み！！

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

 
int main(){
 int N;
  string s,t;
  cin>>N>>s>>t;
  string ans="";
  for(int i=0;i<N;i++){
    ans+=s[i];
    ans+=t[i];
}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

bool c[10][10][10];
ll b[10][10];

int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll a[10];
    string t;
    rep(i,0,9){
        a[i]=-1;
        rep(j,0,n-1){
            t=s[j];
            if(stoll(t)==i){
                a[i]=j;
                break;
            }
        }
        //cout<<a[i]<<' ';
    }
    //cout<<endl;
    rep(i,0,9){
        if(a[i]!=-1){
            rep(j,a[i]+1,n-1){
                t=s[j];
                if(b[i][stoll(t)]==0){
                    b[i][stoll(t)]=j;
                }
            }
            
        }
        
    }
    /*
    rep(i,0,9){
        cout<<b[0][i]<<' ';
    }
    cout<<endl;
    rep(i,0,9){
        cout<<b[2][i]<<' ';
    }
    cout<<endl;*/
    
    rep(i,0,9){
        rep(j,0,9){
            if(b[i][j]!=0){
                rep(k,b[i][j]+1,n-1){
                    t=s[k];
                    c[i][j][stoll(t)]=1;
                }
            }
        }
    }
    ll ans=0;
    rep(i,0,9){
        rep(j,0,9){
            rep(k,0,9){
                if(c[i][j][k]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int X, Y;
  cin >> X >> Y;
  string ans="No";
  
  int kame;
  if(Y % 2 == 0){
    kame = Y/2 -X;
    if(0 <= kame && kame <= 100){
      if(0 <= X - kame && X - kame <= 100){
        ans = "Yes";
      }
    }
  }
  
  cout << ans << endl;

}

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

int x,y,z,ar[200005];

int main() {
	cin >> x;
	for (int a = 0; a < x-1; a++) {
		cin >> z;
		ar[z]++;
	}
	for (int a = 1; a <= x; a++) {
		cout << ar[a] << "\n";
	}
}

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

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%MOD;
        a=a*a%MOD;
        x>>=1;
    }
    return res;
}
string s;
int g(int i){
    if(i<0) return 0;
    if(i==0) return 1;
    if(i==1&&s[1]==s[0]) return 1;

}
int main(){
    int n;cin>>n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++) cin>>x[i]>>y[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)if(i!=j){
            int p=x[i]-x[j],q=y[i]-y[j];
            int c=0;
            for(int k=0;k<n;k++){
                for(int h=0;h<n;h++)if(k!=h){
                    if(x[k]-x[h]==p&&y[k]-y[h]==q) c++;
                }
            }
            ans=max(ans,c);
        }
    }
    ans=1+(n-1)-ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,q;
int a[2007],ans=2e9,b[2007];
vector <int> sv;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		priority_queue <int> pr;
		int cnt=0,in=0,ok=1;
		sv.clear();
		for(int j=1;j<=n;j++){
			if(a[j]<a[i]) b[j]=-1;
			else b[j]=a[j];
		}
		for(int j=1;j<=n;j++){
			if(b[j]!=-1){
				pr.push(-b[j]);
				if(j==i) in=1;
				cnt++;
			}
			if(b[j]==-1 || j==n){
				if(in && cnt<k){
					ok=0;
					break;
				}
				while(cnt>=k){
					cnt--;
					sv.push_back(-pr.top());
					pr.pop();
				}
				while(!pr.empty()) pr.pop();
				in=0, cnt=0;
			}
		}
		if(!ok || (int)sv.size()<q) continue;
		sort(sv.begin(),sv.end());
		ans=min(ans,sv[q-1]-a[i]);
	}
	cout<<ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <bits/stdc++.h>
using namespace std;


std::vector<int> ki(int n, int q, int a[], int b[], int p[], int x[]) {
  map<int, set<int>> tree; 
  for(int i =0;i<n-1;i++) {
    tree[a[i]].insert(b[i]);
    tree[b[i]].insert(a[i]);
  }
  /*
  for(auto t = tree.begin(); t != tree.end(); t++) {
   cout << t->first << " -> ";
   for(auto m = t->second.begin(); m != t->second.end();m++) {
     cout << (*m) << " ";
   }
   cout << endl;
  }
  */
  map<int, int> points; 
  for(int i=0;i<q;i++) {
    points[p[i]] += x[i];
  }
  queue<int> que;
  que.push(1);
  vector<int> ans(n);
  while(!que.empty()) {
    int parent = que.front();
    que.pop();
    ans[parent-1] += points[parent];

    set<int> nodes = tree[parent];
    for(auto node = nodes.begin();node!=nodes.end(); node++) {
      tree[*node].erase(parent);
      que.push(*node);
      ans[(*node) - 1] = ans[parent-1];
    }
  }

  return ans;
}

int main() {
  int n, q;
  cin >> n >> q;
  int a[n-1];
  int b[n-1];
  int p[q];
  int x[q];
  for(int i=1;i<=n-1;i++) {
    cin >> a[i-1] >> b[i-1];
  }
  for(int i=0;i<q;i++) {
    cin >> p[i] >> x[i];
  }
  vector<int> ans = ki(n, q, a, b, p, x);
  int size = (int) ans.size();
  for(int i=0;i<size;i++) {
    cout << ans[i];

    if(i != size - 1) {
      cout << " ";
    } 
  }
}

Measured memory_bytes: 64144
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless, when, forM_)
import Data.List (find)

import Data.Vector.Unboxed (Vector, (!))
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve tbl n
    main
  where sz = 10000
        tbl = V.create $ do
          v <- VM.replicate (sz+1) True
          VM.write v 1 False
          forM_ [2 .. sz] $ \i -> do
            p <- VM.read v i
            when p $ do
              forM_ [i*i, i*(i+1) .. sz] $ \j -> do
                VM.write v j False
          return v

solve :: Vector Bool -> Int -> IO ()
solve tbl n = putStrLn . maybe "" (\x -> show (x-2) ++ " " ++ show x) . find f $ [n, n-1 .. 5]
  where f x = tbl ! x && tbl ! (x-2)



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

typedef long long int LLI;

void solve()
{
    LLI n;
    cin>>n;
    int ar[n+1];
    set<LLI>st;
    map<LLI,LLI>mp;
    for(LLI i=1;i<=n;++i){
        cin>>ar[i];
        mp[ar[i]]++;
        st.insert(ar[i]);
    }
    LLI sum=0;
    for(auto e:st) sum+=(mp[e]*(mp[e]-1))/2;
    for(LLI i=1;i<=n;++i){
        LLI cnt=mp[ar[i]];
        sum-=(cnt*(cnt-1))/2;
        sum+=((cnt-1)*(cnt-2))/2;
        cout<<sum<<"\n";
        sum-=((cnt-1)*(cnt-2))/2;
        sum+=(cnt*(cnt-1))/2;
    }
    return;
}

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

Measured memory_bytes: 17024
n=gets.chomp.split("").map(&:to_s)
s={}
s["a"]=n.count("a")
s["b"]=n.count("b")
s["c"]=n.count("c")

v=s.values
min=v.min
s["a"]=s["a"]-min
s["b"]=s["b"]-min
s["c"]=s["c"]-min

#p s
if s["a"]<2 && s["b"]<2 && s["c"]<2
    puts "YES"
else
    puts "NO"
end

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }

    vector<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        ans[a[i]] = i + 1;
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << (i + 1 != n ? " " : "\n");
    }
    

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define LL long long 
#define N 1000005
using namespace std;
LL int n,m,ar[N],k[N],a,b,sum;
int main()
{
	scanf("%lld %lld",&n,&m);
	for(int i=1;i<=n;i++)
		ar[i]=1;
	k[1]=1;	
	
	for(int i=1;i<=m;i++)
	{
		scanf("%lld %lld",&a,&b);
		ar[a]--;
		ar[b]++;
		if(k[a])
			k[b]++;
		if(ar[a]==0)
			k[a]=0;
	}
	for(int i=1;i<=n;i++)
		if(k[i] && ar[i])
			sum++;
	printf("%lld",sum);		
}


Measured memory_bytes: 5120
#include <stdio.h>
int main(void){
    // Your code here!
    int H,W,i;
    scanf("%d%d",&H,&W);
    char s[W+1];
    for(i=0;i<W+2;i++) printf("#");
    printf("\n");
    for(i=0;i<H;i++){
        scanf("%s",s);
        printf("#%s#\n",s);
    }
    for(i=0;i<W+2;i++) printf("#");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#define il inline
#define rgi register int
#define sp putchar(32)
#define el putchar(10)
#define is_digit(o4) (o4>47&&o4<58)
using namespace std;
il int ri()
{
	register int o1=0;
	register char o3=getchar();
	while(!is_digit(o3))
		o3=getchar();
	while(is_digit(o3))
		o1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();
	return o1;
}
il void wi(rgi o1)
{
	rgi o2=o1/10;
	if(o2)
		wi(o2);
	putchar((o1-(o2<<1)-(o2<<3))^48);
}
int a,b;
signed main()
{
	a=ri(),b=ri();
	wi(max(a-(b<<1),0));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
string str;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> str;
	for (int i = 0; i < str.length(); i++){
		if (str[i] == '?'){
			str[i] = 'D';
		}
	}
	cout << str << "\n";

}

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

long long n;

int main(){
	cin >> n;

	long long sum=0;
	long long tmp;

	tmp=n;

	while(tmp>0){
		sum+=tmp%10;
		tmp/=10;
	}

	if(n%sum == 0)	cout << "Yes\n";
	else	cout << "No\n";

	return 0;
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  string x,y;
  cin >> x;
  y = x;
  reverse(x.begin(), x.end());
  if(x == y){
    cout << "Yes" << endl;
  } else { 
    cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int n;cin>>n;
  	int s=0;
  	int m=n;
  	for(int i=0;i<10;i++){
    	s+=m%10;
      	m/=10;
    }
  
  	if((n%s)==0){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
const int MAXN=110;
const int N=400;
int f[MAXN][MAXN][N*2+10],w[MAXN],v[MAXN];
int main()
{
	int n,W;
	scanf("%d%d",&n,&W);
/*	for (int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	memset(f,-1,sizeof(f));
	f[0][0][0]=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=3*j;k++)
			{
				if (f[i][j][k]==-1) continue;
				f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
				f[i+1][j+1][k+w[i+1]-w[1]]=max(f[i+1][j+1][k+w[i+1]-w[1]],f[i][j][k]+v[i+1]);
			}*/
	for (int i=0;i<n;i++)
		scanf("%d%d",&w[i],&v[i]);

	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=3*j;k++)
			{
				f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]);
				f[i+1][j+1][k+w[i]-w[0]]=max(f[i+1][j+1][k+w[i]-w[0]],f[i][j][k]+v[i]);
			}
	int ans=0;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=3*i;j++)
		{
			ll k=(ll)i*w[0]+j;
			if (k<=W)
				ans=max(ans,f[n][i][j]);	
		}
	cout<<ans;
	return 0;
}


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

typedef long long ll;
const int MAXN = 2e5 + 10;

int n;
int A[MAXN];
ll psum[MAXN];

ll calc(int i1, int i2, int i3) {
	ll sums[4] = { psum[i1], psum[i2] - psum[i1], psum[i3] - psum[i2], psum[n] - psum[i3] };
	sort(sums, sums + 4);
	return sums[3] - sums[0];
}


int main() {

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

	for (int i = 1; i <= n; i++) {
		psum[i] = psum[i - 1] + A[i];
	}

	ll ans = calc(1, 2, 3);

	for (int i2 = 2; i2 <= n - 1; i2++) {
		// i가 i2

		int L = 1, R = i2 - 1;
		while (L < R) {
			int M = (L + R) / 2;
			if (psum[i2] - psum[M] >= psum[M]) {
				L = M + 1;
			}
			else R = M;
		}
		if (L == i2) L--;

		vector<int> i1s;
		i1s.push_back(L);
		if (L - 1 >= 1)
			i1s.push_back(L - 1);


		L = i2 + 1, R = n;
		while (L < R) {
			int M = (L + R) / 2;
			if (psum[n] - psum[M] >= psum[M]-psum[i2]) {
				L = M + 1;
			}
			else R = M;
		}
		if (L == n) L--;

		vector<int> i3s;
		i3s.push_back(L);
		if (L - 1 >= i2 + 1)
			i3s.push_back(L - 1);

		// [1, i1], [i1+1, i2], [i2+1, i3], [i3+1, n]
		for (auto i1 : i1s) {
			for (auto i3 : i3s) {
				if (i1 + 1 <= i2 && i2 + 1 <= i3 && i3 + 1 <= n) {
					ans = min(ans, calc(i1, i2, i3));
				}
			}
		}
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 2560
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


count = 0

for x in range(N + 1):
    num_len = len(make_divisors(x))
    if x % 2 == 1 and num_len == 8:
        count += 1
print(count)


Measured memory_bytes: 38640
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines

#n = int(input())
from fractions import gcd

n,x,d = [int(i) for i in readline().split()]

g = gcd(x,d) 

if d < 0:
    x = x+(n-1)*d
    d = -d

if d == 0:
    if x == 0: print(1)
    else: print(n+1)
    exit()

kind = abs(d//g) #あまりは kind = d//g 種類 

ans = 0



for i in range(min(kind,n+2)):
    res = []
    for j in range(i,n+1,kind):
        res.append([j*x+j*(j-1)//2*d, j*x+(j*n-j*(j+1)//2)*d])
    
    if not res: continue
    
    #print(res)
    res.sort()
    
    q = [res[0][:]]

    for e,f in res:
        while q:
            a,b = q[-1]
            if b < e: break
            else:
                q.pop()
                e,f = a,max(b,f)
        
        q.append([e,f])
    
    #print(q)
    for a,b in q:
        ans += (b-a)//d + 1


print(ans)









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

int main() {
	string str1, str2, str3;
	int i,count_up = 0;
	getline(cin, str1);
	for (i = 0; i < str1.length(); i++) { str1[i] = tolower(str1[i]); }
	while (1) {
		while (1) {
			cin >> str2;
			if (str2 == "END_OF_TEXT")break;
			for (i = 0; i < str2.length(); i++) { str2[i] = tolower(str2[i]); }
			if (str1 == str2)count_up++;
			if (str2 == "")break;
		}
		if (str2 == "END_OF_TEXT")break;
	}
	cout << count_up << endl;
	return 0;
}


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

int main()
{
  const long long int price[] = {600LL, 800LL, 1000LL, 1200LL, 1400LL, 1600LL};

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

    vector<long long int> item(6, 0);
    while (n--) {
      int x, y, h, w;
      cin >> x >> y >> h >> w;

      int s = x+y+h;
      if (s <= 60 && w <= 2)
	++item[0];
      else if (s <= 80 && w <= 5)
	++item[1];
      else if (s <= 100 && w <= 10)
	++item[2];
      else if (s <= 120 && w <= 15)
	++item[3];
      else if (s <= 140 && w <= 20)
	++item[4];
      else if (s <= 160 && w <= 25)
	++item[5];
    }

    long long int ans = 0;
    for (unsigned int i = 0; i < item.size(); ++i)
      ans += item[i] * price[i];

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define int long long int
const int mod = 1000000007;
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

vector<int>adj[200005];
bool vis[200005];


int cnt;

void dfs(int u){
    cnt++;
    vis[u] = true;
    for(auto i : adj[u]){
        if(!vis[i]){
            dfs(i);
        }
    }
    return;
}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m;
    cin>>n>>m;
    for(int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    vector<int>v;
    for(int i=1; i<=n; i++){
        if(!vis[i]){
            cnt = 0;
            dfs(i);
            v.push_back(cnt);
        }
    }
    int ans = 0;
    for(int i=0; i<v.size(); i++){
        ans = max(ans, v[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 20972
#include<iostream>
#include<cmath>
int main(){
  long long int N,P;
  std::cin >> N >> P;
  long long int i=3,k,result=1;

  if(N==1){
    std::cout << P;
    return 0;
  }

  if(P>=std::pow(2,N)){
    k=std::pow(2,N);
    while(P%k==0){
      result = result * 2;
      P= P/std::pow(2,N);
    }
  }


  while(P>=std::pow(i,N)){
    k=std::pow(i,N);
    while(P%k==0){
      result = result * i;
      P= P/std::pow(i,N);
    }
    i+=2;
  }

  std::cout << result;
  return 0;
}


Measured memory_bytes: 256
local N=io.read("n")
local M=io.read("n")
local X=io.read("n")
local A={}
local left=0
for i=1,M do
  A[i]=io.read("n")
  if A[i]<X then
    left=left+1
  end
end
print(math.min(left,M-left))

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

int main() {
  int a, b;
  cin >> a >> b;

  if(a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else if (a == b) {
    cout << "a == b" << endl;
  }

  return 0;
}


Measured memory_bytes: 3100
using System;
using System.Linq;

class Problem {
    public static void Main() {
        var str = "";
        while ((str = Console.ReadLine()) != "0 0") {
            var data = str.Split().Select(int.Parse).ToArray();
            var tf = "";
            var md = "";
            for (var i = 0; i < data[1]; i++) {
                tf += "#";
                md += i == 0 || i == data[1] - 1 ? "#" : ".";
            }
            Console.WriteLine(tf);
            for (var i = 1; i < data[0] - 1; i++) Console.WriteLine(md);
            Console.WriteLine(tf);
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 9268
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
using namespace std;

int x[100],y[100],a[100];

int main(){
	
	int w, h, n;
	cin>>w>>h>>n;
	int xn=0,xx=w,yn=0,yx=h;

	for(int i=0;i<n;i++){
		cin >> x[i]>>y[i]>>a[i];
	}

	for(int i=0;i<n;i++){
		if(a[i]==1)
			xn = max(xn,x[i]);
		else if(a[i]==2)
			xx = min(xx,x[i]);
		else if(a[i]==3)
			yn = max(yn,y[i]);
		else if(a[i]==4)
			yx = min(yx,y[i]);	
	}
	
	if (xn>=xx || yn>=yx)
		cout << 0<<endl;
	else	
		cout << (xx-xn)*(yx-yn) <<endl;
	
	return 0;
};

Measured memory_bytes: 256
n = input()
line = input()
d_list = line.split(" ")
d_list = [int(d) for d in d_list]

ans = 0

for i in range(len(d_list)-1):
    for j in range(i+1, len(d_list)):
        ans = ans + (d_list[i] * d_list[j])
print(ans)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	static long mod=1000000007;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int former=0;
		int latter=0;
		int tmp=0;
		Map<Integer, Integer> m=new HashMap<Integer, Integer>();
		for (int i=0;i<n+1;i++) {
			tmp=sc.nextInt(); {
				if(m.containsKey(tmp)) {
					former=m.get(tmp);
					latter=i;
				}
				else {
					m.put(tmp,i);
				}
			}
		}
		
		int diff=latter-former;
		
		long comb1=n+1;
		long comb2=1;
		
		for (int i=1;i<=n+1;i++) {
			System.out.println((comb1+mod-comb2)%mod);
			comb1=div(comb1*(n+1-i),(i+1));
			comb2=div(comb2*(n-diff-i+1),i);
		}

	}
	private static long div(long a, long b) {
		return (a%mod)*pow(b,mod-2)%mod;
	}
	private static long pow(long a, long b) {
		if (b==0) {
			return 1;
		} else if (b==1) {
			return a%mod;
		} else if(b%2==0) {
			long tmp=pow(a,b/2);
			return tmp*tmp%mod;
		} else {
			return pow(a,b-1)*a%mod;
		}		
	}
}


Measured memory_bytes: 66732
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GREY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];


int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v]) return v;
	}
	return -1;
}


void dfs_visit(int r) {
	for (int i = 0; i < n; i++) nt[i] = 0;

	stack<int> S;
	S.push(r);
	color[r] = GREY;
	d[r] = ++tt;

	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == WHITE) {
				color[v] = GREY;
				d[v] = ++tt;
				S.push(v);
			}
		}
		else {
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}


void dfs() {
	for (int i = 0; i < n; i++) {
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 0;

	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE) dfs_visit(u);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}


int main() {
	int u, k, v;

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

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	dfs();

	return 0;
}

Measured memory_bytes: 3132
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
    	
        Scanner scan = new Scanner(System.in);
        
        Dice dice = new Dice();
        
        for(int i = 0 ; i < 6 ; i ++){
        	
            dice.dice1[i]=scan.nextInt();
            
        }
        
        for(int i = 0 ; i < 6 ; i ++){
        	
            dice.dice2[i]=scan.nextInt();
            
        }
        
        dice.check();
    }
}
class Dice{
	
    public int[] dice1 = new int[6];
    public int[] dice2 = new int[6];
    private int kari = 0;
    
    void check(){
    	
        for(int i = 0 ; i <= 3 ; i ++){
            if(checkAll()){
                break;
            }
            
            N();
            
            for(int j = 0 ; j <= 3 ; j ++){
                if(checkAll()){
                    break;
                }
                
                R();
                
            }
        }
        
        for(int j = 0 ; j <= 3 ; j ++){
            if(checkAll()){
                break;
            }
            
            W();
            
            for(int i = 0 ; i <= 3 ; i ++){
                if(checkAll()){
                    break;
                }
                
                R();
                
            }
        }
        
        if(Arrays.equals(dice1,dice2)){//Arraysクラスequalsで配列比較
            System.out.println("Yes");
        }
        else
            System.out.println("No");
    }
    
    
    boolean checkAll(){
        if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] &&
        		dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
            return true;
        }
        return false;
    }
    
    
    
    void N(){
    	kari=dice1[0];
    	dice1[0]=dice1[1];
    	dice1[1]=dice1[5];
    	dice1[5]=dice1[4];
    	dice1[4]=kari;
    }
    
    void S(){
    	kari=dice1[0];
    	dice1[0]=dice1[4];
    	dice1[4]=dice1[5];
    	dice1[5]=dice1[1];
    	dice1[1]=kari;
    }
    
    void E(){
    	kari=dice1[0];
    	dice1[0]=dice1[3];
    	dice1[3]=dice1[5];
    	dice1[5]=dice1[2];
    	dice1[2]=kari;
    }
    
    void W(){
    	kari=dice1[0];
    	dice1[0]=dice1[2];
    	dice1[2]=dice1[5];
    	dice1[5]=dice1[3];
    	dice1[3]=kari;
    }
    
    void R(){//0と5は動かさずロールさせる
    	kari=dice1[1];
    	dice1[1]=dice1[2];
    	dice1[2]=dice1[4];
    	dice1[4]=dice1[3];
    	dice1[3]=kari;
    }
}

Measured memory_bytes: 26356