akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
using namespace std;
#define DIST(R1,R2)(2*sqrt((double)(R1)*(R2)))
double dp[1<<12][12];
int main() {
	string str;
	while(getline(cin,str)) {
		stringstream sstr(str);
		int n,m,R[12];
		sstr>>m;
		for(n=0;sstr>>R[n];n++);
		fill((double*)dp,(double*)(dp+(1<<12)),1<<27);
		for(int i=0;i<n;i++) {
			dp[1<<i][i]=R[i];
		}
		for(int i=1;i<(1<<n);i++) {
			for(int j=0;j<n;j++) {
				if(dp[i][j]==(1<<27)) continue;
				for(int k=0;k<n;k++) {
					if(i&(1<<k)) continue;
					dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+DIST(R[j],R[k]));
				}
			}
		}
		bool OK=false;
		for(int i=0;i<n;i++) {
			if((dp[(1<<n)-1][i]+R[i])<=m) {OK=true;break;}
		}
		cout<<(OK?"OK":"NA")<<endl;
	}
}

Measured memory_bytes: 1592
#include <iostream>

using namespace std;

int w, h;
int f[21][21];
int ans;

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

void rec(int n, int x, int y) {
  if (n >= ans) { return; }

  for (int i=0; i<4; i++) {
    int mx=x, my=y;
    mx += dx[i]; my += dy[i];
    if (mx < 0 || mx >= w) { continue; }
    if (my < 0 || my >= h) { continue; }
    if (f[my][mx] == 1) { continue; }

    while (1) {
      if (f[my][mx] == 3) {
        ans = n;
        return;
      }

      mx += dx[i]; my += dy[i];
      if (mx < 0 || mx >= w) { break; }
      if (my < 0 || my >= h) { break; }

      if (f[my][mx] == 1) {
        f[my][mx] = 0;
        rec(n+1, mx-dx[i], my-dy[i]);
        f[my][mx] = 1;
        break;
      }
    }
  }
}

int main() {
  while (cin >> w >> h, (w || h)) {
    int sx, sy;
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        cin >> f[y][x];
        if (f[y][x] == 2) {
          sx = x; sy = y;
        }
      }
    }

    ans = 11;
    rec(1, sx, sy);
    if (ans > 10) { ans = -1; }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3028
from collections import deque
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
d=deque()

l=[[] for _ in range(n)]
R=[-1]*(n+1)
R[1]=0

for _ in range(m):
    x,y=tuple(map(int,input().split()))
    l[x-1].append(y)
    l[y-1].append(x)

def g(s):
    for i in range(len(l[s-1])):
        if R[l[s-1][i]]==-1:
            R[l[s-1][i]]=s
            d.append(l[s-1][i])
    if len(d)!=0:
        s=d.popleft()
        return g(s)
    else:
        return
g(1)
print("Yes")
for h in range(2,len(R)):
    print(R[h])

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        hs: [usize; n]
    }
    let mut m = hs[0];
    let mut count = 1;
    for i in 1..n {
        if m <= hs[i] {
            count += 1;
            m = max(m, hs[i]);
        }
    }
    println!("{}", count);
}


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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)

// -----



int main()
{
    string s;
    cin >> s;
    pl((s == "ABC" ? "ARC" : "ABC"));
}

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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	
	if (x - r < 0 || x + r > W || y - r < 0 || y + r > H){
		cout << "No" <<endl;
	}else{
		cout << "Yes" <<endl;
	}
	return 0;
}

Measured memory_bytes: 3104
"use strict";

const is_palindrome = s => {
    let n = s.length;
    for (let i = 0; i < n; i++) {
        if (s[i] !== s[n - i - 1]) return false;
    }

    return true;
}

const main = (input) => {
    const spi = input.split('\n');
    const n = Number(spi[0]);
    const d = n / 3;
    console.log(d*d*d);
};

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


Measured memory_bytes: 29676
#include <iostream>
using namespace std;
int main(void)
{
    double r;
    double pi=3.141592653589;
    double are;
    double circ;
    scanf("%lf",&r);
    are=r*r*pi;
    circ=pi*2*r;
    printf("%f %f\n",are,circ);
}



Measured memory_bytes: 3188
local n = io.read("*n", "*l")
local str = io.read()
local t = {}
for i = 1, n do
  t[i] = string.sub(str, i, i) == "#" and 1 or 0
end
local blacks, whites = {}, {}
blacks[1] = t[1]
for i = 2, n do
  blacks[i] = blacks[i - 1] + t[i]
end
for i = 1, n do
  whites[i] = i - blacks[i]
end
local ret = n
local btot = blacks[n]
for i = 0, n do
  local cand = 0
  if(i == 0) then
    cand = cand + whites[n]
  else
    cand = cand + blacks[i]
    cand = cand + (whites[n] - whites[i])
  end
  ret = math.min(ret, cand)
end
print(ret)


Measured memory_bytes: 6844
#include <iostream>

using namespace std;

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

string w;
int x;
bool b;

int main(){
    cin >> w;
    vector<char> v;
    for(int i = 0; i < w.length(); i++){
        v.push_back(w[i]);
    }
    sort(v.begin(), v.end());

    for(int i = 0; i < v.size(); i++){
        if(v[i] == v[i+1]){
            x++;
        } else{
            if((x+1)%2 != 0){
                b = false;
                cout << "No";
                return 0;
            }
            x = 0;
        }
    }

    cout << "Yes";

}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 3e3+5;
const int INF = 1e9;
const int MOD = 1e9+7;

string s, t;
int n, m;
int max(int a, int b, int c){
	return max(a, max(b, c));
}
int dp[N][N];
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> s >> t;
	n = s.length(); m = t.length();
	s = "*" + s;
	t = "-" + t;
	for(int i=0; i<N; i++){
		dp[i][0] = 0;
		dp[0][i] = 0;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1], dp[i-1][j-1]+(s[i]==t[j]));
		}
	}
	if (dp[n][m] == 0) return 0*puts(" ");
	string T = "";
	int x = n, y = m;
	while(x > 0 && y>0){
		if (s[x] == t[y]) {
			T += s[x];
			x--, y--;
		} else {
			if (dp[x-1][y] > dp[x][y-1]) x--;
			else y--;
		}
	}
	reverse(T.begin(), T.end());
	cout << T << endl;

	return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    string s; cin >> s;
    int a = 0, b = 0;
    rep(i, SZ(s)) {
        if (s[i] == '0') a++;
        else b++;
    }
    //out(a << " " << b);
    out(min(a, b) * 2);
}




Measured memory_bytes: 512
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
#define PI 3.1415926535
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 3e6;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

vector <int> bpow(vector <int> a, int n, int k)
{
    vector <int> p(n);
    iota(all(p), 0);
    for (int i = 0; i < a.size(); ++i)
        swap(p[a[i]], p[a[i] - 1]);
    vector <int> res(n);
    iota(all(res), 0);
    while (k)
    {
        if (k & 1)
        {
            vector <int> r = res;
            for (int i = 0; i < n; ++i)
                res[i] = r[p[i]];
        }
        vector <int> r = p;
        for (int i = 0; i < n; ++i)
            p[i] = r[r[i]];
        k >>= 1;
    }
    return res;
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> x(n);
    cin >> x;
    vector <int> d(n - 1);
    for (int i = 1; i < n; ++i)
        d[i - 1] = x[i] - x[i - 1];
    int m, k;
    cin >> m >> k;
    vector <int> a(m);
    cin >> a;
    for (auto &i : a)
        --i;
    a = bpow(a, n - 1, k);
    auto t = d;
    for (int i = 0; i < n - 1; ++i)
        d[i] = t[a[i]];
    d.pb(0);
    int sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cout << x[0] + sum << endl;
        sum += d[i];
    }
    return 0;
}




Measured memory_bytes: 5760
nn = gets.to_i
xy = nn.times.map{gets.split.map(&:to_i)}.sort_by{|a|Math.atan2(a[1],a[0])}.to_a

# 2周分定義
xy = xy*2
max=0
nn.times do |from|
  x = 0
  y = 0
  from.upto(from+nn-1) do |to|
    x += xy[to][0]
    y += xy[to][1]
    dist = Math.hypot(x,y)
    if max < dist
      max = dist
    end
  end
end

puts max


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int N{}; std::cin >> N;
	std::vector<long long> L(N);
	for (auto& r : L) std::cin >> r;
	long long ans{};
	for (int i{ 0 }; i < N - 2; ++i) {
		for (int j{ i + 1 }; j < N - 1; ++j) {
			for (int k{ j + 1 }; k < N; ++k) {
				if ((L.at(i) + L.at(j)) > L.at(k)
					&& (L.at(i) + L.at(k)) > L.at(j)
					&& (L.at(j) + L.at(k)) > L.at(i)
					&& (L.at(i) != L.at(j)
						&& L.at(j) != L.at(k)
						&& L.at(i) != L.at(k))
					) ++ans;
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
    int n, k;
    cin >> n >> k;
    int ans=0;
    for(int i=1;i<1000;++i) {
        if(n>=pow(k,i-1) && n<pow(k,i)) {
            ans=i;
            break;
        }
        
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    
    int v=0;
    REP(i,n){
        while(a[i]%2==0){
            v++;
            a[i]/=2;
        }
    }

    cout<<v<<endl;

	return 0; 
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c,d,x[4];
    cin>>a>>b>>c>>d;
    x[0]=a*c;
    x[1]=a*d;
    x[2]=b*c;
    x[3]=b*d;
    long long max=x[0];
    for(int i=1;i<4;i++)
    {
        if(max<x[i])
            max=x[i];
    }
    cout<<max<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	string s;
	sc(s);
	if(s[0]==s[1] or s[1]==s[2] or s[2]==s[3])re pr("Bad"),0;
	else pr("Good");


	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = scanner.nextInt();
        long count = 0;
        for(int i = 1; i <= n; i++){
            for (int j = 1; i * j <= n; j++) {
                count += i * j;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35548
def main():
    N, Y = (int(i) for i in input().split())
    ans = [-1, -1, -1]
    for x in range(N+1):
        for y in range(N+1):
            z = N - x - y
            if z < 0:
                continue
            yen = x*10000 + y*5000 + z*1000
            if yen == Y:
                ans = [x, y, z]
                break
        if ans != [-1, -1, -1]:
            break
    print(*ans)


if __name__ == '__main__':
    main()


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

int main(){
//srandom((unsigned long)time(NULL));
long long N;
cin>>N;
//1 2 3 4 5 6
//2 4 6 8 10 12
//3 6 9 12 15 18
//4 8 12 16 20 24
//5 10 15 20 25 30
//6 12 18 24 30 36

vector<tuple<long long,long long>> a;
long long x,y;
for(long long i=1;i<=sqrt(N);i++){
    if(N%i==0){
        a.emplace_back(i,N/i);
        x=i;
        y=N/i;
    }
}

cout<<x+y-2<<endl;

return 0;
}

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    if ( 2 * N > M ) ans = M / 2;
    else {
        ans = (N + M / 2) / 2;
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int n,k;
    string s;
    cin>>n>>s>>k;
    char rep=s[k-1];
    for(int i=0;i<n;i++)
    {
        if(s[i]!=rep)
        s[i]='*';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}

object Main {
  def isStable(l:Array[(String, Int)],a:Array[(String, Int)]) = {
    val s = l.groupBy(_._2).filter(_._2.length > 1)
    var stable = true

    for { i <- s if stable }
      if(a.filter(_._2 == i._1).toSeq != i._2.toSeq)
        stable = false
    stable
  }

  def exchange(a:Array[(String,Int)],i:Int,j:Int) = {
    val temp = a(i)
    a(i) = a(j)
    a(j) = temp
  }

  def partition(a:Array[(String,Int)],p:Int,r:Int) = {
    val x = a(r)._2
    var i = (p-1)
    for(j<-p until r) {
      if(a(j)._2 <= x) {
        i+=1
        exchange(a,i,j)
      }
    }
    exchange(a,i+1,r)
    i+1
  }

  def quicksort(a:Array[(String,Int)],p:Int,r:Int):Unit = {
    if(p<r) {
      val q = partition(a,p,r)
      quicksort(a,p,q-1)
      quicksort(a,q+1,r)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = { for(i <- 1 to n) yield {
      val s = readLine.split(" ")
      (s(0),s(1).toInt)
    } }.toArray
    val org = a.clone
    quicksort(a,0,n-1)
    if(isStable(org,a))  println("Stable") else println("Not stable")
    println(a.map(e=>e._1+" "+e._2).mkString("\n"))
  }
}

Measured memory_bytes: 144884
#include <iostream>
#include <vector>
using namespace std;
int main(void){
	const int MAX=100001;
	int prime[MAX]={};
	int c[MAX]={};
//0が素数
	for(int i=2;i<=100000;i++){
			if(prime[i]==0){
				for(int j=i+i;j<=100000;j+=i){
					prime[j]=1;
				}
			}
	}
	prime[0]=prime[1]=0;

	for(int i=3; i<100000; i+=2){
		if(prime[i]==0 && prime[(i+1)/2]==0){c[i]++;}
	}
	for(int i=3; i<100000; i++){
		c[i]+=c[i-1];
	}

	int n;
	int l, r;
	cin >> n;

	for(int i=0; i<n; i++){
		cin >> l >> r;
		cout << c[r]-c[l-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    vecl A(N);
    REP(i,N) cin >> A[i];
    vecl S(N+1);
    REP(i,N) S[i+1] = S[i] + A[i];
    ll ans = S[N]+1;
    for(int i = 0; i <= N; ++i) {
        chmin(ans,(ll)abs(S[i]-(S[N]-S[i])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
constexpr auto INF = 1000000007;
using namespace std;
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x%y);
}
int lcm(int x, int y) {
    return x / gcd(x, y)*y;
}
int kai(int x) {
    int cnt = 1;
    if (x == 0)return 1;
    cnt = kai(x - 1);
    return x * cnt;
}
int prime(int n) {
    for (int i = 2; i*i <= n; i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}
/*Library End!*/
int n,a[15],ans;
signed main() {
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ans+=a[0]/2;
    for(int i=1;i<n;i++)ans+=a[i];
    cout<<ans<<endl;
}


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


int main() {
    ll x;
    cin>>x;
    ll now=100;
    int count=0;
    while(now<x){
        now*=1.01;
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back
#define INF 10000001

typedef long long int ll;

using namespace std;

int main()
{
    si(d); si(t); si(s);
    long double k=(double)d/(double)s;
    //watch(k);
    if((k*s)<=(s*t))
    {
        cout<<"Yes";
    }
    else    cout<<"No";
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,a,b) for(int i=(a);i>=(b);i--)

using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;

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


  int N;
  int T;
  cin >> N >> T;
  vi A(N);
  rep(i,0,N-1) cin >> A[i];
  int pre = A[0];
  int maxdel = -1;
  int c =1;
  rep(i, 1, N-1) {
    if (pre < A[i]) {
      if (A[i] - pre == maxdel) c++;
      else 
        if (A[i] - pre > maxdel) {
          maxdel = A[i] - pre;
          c = 1;
        }
    }
    pre = min(pre, A[i]);
  }

  cout << c << endl;


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using   namespace std;
const int maxn=2e5+100;
int x2,y2;
long long s;
int main()
{
    while(cin>>s)
    {
        int v=1e9;
        int x2=(v-s%v)%v;
        int y2=(s+x2)/v;
        cout<<"0 0 1000000000 1 "<<x2<<" "<<y2<<endl;
    }
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
string S;
string T;
cin>>S>>T;
bool flag = true;

rep(i,S.length()){
    if(S[i]!=T[i]){
        flag = false;
    }
}
if(flag){
if(S.length() + 1== T.length()){
    cout<<"Yes"<<endl;
}
}
else cout<<"No"<<endl;


return 0;

}

Measured memory_bytes: 3616
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 300004;
int cnth[N], cntw[N], x[N], y[N];
map <int, bool> mp[N];

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h, w, m;
	cin >> h >> w >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
		mp[x[i]][y[i]] = true;
		cnth[x[i]]++, cntw[y[i]]++;
	}
	int mxh = 0, mxw = 0;
	for (int i = 0; i < N; i++) {
		mxh = max(mxh, cnth[i]);
		mxw = max(mxw, cntw[i]);
	}
	vector <int> hall, wall;
	for (int i = 0; i < N; i++) {
		if (cnth[i] == mxh) {
			hall.push_back(i);
		}
		if (cntw[i] == mxw) {
			wall.push_back(i);
		}
	}
	int cnt = 0, mx = 0;
	for (int i = 0; i < hall.size(); i++) {
		for (int j = 0; j < wall.size(); j++) {
			cnt++;
			if (cnt > N * 2)
				break;
			mx = max(mx, mxh + mxw - mp[hall[i]][wall[j]]);
		}
		if (cnt > N * 2)
			break;
	}
	cout << mx;
}


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

int main()
{
    int n,W;
    cin>>n>>W;
    long long int w[n],v[n];
    long long int sum=0;
    for(int i=0;i<n;i++)
    {   
        
        cin>>w[i]>>v[i];
        sum=sum+v[i];
     
    }
    long long int dp[n][sum + 1];
    for(int i=0;i<=sum;i++)
    {
            if(i==v[0])
            {
            dp[0][i]=w[0];
            }
            else{
                dp[0][i]=W+1;
            }
        
    }
    for(int j=0;j<n;j++)
    {
        dp[j][0]=0;
    }
   
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<=sum;j++)
        {   
           if(j<v[i])
           {
               dp[i][j]=dp[i-1][j];
           }
           else{
               dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
           }
          
        }
        
    }
    
   for(int i=sum;i>=0;i--)
   {
       if(dp[n-1][i]<=W)
       {
           cout<<i;
           break;
       }
   }
}

Measured memory_bytes: 81664
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli n,i,w,x,y,j,k,l,wt,v,sum=0;
        cin>>n>>w;
        vector<lli> weight,val;
        for(i=0;i<n;i++)
        {
            cin>>x>>y;
            weight.pb(x);
            val.pb(y);
            sum+=y;
        }
        vector<lli> dp(sum+1,INF);
        dp[0]=0;
        for(i=0;i<n;i++)
        {
            wt=weight[i];
            v=val[i];
            for(j=sum-v;j>=0;j--)
            {
                dp[j+v]=min(dp[j+v],dp[j]+wt);
            }
        }
        lli ans=0;
        for(i=0;i<=sum;i++)
        {
            //what_is(dp[i]);
                if(dp[i]<=w)
                {
                    ans=max(ans,i);
                }
        }
        cout<<ans<<endl;
    }
}


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

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

    string S; cin >> S;
    int ans = 0, res = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
            res++;
        else {
            ans = max(ans, res);
            res = 0;
        }
    }
    ans = max(ans, res);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RADIAN(num) M_PI*(num/180.0)
using namespace std;
typedef complex<double> P;

int n;
P s = P(1, 0);

void exec() {
    double len = abs(s);
    P normalLine = s * P(0, 1);
    normalLine = P(normalLine.real()/len, normalLine.imag()/len);
    s = P(s.real()+normalLine.real(), s.imag()+normalLine.imag());
}

void solve() {
    for(int r = 0; r < n; r++) {
        exec();
    }
}

int main(void) {
    while(cin >> n, n != -1) {
        n--; //処理を行う回数と考える
        solve();
        printf("%.2f\n%.2f\n", s.real(), s.imag());
        s = P(1, 0);
    }
    return(0);
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll MAX = 1100000;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, 1, 0, -1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	repl(i, 2, MAX) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 or k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	COMinit();
	ll n, m, k;
	cin >> n >> m >> k;
	ll ans = 0;
	rep(i, k + 1) {
		ll now = COM(n - 1, i) * modpow(m - 1, n - 1 - i);
		now %= MOD;
		now *= m;
		ans = (ans + now) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 29436
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    moji=list('abcdefghijklmnopqrstuvwxyz')
    c=STR()
    ct=moji.index(c)
    print(moji[ct+1])
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

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

  int n;
  cin >> n;
  int a[n];
  multiset<int> ms;
  rep(i,n){
    cin >> a[i];
    ms.insert(a[i]);
  }
  if(n%2==0){
    rep(i,n){
      int t=i*2+1;
      if(t>n-1) break;
      if(ms.count(t)!=2){
	cout << 0 << endl;
	return 0;
      }
    }
  }
  else{
    if(ms.count(0)!=1){
      cout << 0 << endl;
      return 0;
    }
    rep1(i,n){
      int t=i*2;
      if(t>n-1) break;
      if(ms.count(t)!=2){
	cout <<	0 << endl;
	return 0;
      }
    }
  }
  n=n/2;
  cout <<  pw(2,n) <<endl;
    
  return 0;
    

}


Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if(a > b) {
        out(0);
        re0;
    }

    if(n == 1) {
        if(a != b) {
            out(0);
        }
        else {
            out(1);
        }
        re0;
    }
    
    out(b*(n-1) + a - (a*(n-1) + b) + 1);
    re0;
}

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

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

using namespace std;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(m), b(m);
  rep(i, m) std::cin >> a[i] >> b[i];
  std::map<int, int> map;

  rep(i, m) {
    if (b[i] == n) {
      map[a[i]]++;
    }
  }

  rep(i, m) {
    if (a[i] == 1 && map[b[i]] > 0) {
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }
  }

  std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}


Measured memory_bytes: 13976
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n,m;
    cin >>n >>m;
    int ne = 3*n;
    vector<int> edges[ne+1];
    int s,t;
    rep(i,m){
        int u,v;
        cin >> u >> v;
        rep(i,3){
            edges[u+i*n].push_back(v+((i+1)%3)*n);
        }
    }
    cin >> s >> t;
    int d[ne+1];
    rep(i,ne+1){
        if(i==s)d[i]=0;
        else d[i]=1LL<<30;
    }
    int value = s;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
    do {
        if(!que.empty())que.pop();
        DEBUG{cout << "value " << value << endl;}
        for(auto x:edges[value]){
            if (d[value]+1<d[x]){
                d[x]=d[value]+1;
                que.push(make_pair(d[value]+1,x));
            }
        }
        if(!que.empty()){
        DEBUG{
            cout << "top " << que.top().second << endl;
        }
            value = que.top().second;
        }
    } while(!que.empty());
    cout << ((d[t]==1LL<<30) ? -1 : d[t]/3) << endl; 
    return 0;
}


Measured memory_bytes: 17792
import java.util.HashSet;
import java.util.Scanner;
 
class Main {
	int N;
	String[] s;
	int M;
	String[] t;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		N = sc.nextInt();
		s = new String[N];
		for(int i=0;i<N;i++){
			s[i] = sc.next();
		}
		M = sc.nextInt();
		t = new String[M];
		for(int i=0;i<M;i++){
			t[i] = sc.next();
		}
	}
	void solve(){
		HashSet<String> h = new HashSet<String>(N+M);
		for(int i=0;i<N;i++) h.add(s[i]);
		for(int i=0;i<M;i++) h.add(t[i]);
		int max = 0;
		for(String str:h){
			int cnt = 0;
			for(int i=0;i<N;i++) if(str.equals(s[i])) cnt++;
			for(int i=0;i<M;i++) if(str.equals(t[i])) cnt--;			
			max = Math.max(max, cnt);
		}
		System.out.println(max);
	}
}

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

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

	vector<pair<int, int>> v(N);
	for (int i = 1; i <= N; i++) {
		cin >> v[i - 1].first;
		v[i - 1].second = i;
	}

	sort(v.begin(), v.end());
	for (auto i : v) cout << i.second << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

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

int main(){
	int n;cin>>n;
	VI p(n),a(n);
	rep(i,n){
		cin>>p.at(i);
		a.at(i)=p.at(i);
	}
	sort(all(p));
	int cnt=0;
	rep(i,n){
		if(a.at(i)!=p.at(i))cnt++;
	}
	if(cnt<=2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int i;
	int j;
	
	for(i=0;i<9;i++)
	{
		for(j=0;j<9;j++)
		{
			printf("%dx%d=%d\n",i+1, j+1, (i+1)*(j+1));
		}
	}
    return 0;
}

Measured memory_bytes: 524
N,M = map(int,input().split())
MOD = 10**9+7
from collections import Counter
c = Counter()
m = 2

while(m**2 <= M):
    if M%m == 0:
        while(M%m == 0):
            c[m] += 1
            M //= m
    else:
        m += 1
if M > 1 : c[M] += 1
MAXN = N+100
fac = [0 for _ in range(MAXN)]
inv = [0 for _ in range(MAXN)]
finv = [0 for _ in range(MAXN)]
fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1
for i in range(2,MAXN):
    fac[i] = (i*fac[i-1]) % MOD
    inv[i] = (-inv[MOD%i]*(MOD//i))%MOD
    finv[i] = (finv[i-1]*inv[i])%MOD

def comb(n,k):
    return (fac[n]*(finv[k]*finv[n-k]%MOD))%MOD
ans = 1
for i in c:
    ans *= comb(c[i]+N-1,N-1)
    ans %= MOD
print(ans)

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n;
    string x;
    cin >>n;
    vector<pair<string,int>> m(n);

    rep(i,n){
        string si;
        int ti;
        cin>>si>>ti;
        m[i] = mp(si,ti);
    }
    cin>>x;

    bool f=false;
    rep(i,n){

        if(f)ans += m[i].se;

        if(m[i].fi == x){
            f=true;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, T;
		N = sc.nextInt();
		T = sc.nextInt();
		int[] t = new int[N];
		for (int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
		}

		long sum = T;
		for (int i = 0; i < t.length - 1; i++) {
			sum += Math.min(T, t[i + 1] - t[i]);
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 63000
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	ll n;
	cin >> n;
	vector<ll> a(n+1);
	for(ll x=1; x*x <= n; x++){
		for(ll y=1; y*y<=n; y++){
			for(ll z=1; z*z<=n; z++){
				ll cnt = x*x+y*y+z*z+x*y+y*z+z*x;
				if(cnt > n) continue;
				a[cnt]++;
			}
		}
	}
	loop(i, 1, n+1){
		cout << a[i] << endl;
	}
	return 0;
}


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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll ans=0;
    if(a%2==0 && b%2==0 && c%2==0){
        if(a==b && b==c)    ans = -1;
        else{
            ll ta, tb, tc;
            ans = 1;
            while(1){
                ta=b/2+c/2, tb=a/2+c/2, tc=a/2+b/2;
                if(ta%2 || tb%2 || tc%2) break;
                a = ta; b=tb; c=tc;
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;  
    int main(){
    long long int i,n,j,k,l,gg;
	cin >> n;
	int a[n][3];
	for(i=0;i<n;i++){for(j=0;j<3;j++){cin >> a[i][j];
	}
	}	

	int dp[n][3];
	for(i=0;i<n;i++){for(j=0;j<3;j++){
		if(i==0){
			dp[i][j]=a[i][j];
		}
		else {
			if(j==0){
				dp[i][j]=a[i][j]+max(dp[i-1][j+1],dp[i-1][j+2]);
			}
			else if(j==1){
				dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j+1]);
			}
			else if(j==2){
				dp[i][j]=a[i][j]+max(dp[i-1][j-1],dp[i-1][j-2]);
			}
		}
	}
}
		k= max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
cout << k << '\n';
return 0;	
}


Measured memory_bytes: 2560
/*
coded by : Bissultanov Yedyge;
:)
¤
•
¦
§
*/
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
 
#define mp make_pair
#define np next_permutation
 
#define bg begin()
#define ed end()
 
#define int long long
#define ioi return 0;
 
#define sz size()
#define fix fixed<<setprecision
 
#define lb lower_bound
#define ub upper_bound
 
#define fr first
#define sc second
 
#define pb push_back
#define ppb pop_back
 
#define pf push_front
#define ppf pop_front
 
typedef long double ld;
typedef unsigned long long ull;
 
const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
 
using namespace std;
 
int ans, cnt;
int n , m;
int a[5] , k;

main(){
	ios
		for ( int i = 1 ; i <= 5 ; ++i ){
			cin >> a[i];
		}
		cin >> k;
		for ( int i = 1 ; i <= 5 ; ++i ){
			for ( int j = i+1 ; j <= 5 ; ++j ){
				if ( a[j] - a[i] > k ){
					cout << ":(";
					ioi
				}
			}
		}
		cout << "Yay!";
	ioi	
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = str(input().replace(' ', ''))
q = str(input().replace(' ', ''))

num = []
for i in range(n):
    num.append(i+1)
    
l = itertools.permutations(num)

l2 = []
for i in l:
    youso = ''
    for j in range(n):
        youso += str(i[j])
    l2.append(youso)
    
p_n = l2.index(p)
q_n = l2.index(q)

print(abs(p_n-q_n))

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n; cin >> m >> n;
	vector<string> a(m,string(n,'.')), b = a;
	FOR(i,0,m) FOR(j,0,n) {
		char c; cin >> c;
		if (c == '#') a[i][j] = b[i][j] = '#';
		if (i == 0) a[i][j] = '#';
		else if (i == m-1) b[i][j] = '#';
		else if (j % 2) a[i][j] = '#';
		else b[i][j] = '#';
	}
	FOR(i,0,m) cout << a[i] << endl;
	cout << endl;
	FOR(i,0,m) cout << b[i] << endl;

}


Measured memory_bytes: 1280
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;

void main(string[] args) {
  readln.solve.writeln;
}

auto solve(string line1) {
  auto _ = line1.chomp.split.map!(to!int).array;
  int N = _[0];
  int A = _[1];
  int B = _[2];
  long res = 0;

  foreach(d1; 0..2)
  foreach(d2; 0..10)
  foreach(d3; 0..10)
  foreach(d4; 0..10)
  foreach(d5; 0..10) {
    auto dsum = d1 + d2 + d3 + d4 + d5;
    auto num = 10000*d1 + 1000*d2 + 100*d3 + 10*d4 + d5;
    if (A <= dsum && dsum <= B && num <= N) {
      res += num;
    }
  }

  return res;
} unittest {
  assert(solve("100 4 16") == 4554, "1");
  assert(solve("10 1 2") == 13, "2");
  assert(solve("20 2 5") == 84, "3");
}

Measured memory_bytes: 256
const main = (txt: any): void => {
  const input = txt.split('\n')
  let ans: string = ''
  const [h, w]: number[] = input[0].split(' ').map((i: string) => Number(i))
  for (let i = 1; i <= h; i++) {
    if (i === h) {
      ans += input[i] + '\n'
      ans += input[i]
    }
    else {
      ans += input[i] + '\n'
      ans += input[i] + '\n'
    }
  }
  console.log(ans)
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
score_t = score_h = 0
n = int(input())
for _ in range(n):
    animal_t, animal_h = input().split()
    if animal_t == animal_h:
        score_t += 1
        score_h += 1
    elif animal_t > animal_h:
        score_t += 3
    else:
        score_h += 3

print(score_t, score_h)



Measured memory_bytes: 5596
import java.util.*;
import static java.lang.System.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   if(a == 1 && b ==1){
   	out.println("Draw");
   } else if(a == 1){
     out.println("Alice");
   } else if(b == 1){
     out.println("Bob");
   } else {
     if(a < b){
     	out.println("Bob");
     } else if(a > b){
       out.println("Alice");
     } else{
       out.println("Draw");
     }
   }
 }
  
}

Measured memory_bytes: 23764
N , M = map(int,input().split())
lst = []
AC_list = [False] * N
WA_cnt_list = [0] * N
for _ in range(M):
    r , judge = input().split()
    question_num = int(r) - 1
    if AC_list[question_num]:
        continue
    elif judge == "WA":
        WA_cnt_list[question_num] += 1
    elif judge == "AC":
        AC_list[question_num] = True
wa_cnt = 0
for i in range(N):
    if AC_list[i]:
        wa_cnt += WA_cnt_list[i]
print(sum(AC_list) , wa_cnt)


Measured memory_bytes: 4596