akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define mod 1000000007
using namespace std;
int a[1005][1005],dp[1005][1005];
int main(int argc, char** argv) {
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin >> c;
			if(c=='.') a[i][j]=1;
		}
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(i==1&&j==1) continue;
			if(!a[i][j]) continue;
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 8064
N, Q = list(map(int, input().split()))
S = input()

# Sのi番目までに出現するACの数を格納するリストです
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(t[r-1] - t[l-1])

Measured memory_bytes: 9540
H,W = map(int,input().split())
ds = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j])
ans = 0
for row in A:
    for a in row:
        if a < 0: continue
        ans += ds[a][1]
print(ans)

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  int a ; int b; int sum=0;
	cin>>a>>b;
	vector<int>food(b,1);
	
	for(int i = 0 ; i< a ; i++){
		int z;cin>>z; vector<int>ifood(b,0);
		for(int j = 0 ; j<z ; j++ ){
			int u ; cin>>u;
			ifood[u-1]=1;
		}
		for(int j = 0 ; j<b ; j++){
			if(ifood[j]==0){
				food[j]=0;
			}
		}
	}

	for(int i = 0 ; i< b ; i++){
		if(food[i]==1){
			sum++;
		}
	}
	cout<<sum;
	
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()



D = defaultdict(int)
for i in range(n):
    a = A[i]
    Di = defaultdict(int)
    for j in range(2, int(a ** 0.5) + 1):
        while a % j == 0:
            a //= j
            Di[j] += 1
        if a == 0:
            break
    if a:
        Di[a] += 1
    for k in Di:
        D[k] = max(D[k], Di[k])

ret = 1
for ki in D:
    ret = ret * pow(ki, D[ki], mod)
    ret %= mod

ans = 0
for a in A:
    ans += ret * pow(a, mod - 2, mod)
    ans %= mod

print(ans)






Measured memory_bytes: 84700
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [list(li()) for _ in range(n)]
ab.sort(key=lambda x: x[0] + x[1], reverse=True)

first = 0
second = 0

for i, (ai, bi) in enumerate(ab):
    if i%2 == 0:
        first += ai
    else:
        second += bi

print(first - second)

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


int main()
{
        int k;
        cin>>k;
        string s;
        cin>>s;
        deque<int> w;
        deque<int> r;
        int ats=0;
        for(int i=0;i<s.length() ;i++){
            if(s[i]=='W')w.push_back(i);
            else r.push_back(i);
        }
        if(r.size()!=0){reverse(r.begin(), r.end());
        //cout<<w[0]<<" "<<w[1]<<endl;
        //cout<<r[0]<<" "<<r[1]<<endl;

        while(w.front()<r.front()&&(w.size()!=0&&r.size()!=0)){
            //cout<<w.front()<<" "<<r.front();
            w.pop_front();
            r.pop_front();
            ats++;
            //cout<<"tete"<<endl;
        }
        }
        cout<<ats<<endl;

}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

bool DEBUG = false;

int main(){
    string s;
    bool bad = false;
    cin >>s;
    for(int i=0; i<3; i++){
        if(s[i] == s[i+1]){
            bad = true;
            break;
        }
    }
    
    if(bad) cout <<"Bad";
    else cout <<"Good";
    cout <<endl;
}

Measured memory_bytes: 256
#define NDEBUG
#include<deque>
#include<functional>
#include<utility>
#include<cstddef>
#include<cassert>

template<typename T, class Compare = std::less<T>>
class SlidingMinimum{
public:
	using value_compare = Compare;
	using value_type = T;
private:
	using size_type = std::size_t;
	using container_type = std::deque<std::pair<const value_type, size_type>>;
	container_type c;
	value_compare comp;
public:
	SlidingMinimum(const value_compare &x = value_compare()) :comp(x){}
	const value_type &top()const{
		assert(!c.empty());
		return c.front().first;
	}
	const size_type top_index()const{
		assert(!c.empty());
		return c.front().second - 1;
	}
	void push(const value_type &x){
		size_type s = 1;
		while (!c.empty() && comp(x, c.back().first)){
			s += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<const value_type, size_type>(x, s));
	}
	void push(value_type &&x){
		size_type s = 1;
		while (!c.empty() && comp(x, c.back().first)){
			s += c.back().second;
			c.pop_back();
		}
		c.push_back(std::pair<const value_type, size_type>(std::move(x), s));
	}
	void pop(){
		assert(!c.empty());
		if (!(--c.front().second))
			c.pop_front();
	}
	void clear(){
		c.clear();
	}
};


#include<cstdio>
#include<utility>

int main(){
	using uint = unsigned int;
	uint n, l;
	scanf("%u%u", &n, &l);
	SlidingMinimum<uint> S;
	uint a;
	n -= l;
	while (l--){
		scanf("%u", &a);
		S.push(a);
	}
	printf("%u", S.top());
	while (n--){
		S.pop();
		scanf("%u", &a);
		S.push(a);
		printf(" %u", S.top());
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL N;
	
	void Solve() {
		cin >> N;
		deque<UL> A1, A2;
		rep(i, N) {
			UL a; cin >> a;
			if (i % 2 == 1) A1.push_back(a);
			else A2.push_back(a);
		}
		sort(A1.begin(), A1.end());
		sort(A2.begin(), A2.end());
		A1.push_back(1000000001);
		A2.push_back(1000000001);
		UL Movs = 0;
		rep(i, N) {
			deque<UL> *posi, *neg;
			if (i % 2 == 1) { posi = &A1; neg = &A2; }
			else { posi = &A2; neg = &A1; }
			if (posi->front() <= neg->front()) {
				posi->pop_front();
			}
			else {
				neg->pop_front();
				Movs++;
			}
		}
		cout << Movs / 2 << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 640
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: Vec<u32> = (0..2).map(|_| read()).collect();
    println!("{}", if a[0] * a[1] % 2 == 0 {"Even"} else{"Odd"});
}


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

int main() {
    int n,k; 
    cin >> n >> k;
    vector<int> v[n+1];
    int flag[n+1] = {};
    rep(i,n-1){
        int a,b; cin >> a >> b;
        v[a].push_back(b); v[b].push_back(a);
    }

    ll ans;
    queue<int> que;
    que.push(1);
    while(que.size()>0){
        int x = que.front();
        que.pop();
        if(x==1){
            ans = k;
            flag[1] = 1;
            int count = 0;
            rep(i,v[x].size()){
                if(flag[v[x][i]]==0){
                    count++;
                    que.push(v[x][i]);
                    flag[v[x][i]] = 1;
                }
            }
            rep(i,count){
                ans *= k-1-i;
                if(k-1-i<0){
                    cout << '0' << endl;
                    return 0;
                }
                ans %= MOD;
            }
        }else{
            int count = 0;
            rep(i,v[x].size()){
                if(flag[v[x][i]]==0){
                    count++;
                    que.push(v[x][i]);
                    flag[v[x][i]] = 1;
                }
            }
            rep(i,count){
                ans *= k-2-i;
                if(k-2-i<0){
                    cout << '0' << endl;
                    return 0;
                }
                ans %= MOD;
            }
        }
    }

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


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


const string YES = "Yes";
const string NO = "No";
void solve(ll N, string s){
    ll R = 0;
    ll B = 0;
    rep(i, N) {
        if (s[i] == 'R') R++;
        else B++;
    }
    cout << (R > B ? "Yes" : "No") << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    string s;
    cin >> s;
  solve(N, s);
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
# = int(input())
# = input()
# = list(map(int, input().split()))

com = []
for i in range(n):
	a = []
	if i == 0:
		com = list(map(int, input().split()))
		del com[0]
	else:
		a = list(map(int, input().split()))
		del a[0]
		com = list(set(com) & set(a))
print(len(com))


Measured memory_bytes: 3060
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------
int h,w;
int mapp[410][410],cp[410][410];
string s;

deque<pi> q;
int bl,wh,ret;
signed main(){
    I(h); I(w);
    REP(i,h){
        cin >> s;
        REP(j,w) mapp[i][j] = (s[j] == '#'); 
        REP(j,w) cp[i][j] = mapp[i][j];
    }
    
    REP(i,h) { REP(j,w){
        if (mapp[i][j] == 1){
            q.pb(mp(i,j));
            bl = 1; wh = 0;
            mapp[i][j] = -1;
            while(!q.empty()){
                auto tgt = q.front();
                q.pop_front();
                int x = tgt.first;
                int y = tgt.second;

                if (x > 0 && mapp[x-1][y] != -1 && cp[x-1][y] != cp[x][y]){
                    q.pb(mp(x-1,y));
                    if (cp[x-1][y]){ bl++; } else { wh++; }
                    mapp[x-1][y] = -1;
                }
                if (x < h-1 && mapp[x+1][y] != -1 && cp[x+1][y] != cp[x][y]){
                    q.pb(mp(x+1,y));
                    if (cp[x+1][y]){ bl++; } else { wh++; }
                    mapp[x+1][y] = -1;
                }
                if (y > 0 && mapp[x][y-1] != -1 && cp[x][y-1] != cp[x][y]){
                    q.pb(mp(x,y-1));
                    if (cp[x][y-1]){ bl++; } else { wh++; }
                    mapp[x][y-1] = -1;
                }
                if (y < w-1 && mapp[x][y+1] != -1 && cp[x][y+1] != cp[x][y]){
                    q.pb(mp(x,y+1));
                    if (cp[x][y+1]){ bl++; } else { wh++; }
                    mapp[x][y+1] = -1;
                }
            }

            ret += bl * wh;
        }
    } }
    cout << ret << endl;
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,d[51];
	scan(N);
	rep(i,N) scan(d[i]);
	int ans=0;
	rep(i,N-1){
		for(int j=i+1;j<N;j++){
			ans+=d[i]*d[j];
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,count = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int l,r;
    cin >> l >> r;
    count += r-l+1;
  } 
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [[0, 0, 0]for _ in range(2*N)]
for i in range(N):
    x, y = map(int, input().split())
    P[i] = [0, x, y]
for i in range(N):
    x, y = map(int, input().split())
    P[N+i] = [1, x, y]
P.sort(key=lambda x: x[1])
cnt = 0
for i in range(2*N):
    if P[i][0] == 0:
        continue
    else:
        if i == 0:
            continue
        else:
            M = [-1, -1]
            for j in range(i):
                if P[j][0] == 0:
                    if P[j][2] > M[1] and P[j][2] < P[i][2]:
                        M = [j, P[j][2]]
            if M[0] != -1:
                cnt += 1
                P[M[0]][0] = 2
print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String S = scan.next();
		int[] atWestToEast = new int[N];
		int[] atEastToWest = new int[N];
		int count = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 1; i < N; i++) {
			if (S.charAt(i - 1) == 'W') {
				atWestToEast[i] = atWestToEast[i - 1] + 1;
			} else {
				atWestToEast[i] = atWestToEast[i - 1];
			}
			if (S.charAt(i) == 'E') {
				count++;
				atEastToWest[i] = atEastToWest[i - 1] - 1;
			} else {
				atEastToWest[i] = atEastToWest[i - 1];
			}
			 min = Math.min(min, atEastToWest[i] + atWestToEast[i]);
		}
		System.out.println(Math.min(0, min) + count);
	}

}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,m;cin>>n>>m;
    vl x(n),y(m),a(n-1),b(m-1);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    ll suma=0,sumb=0;
    rep(i,n-1){
        a[i]=(x[i+1]-x[i])%MOD*(i+1)%MOD*(n-i-1)%MOD;
        suma+=a[i];
        suma%=MOD;
    }
    rep(i,m-1){
        b[i]=(y[i+1]-y[i])%MOD*(i+1)%MOD*(m-i-1)%MOD;
        sumb+=b[i];
        sumb%=MOD;
    }
    cout<<suma*sumb%MOD<<endl;
}

Measured memory_bytes: 6404
#include<stdio.h>
int main(){
 
  int n,x,i,j,k,count;
 
  while(1){
    count=0;
    scanf("%d%d",&n,&x);
    if(n == 0 && x == 0)break;
 
 
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
    for(k=j+1;k<=n;k++){
 
      if(i+j+k==x){
        count++;
      }
 
    }
      }
    }
      printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 600
# coding: utf-8

# https://atcoder.jp/contests/abc080/tasks/abc080_c
# 15:36-16:15 done

from copy import deepcopy


def main():
    N = int(input())
    F = [None] * N
    for i in range(N):
        F[i] = list(map(int, input().split()))
    P = [None] * N
    for i in range(N):
        P[i] = list(map(int, input().split()))

    # max_benefit = -(10**10)
    n_overlaps_list = []

    def rec(time_i, counts, flag):
        # print(counts)
        # exit()
        # 終章条件
        if time_i == 10:
            if not flag:
                # print(counts)
                n_overlaps_list.append(counts)
            return None

        counts_1 = deepcopy(counts)
        counts_2 = deepcopy(counts)

        for i in range(len(counts)):
            if F[i][time_i] == 1:
                counts_2[i] += 1

        rec(time_i+1, counts_1, flag and True)  # 開かない
        rec(time_i+1, counts_2, False)  # 開く

    rec(0, [0] * N, True)
    # print(n_overlaps_list)

    ans = -(10**10)
    tmp = None
    for n_overlaps in n_overlaps_list:
        candidate = 0
        for i in range(N):
            candidate += P[i][n_overlaps[i]]
        if candidate > ans:
            ans = candidate
            tmp = n_overlaps
    # print(tmp)
    
    return ans


print(main())


Measured memory_bytes: 4468
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
#include<vector>
using namespace std ;
typedef long long ll;

// N K
// A_1, ..., A_N
int main(){
    string S;
    cin >> S ;

    vector<string> devide_strings{"dream", "dreamer", "erase", "eraser"} ;

    // 後ろから解いていく
    reverse(S.begin(), S.end()) ;

    for(auto &s: devide_strings)
        reverse(s.begin(), s.end()) ;

    bool can = true ;
    for(int i = 0; i != S.size(); )
    {
        bool can2 = false ;
        for(auto devide_string: devide_strings)
        {
            if(S.substr(i, devide_string.size()) == devide_string)
            {
                i += devide_string.size() ;
                can2 = true ;
                break ;
            }
        }
        if(!can2){
            can = false ;
            break ;
        }
    }

    if(can)
        cout << "YES" << endl ;
    else
        cout << "NO" << endl ;
}

Measured memory_bytes: 512
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s):
        if ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s):
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vp;
typedef set<ll> si;
typedef map<string, ll> msi;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int T;
  T=1;
  while(T--){
      ll n,i,j,k,l,q,m,b,c,x,sum=0;
      //char c;
      cin>>n;
      map<ll,ll> mp;
      ll a[n];
      REP(i,0,n-1){
        cin>>a[i];
        sum+=a[i];
        if(mp.find(a[i])!=mp.end())mp.find(a[i])->second++;
        else{
          mp.insert({a[i],1});
        }
      }
      cin>>q;
      while(q--){
        cin>>b>>c;
        if(mp.find(b)==mp.end())cout<<sum<<"\n";
        else{
          x=mp.find(b)->second;
          mp.erase(mp.find(b));
          sum-=b*x;
          sum+=c*x;
          if(mp.find(c)!=mp.end())mp.find(c)->second +=x;
          else{
            mp.insert({c,x});
          }
          cout<<sum<<"\n";
        }
      }


  }
  return 0;
}

Measured memory_bytes: 8368
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
string S;

bool dfs(int pos) {
  string T[4] = { "dream", "dreamer", "erase", "eraser" };
  if (S.length() == pos) return true;
  for (int i = 0; i < 4; i++) {
    if (S.substr(pos, T[i].length()) == T[i]) {
      if (dfs(pos+T[i].length())) return true;
    }
  }
  return false;
}

signed main() {
  cin >> S;
  if (dfs(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 6016
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef unsigned long long ll;
const ll inf=-1;
int a[200010];
ll s[200010];
int get(int i){
	return i==1?5:i*2+1;
}
int main(){
	int n,i,j,k;
	ll X,ans,t;
	scanf("%d%llu",&n,&X);
	for(i=1;i<=n;i++){
		scanf("%d",a+i);
		s[i]=s[i-1]+a[i];
	}
	ans=inf;
	for(k=1;k<=n;k++){
		j=0;
		t=0;
		for(i=n;i>0;i-=k){
			j++;
			t+=get(j)*(s[i]-s[max(i-k,0)]);
		}
		ans=min(ans,t+k*X);
	}
	printf("%llu",ans+n*X);
}

Measured memory_bytes: 2560
if __name__ == "__main__":
    n = int(input())
    l_a = list(map(int, input().split()))
    s_a = list(set(l_a))

    #s_a.sort()

    dub_a = [0]*(max(s_a)+1)

    for i in l_a:
        dub_a[i] += 1

    dp = [1]*(max(s_a)+1)

    for i in s_a:
        for j in range(2*i, len(dp), i):
            dp[j] = 0


    count = 0
    for i in s_a:
        if dp[i]==1 and dub_a[i]==1:
            count += 1
    print(count)

Measured memory_bytes: 35052
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, D, ans;
    cin >> N >> D;

    ans = N / (2*D+1);
    if (N % (2*D+1) != 0){
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
ll d[200009]={};
int n;
void addx(int k1,ll m){
	while(k1<n+2){
		d[k1]+=m;
		k1+=k1&-k1;
	}
	return;
}
int sumx(int k1){
	int r=0;
	while(k1>0){
		r+=d[k1];
		k1-=k1&-k1;
	}
	return r;
}

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

	ll a[200001]={};
	vector<ll> v;
	ll t=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
		t+=a[i]-k;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	ll c=0;
	t=0;
	for(int i=0;i<n;++i){
		t+=a[i]-k;
		if(t>=0)c++;
		auto it=upper_bound(v.begin(),v.end(),t);
		int x=it-v.begin();
		c+=sumx(x);
		addx(x,1);
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 5104
#include <bits/stdc++.h>
//#include <cstdlib>
//#include <cmath>

using namespace std;

int main() {
  
  
  string vo_cal = "aeiou";
  
  char c;
  cin >> c;
  
  
  for (int i = 0; i<5 ; i++){
    if (c == vo_cal.at(i)){
      cout << "vowel" << endl;
      break;
    }
    else if ( i == 4 ){
      cout << "consonant" << endl;
    }
    
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int a, b, c, d;
	int left, right;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	left = a + b; right = c + d;
	printf((left > right) ? "Left" : (left == right) ? "Balanced" : "Right");
}

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

const int INF = 1e+9;

int main()
{
  int n,m;
  while(cin >> n >> m, n||m)
  {
    int d[2][101][101];
    for(int i=0; i < 101; i++)
    {
      for(int j=0; j < 101; j++ )
      {
        d[0][i][j] = (i==j)? 0 : INF;
        d[1][i][j] = (i==j)? 0 : INF;
      }
    }

    for(int i=0; i < n; i++)
    {
      int a, b, cost,time;
      cin >> a >> b >> cost >> time;
      d[0][a][b] = cost;
      d[0][b][a] = cost;
      d[1][a][b] = time;
      d[1][b][a] = time;
    }
    for(int k=1; k <= m; k++)
    {
      for(int i=1; i <= m; i++)
      {
        for(int j=1; j <= m; j++)
        {
          d[0][i][j] = min(d[0][i][j], d[0][i][k]+d[0][k][j]);
          d[1][i][j] = min(d[1][i][j], d[1][i][k]+d[1][k][j]);
        }
      }
    }
    int k;
    cin >> k;
    for(int i=0; i < k; i++)
    {
      int p, q, r;
      cin >> p >> q >> r;
      cout << d[r][p][q] << endl;
    }
  }
}

Measured memory_bytes: 1236
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=sc.nextInt(),b=sc.nextInt();//生地値段、トッピング値段
		int c=sc.nextInt();//生地カロリー
		int[] d=new int[n];//トッピングカロリー
		for(int i=0;i<n;i++){
			d[i]=sc.nextInt();
		}
		for(int i=0;i<d.length-1;i++){	//降順sort
            for(int j=0;j<d.length-i-1;j++){
            	if(d[j]<d[j+1]){
            		int s=d[j];
            		d[j]=d[j+1];
            		d[j+1]=s;
            	}
            }
		}
		int pt=0;
		int ans=0;
		int bp=0;
		for(int i=0;i<n;i++){
			pt+=d[i];
			bp=(c+pt)/(a+(i+1)*b);//1ドルあたりのカロリー数
			if(bp>ans)ans=bp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 18116
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << (s[0] == s[2]?"Yes":"No");    
    return 0;
}

Measured memory_bytes: 256
S = input()

ans = True
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] not in ['R', 'U', 'D']:
            ans = False
            break
    else:
        if S[i] not in ['L', 'U', 'D']:
            ans = False
            break
print('Yes' if ans else 'No')


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int nCount, iIn;
	register int i;
	set<int> setNums;
	cin >> nCount;
	for (i = 1; i <= nCount; ++i){
		cin >> iIn;
		if (setNums.find(iIn) != setNums.end())
			setNums.erase(iIn);
		else
			setNums.insert(iIn);
	}
	cout << setNums.size() << endl;
endapp:
	//system("pause > nul");
	return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n), dp(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  dp[n - 1] = 0;
  dp[n - 2] = abs(a[n - 2] - a[n - 1]);
  for(int i = n - 3; i >= 0; i--) dp[i] = min(abs(a[i] - a[i + 1]) + dp[i + 1], abs(a[i] - a[i + 2]) + dp[i + 2]);
  cout << dp[0] << endl;
  return 0;
}


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

const int Maxn = 100005;

int n, m;
int B[Maxn];
bool could[Maxn];
int res;

int main()
{
    scanf("%d %d", &n, &m);
    could[1] = true;
    for (int i = 1; i <= n; i++)
        B[i] = 1;
    for (int i = 0; i < m; i++) {
        int x, y; scanf("%d %d", &x, &y);
        if (could[x]) {
            could[y] = true;
            if (B[x] == 1) could[x] = false;
        }
        B[x]--; B[y]++;
    }
    for (int i = 1; i <= n; i++)
        res += could[i];
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();

using namespace __gnu_pbds;
using namespace std;

const int N=2e5+1, mod=998244353;
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;

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


  // #ifndef ONLINE_JUDGE
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  // #endif

  int n;
  cin>>n;
  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
    int x,l;
    cin>>x>>l;
    v.pb({x-l,x+l});
  }
  sort(v.begin(),v.end());

  int l=-INF,r=-INF,ct=0;
  for(int i=0;i<n;i++){
    if( v[i].xx >= r ){
      l=v[i].xx; r=v[i].yy;
      ct++;
    }else if( v[i].xx>=l ){
      r=min(r,v[i].yy);
    }
  }
  cout<<ct;
  
  yogeshk972();
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jun 13 21:11:46 JST 2020
 **/

signed main() {
    Int n, K;
    std::cin >> n >> K;
    std::vector<Int> a(n + 1);
    REP(i, n) std::cin >> a[i];
    REP(k, K) {
        if (std::count(a.begin(), a.begin() + n, n) == n) break;
        std::vector<Int> nxt(n + 1);
        REP(i, n) {
            nxt[std::max(0LL, i - a[i])]++;
            nxt[std::min(n, i + a[i] + 1)]--;
        }
        REP(i, n) nxt[i + 1] += nxt[i];
        std::swap(a, nxt);
        dump(a);
    }
    REP(i, n) std::cout << a[i] << " ";
    std::cout << std::endl;
}


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

using ll = long long;
using P = pair<int, int>;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;

  int ans = INF;
  for (int i = 0; i <= N; i++) {
    int tmp = 0;
    int a = i;
    int b = N - i;
    
    int n = 46656;
    while (n > 1) {
      tmp += a / n;
      a %= n;
      n /= 6;
    }
    tmp += a;
    n = 59049;
    while (n > 1) {
      tmp += b / n;
      b %= n;
      n /= 9;
    }
    tmp += b;

    ans = min(ans, tmp);
  }

  // 解答
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

   int main () {

     int i,j,k,n,x;

     while (1) {

     int a = 0;

      scanf ( "%d %d\n", &n, &x );

      if ( n == 0 && x == 0){
       break;
      }

       for ( i = 1; i <= n-2; i++) {
        for ( j = i+1; j <= n-1; j++){
         for ( k = j+1; k <= n; k++){
          if ( i+j+k == x){
                 a++ ;
          }
         }
        }
       }

       printf ("%d\n", a);

}

      return 0;
}



Measured memory_bytes: 2120
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;
long[10^^5+50] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

int[10^^5+10] MEMO;;

void main()
{
    init();
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);

    int l, r;
    foreach (int i, a; as) {
        if (MEMO[a]) {
            l = MEMO[a];
            r = i+1;
            break;
        } else {
            MEMO[a] = i + 1;
        }
    }

    foreach (i; 0..n+1) {
        ++i;
        if (i == 1) {
            writeln(n);
        } else if (i == n+1) {
            writeln(1);
        } else {
            auto res = comb(n+1, i);
            if (l-1 + (n+1 - r) >= i - 1) res = (res - comb(l-1 + (n+1 - r), i - 1) + P) % P;
            writeln(res);
        }
    }
}

Measured memory_bytes: 6308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll a, b;
	cin >> a >> b;
	if (a % 2 == 0) {
		if (b % 2 == 1) {
			cout << (b - a + 1) / 2 % 2 << endl;
		}
		else {
			if (a == b) cout << a << endl;
			else {
				cout << (((b - 1 - a + 1) / 2 % 2) ^ b) << endl;
			}
		}
	}
	else {
		if (b % 2 == 1) {
			if (a == b) cout << a << endl;
			else {
				cout << (((b - (a + 1) + 1) / 2 % 2) ^ a) << endl;
			}
		}
		else {
			if (b == a + 1) cout << (a ^ b) << endl;
			else {
				cout << (((b - 1 - (a + 1) + 1) / 2 % 2) ^ a ^ b) << endl;
			}
		}
	}
}


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

#define MAX_N 100

void print_lst_a(int *lst_a, int n) {
  rep(j, n - 1) cout << lst_a[j] << " ";
  cout << lst_a[n - 1] << endl;
}

int main() {
  int n, lst_a[MAX_N];
  cin >> n;
  rep(i, n) cin >> lst_a[i];

  print_lst_a(lst_a, n);
  for (int i = 1; i < n; i++) {
    int v = lst_a[i];
    int j = i - 1;
    while (j >= 0 && lst_a[j] > v) {
      lst_a[j + 1] = lst_a[j];
      j--;
    }
    lst_a[j + 1] = v;
    print_lst_a(lst_a, n);
  }

  return 0;
}



Measured memory_bytes: 3104
n=int(input())
S=input()
l=[]
for i in range(10**3):
    num=str(i).zfill(3)
    s=S
    if s.find(num[0])==-1: continue
    s=s[s.index(num[0])+1:]
    if s.find(num[1])==-1: continue
    s=s[s.index(num[1])+1:]
    if s.find(num[2])==-1: continue
    l.append(num)
print(len(set(l)))

Measured memory_bytes: 3188
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        String s = sc.next();
        int firstA = s.indexOf('A');
        int lastZ = s.lastIndexOf('Z');
        System.out.println(lastZ - firstA + 1);
    }
}

Measured memory_bytes: 26196
#include <iostream>
#include <vector>
#include <limits>

int merge(std::vector<int> & list, int left, int mid, int right) {
    constexpr int MAX = std::numeric_limits<int>::max();

    std::vector<int> l_list, r_list;
    l_list.reserve(mid - left + 1);
    for (int i = left; i < mid; ++i) {
        l_list.emplace_back(list.at(i));
    }
    l_list.emplace_back(MAX);
    l_list.reserve(right - mid + 1);
    for (int i = mid; i < right; ++i) {
        r_list.emplace_back(list.at(i));
    }
    r_list.emplace_back(MAX);

    int left_id = 0;
    int right_id = 0;
    int count = 0;
    for (int i = left; i < right; ++i) {
        ++count;
        if (l_list.at(left_id) <= r_list.at(right_id)) {
            list.at(i) = l_list.at(left_id);
            ++left_id;
        } else {
            list.at(i) = r_list.at(right_id);
            ++right_id;
        }
    }

    return count;
}

int mergeSort(std::vector<int> & list, int left, int right) {
    int count = 0;

    if (left + 1 < right) {
        const int mid = (left + right) / 2;
        count += mergeSort(list, left, mid);
        count += mergeSort(list, mid, right);
        count += merge(list, left, mid, right);
    }

    return count;
}

int main() {

    int n;
    std::cin >> n;

    std::vector<int> S;
    S.reserve(n);
    while (n--) {
        int t;
        std::cin >> t;
        S.emplace_back(t);
    }

    int count = mergeSort(S, 0, S.size());

    std::cout << S.front();
    const auto endItr = S.cend();
    for (auto itr = S.cbegin() + 1; itr != endItr; ++itr) {
        std::cout << " " << *itr;
    }
    std::cout << std::endl;
    std::cout << count << std::endl;

    return 0;

}

Measured memory_bytes: 7212
s=list(input())
ss=s*3
k=int(input())
cnt1,cnt2,cnt3=0,0,0
for i in range(len(ss)-1):
    if ss[i]==ss[i+1]:
        ss[i+1]='.'
        if i<=len(s)-2:
            cnt1+=1
        elif len(s)-2<i<=2*len(s)-2:
            cnt2+=1
        else:
            cnt3+=1

#print(cnt1,cnt2,cnt3)

if cnt1==cnt3:
    if k%2==0:
        print((cnt1*(k//2))+cnt2*((k//2)))
    else:
        print((cnt1*((k//2)+1))+cnt2*(k//2))
elif cnt2==cnt3:
        print(cnt1+(cnt2*(k-1)))

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

using namespace std;

int main(){
    int n;
    vector<tuple<char, int, int>> teams;
    while(cin >> n && n){
        teams.resize(n);
        for(int i = 0; i < n; i++){
            char team;
            cin >> team;
            int win = 0, lose = 0;
            for(int j = 0; j < n - 1; j++){
                int result;
                cin >> result;
                switch(result){
                case 0:
                    win++;
                case 1:
                    lose++;
                }
            }
            teams[i] = make_tuple(team, win, lose);
        }
        sort(begin(teams), end(teams), [](tuple<char, int, int> a, tuple<char, int, int> b){
            if(get<1>(a) != get<1>(b)){
                return get<1>(a) > get<1>(b);
            }else{
                return get<2>(a) < get<2>(b);
            }
        });
        for(auto&& i : teams){
            cout << get<0>(i) << "\n";
        }
    }
}


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

int main(void){
   string S;
   cin>>S;
   if(S.size()%2==1){
      cout<<"No"<<endl;
      return 0;
   }
   bool flag=true;
   for(int i=0;i<S.size();i++){
      if((i%2==0&&S[i]!='h')||(i%2==1&&S[i]!='i')){
         flag=false;
         break;
      }
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 3644
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        char line[] = sc.nextLine().toCharArray();
        for(int i = 0; i < line.length; i++){
            if(Character.isUpperCase(line[i])){
                sb.append(Character.toLowerCase(line[i]));
                
            }else{
                sb.append(Character.toUpperCase(line[i]));
            }
        }
       System.out.println(new String(sb));
    }
}


Measured memory_bytes: 26144
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
    	
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int H = sc.nextInt();
    	int W = sc.nextInt();
    	int []A = new int[N];
    	int []B = new int[N];
    	
    	int cnt = 0;
    	
    	for(int n=0; n<N; n++) {
    		A[n] = sc.nextInt();
    		B[n] = sc.nextInt();
    	}
    	
    	for(int i=0; i<N; i++) {
    		if(A[i]>=H && B[i]>=W) {
    			cnt++;
    		}
    	}
	    System.out.println(cnt);
    }
}

Measured memory_bytes: 25172
n,p=map(int,input().split())
D={}
ans=1
while True:
    memo=0
    for i in range(2,1+int(p**0.5)):
        if p%i==0:
            if i in D:
                D[i]+=1
            else:
                D[i]=1
            p=p//i
            memo=1
            break
    if memo==0:
        if p in D:
            D[p]+=1
        else:
            D[p]=1
        break
for k,v in D.items():
    ans*=max(1,k**(v//n))
print(ans)

Measured memory_bytes: 3188
last = int(input())
m = set([last])
for i in range(2, int(1e7) + 2):
    if last & 1:
        a = last * 3 + 1
    else:
        a = last // 2
    if a in m:
        print(i)
        break
    m.add(a)
    last = a


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int N;
    cin >> N;
    if(N == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}


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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

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

    cout << a * b << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i, f, n) for (int i = f; i < n; ++i)
#define rep(i, n) reep(i, 0, n)

typedef vector<int> vi;

int main()
{
    map<string, vi> table;
    char str[32];
    int p;
    while (scanf("%s %d", str, &p) != EOF)
    {
        string s(str);
        if (table.count(s))
            table[s].push_back(p);
        else
            table[s] = vi(1, p);
    }
    for (map<string, vi>::iterator itr = table.begin(); itr != table.end(); itr++)
    {
        sort(itr->second.begin(), itr->second.end());
        puts(itr->first.c_str());
        for (int i = 0; i < itr->second.size(); i++)
            printf("%s%d", i ? " " : "", itr->second[i]);
        puts("");
    }
    return 0;
}


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

using namespace std;
#define ll long long int
#define MAX 1000001
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define VV vector
#define pb push_back
#define bitc __builtin_popcountl
#define mp make_pair
#define inf 200000000000000l
#define swap(a, b) { a = a ^ b; b = a ^ b; a = a ^ b; }
#define rep(i, n) for (ll i = 0, _n = (n); i < _n; i++)
#define debug(x) cout << #x << ": " << x << endl;
#define fr(i, a, b) for (ll i = (a), _b = (b); i <= _b; i++)

ll arr[MAX];



int main()
{
  fast
  ll n,d;
  cin>>n>>d;
  ll** arr=new ll*[n];
  for(int i=0;i<n;i++)
  {
    arr[i]=new ll[d];
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<d;j++)
    {
      cin>>arr[i][j];
    }
  }
  ll count=0;
  ll sum=0;
  for(int i=0;i<n;i++)
  {


    for(int j=i+1;j<n;j++)
    {
      sum=0;
      for(int o=0;o<d;o++)
      {
        sum+=int(pow((arr[i][o]-arr[j][o]),2));
      }
      if(ceil(sqrt(sum))==floor(sqrt(sum))) count++;
      sum=0;
    }
  }
  cout<<count<<endl;




  return 0;
}


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

bool isprime(int num) //素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    for (int i = 3; i*i <= num; i += 2)
    {
        if (num % i == 0) return false;
    }
    // 素数である
    return true;
}

int main(){
    int q;
    cin >> q;
    bool is_prime[100010];
    rep(i,100010){
        is_prime[i]=isprime(i);
    }

    int sum[100010];
    memset(sum,0,sizeof(sum));
    int s=0;

    for(int i=99999;i>=1;i=i-2){
        if(is_prime[i] && is_prime[(i+1)/2]){
            s++;
        }
        sum[i]=s;
    }
    
    int ans[q];
    

    rep(i,q){
        int l,r;
        cin >> l >> r;
        ans[i]=sum[l]-sum[r+2];
    }

    rep(i,q) cout << ans[i] << endl;
}

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

int main()
{
    int s;
    cin >>s;
    set<int> st;
    int v = s;
    while(st.count(v)==0){
        st.insert(v);
        if(v%2==0){
            v/=2;
        }else{
            v=3*v+1;
        }
    }
    cout << st.size()+1<<endl;
    return 0;
}

Measured memory_bytes: 256