akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define msz 51
void multiply(ll M[msz][msz],ll A[msz][msz],ll sz)
{
	ll c[msz][msz];
	for(ll i=0;i<sz;i++)
	{
		for(ll j=0;j<sz;j++)
		{
			c[i][j]=0;
			for(ll k=0;k<sz;k++)
			c[i][j]=(c[i][j]+(M[i][k]*A[k][j])%mod)%mod;
		}
	}
	
	for(ll i=0;i<sz;i++)
		for(ll j=0;j<sz;j++)
			M[i][j]=c[i][j];
}
void matpow(ll M[msz][msz],ll n,ll sz)
{
	ll A[msz][msz];
	for(ll i=0;i<sz;i++)
		for(ll j=0;j<sz;j++)
			A[i][j]=M[i][j];
			
	if(n>1)
	{
	
		matpow(M,n/2,sz);
		multiply(M,M,sz);
	
		if(n&1)
		multiply(M,A,sz);
	}
}
int main()
{
	sync;
	ll n,k;
	cin>>n>>k;
	ll arr[msz][msz];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<n;j++)
			cin>>arr[i][j];
	
	matpow(arr,k,n);
	
	ll ans=0;
	for(ll i=0;i<n;i++)
		for(ll j=0;j<n;j++)
			ans=(ans+arr[i][j])%mod;
			
	cout<<ans;
}

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

int main() {
  int N, T;
  cin >> N >> T;
  vector<pair<int, int>> ct(N);
  for (int i=0; i<N; i++) {
    cin >> ct.at(i).first >> ct.at(i).second;
  }
  sort(ct.begin(), ct.end());
  int answer = 0;
  for (int i=0; i<N; i++) {
    if (ct.at(i).second <= T) {
      answer = ct.at(i).first;
      break;
    }
  }
  if (answer != 0) {
    cout << answer << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(x:i64));
    if x < 1200 {
        "ABC"
    } else if x < 2800 {
        "ARC"
    } else {
        "AGC"
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1199" => "ABC",
    test2: "1200" => "ARC",
    test3: "4208" => "AGC",
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll N;
    cin >> N;

    if (N % 2 == 0){
        cout << N/2 - 1 << endl;
    }else{
        cout << N/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace _0030
{
    
    class Program
    {

        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            long max = -1;
            long min = (long)Math.Pow(10, 9);

            int tmp = 0;

            for(int i = 0; i < n; i++)
            {
                tmp = int.Parse(str[i]);

                if(tmp > max)
                {
                    max = tmp;
                }
                if(tmp < min)
                {
                    min = tmp;
                }

            }

            Console.WriteLine(max - min);

        }
    }
}

Measured memory_bytes: 11092
N = int(input())
X = list(map(int,input().split()))

a = min(X)
b = max(X)

ans = 1000000

for n in range(a, b + 1):
    sum = 0
    for x in X:
        sum += (x-n)*(x-n)
    ans = min(ans, sum)
print(ans)

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

int main()
{
  int a = 0, b = 0;
  for (int i = 0; i < 3; i++){
    int x; cin >> x;
    if (x == 5) a++;
    if (x == 7) b++;
  }
  
  if (a == 2 && b == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}
    

Measured memory_bytes: 256
open Batteries

let () =
  let h, w = Scanf.scanf "%d %d\n" (fun a b -> a, b) in
  let arr = Array.make h (Array.make w "") in
  for i = 0 to h-1 do
    let str = Scanf.scanf "%s\n" (fun a -> a) in
    let str_list = Str.split (Str.regexp "") str in
    arr.(i) <- (Array.of_list str_list)
  done;

  let res = ref true in

  for i = 0 to h-1 do
    for j = 0 to w-1 do
      if arr.(i).(j) = "#" then (
        let tmp = ref false in
        if i <> 0 then (
          if arr.(i-1).(j) = "#" then tmp := true;
        );
        if i <> h-1 then (
          if arr.(i+1).(j) = "#" then tmp := true;
        );
        if j <> 0 then (
          if arr.(i).(j-1) = "#" then tmp := true;
        );
        if j <> w-1 then (
          if arr.(i).(j+1) = "#" then tmp := true;
        );
        if !tmp = false then res := false
      );
    done;
  done;

  print_endline (if !res then "Yes" else "No")


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	vector<int> V;
	cin>>x;
	FOR(i,x) cin>>y, V.push_back(y);
	sort(ALL(V));
	cout<<V.back()-V[0]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N (200005)
#define int long long
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define CM cerr<<(&MOP2-&MOP1)/1024.0/1024.0<<endl
using namespace std;
template <class T> inline T Min(T x, T y){
    return x<y?x:y;
}
template <class T> inline T Max(T x, T y){
    return x>y?x:y;
}
bool MOP1;
char a[100005],b[100005];
int t[100005][30];
int ans;
bool MOP2;
signed main(){
	scanf("%s%s",a,b);
	int n=strlen(a);
	int m=strlen(b);
	for(int i=0;i<26;i++)t[n][i]=n;
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<26;j++)t[i][j]=t[i+1][j];
		t[i][a[i]-'a']=i;
	}
	for(int i=0;i<m;i++)if(t[0][b[i]-'a']==n){
		puts("-1");
		return 0;
	}
	int cnt=0;
	while(cnt<m){
		int now=0;
		while(t[now][b[cnt]-'a']<n){
			now=t[now][b[cnt]-'a']+1,cnt++;
			if(cnt==m){
				printf("%lld",now+ans*n);
				return 0;
			}
		}
		ans++;
	}
	return 0;
}




Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll n,k;
		cin >> n >> k;
		string s;
		cin >> s;
		ll i = k-1;
		if(s[i]=='A')
		{
			s[i] = 'a';
		}
		if(s[i]=='B')
		{
			s[i] = 'b';
			
		}
		if(s[i] == 'C')
		{
			s[i] = 'c';
		}
		cout << s << endl;
		
		
				
	}
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int n, nrfin;

int nrdiv(int x) {
    int div = 2;
    int rez = 2;
    for (; div * div < x; div++)
        if (!(x % div))
            rez += 2;
    if (div * div == x)
        rez++;
    return rez;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    FOR(i, 1, n + 1, 2)
        if (nrdiv(i) == 8)
            nrfin++;
    cout << nrfin;
}

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

vector<vector<char>> sett = {
  {'.', ',', '!', '?', ' '},
  {'a', 'b', 'c'},
  {'d', 'e', 'f'},
  {'g', 'h', 'i'},
  {'j', 'k', 'l'},
  {'m', 'n', 'o'},
  {'p', 'q', 'r', 's'},
  {'t', 'u', 'v'},
  {'w', 'x', 'y', 'z'}
};


int main(){
  int N; cin >> N;
  vector<string> anss;
  for(int i = 0 ; i < N ; i++){
    string inp; cin >> inp;
    string ans;
    int count = 0;
    int pre = 0;
    for(int j = 0 ; j < inp.size(); j++){
      if(inp[j] == '0'){
        if(count == 0) continue;
        ans.push_back(sett[pre-1][(count-1)%sett[pre-1].size()]);
        count = 0;
      }
      else{
        pre = inp[j] - '0';
        count++;
      }
    }
    anss.push_back(ans);
  }
  for(int i = 0 ; i < N ; i++){
      cout << anss[i] << endl;
  }
}



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

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

#define MOD 1000000007

int main(){
	ll N;
	cin >> N;
	ll x[N+5],ans[N+5];
	memset(ans,0,sizeof ans);
	for(int i=1;i<=N;i++){
		x[i] = i;
	}
	for(int i=2;i<=N;i++){
		for(int j=1;j<=N;j++){
			while(x[j] != 1 && x[j] % i == 0){
				ans[i]++;
				x[j] /= i;
			}
		}
	}
	ll hit = 1;
	for(int i=1;i<=N;i++){
		hit = hit * (ans[i] + 1);
		hit %= MOD;
	}
	cout << hit << "\n";
	//ll ans = 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;
using u64 = std::uint_fast64_t;

void solve(void){

  llint n, k;
  std::cin >> n >> k;

  std::vector<llint> A(n);
  llint longest = 0;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
    longest = std::max(longest, A[i]);
  }

  llint st = 0;
  llint ed = longest;
  while(st < ed-1){
    //std::cout << st << " " << ed << std::endl;
    llint mid = (ed+st)/2;
    llint cnt = 0;
    for(int i=0; i<n; i++){
      //std::cout << cnt << " & " << A[i] << std::endl;
      cnt += (A[i]-1)/mid;
    }
    if(k<cnt) st = mid;
    else      ed = mid;
  }

  llint cnt = 0;
  for(int i=0; i<n; i++){
    cnt += (A[i]-1)/ed;
  }
  if(k>=cnt) std::cout << ed << std::endl;
  else       std::cout << st << std::endl;
  
}
int main(void){
  solve();
  return 0;
}





Measured memory_bytes: 4764
pn=[2];A=2000
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)

ans = []
n = int(input())
for i in range(len(pn)):
  if str(pn[i])[-1]=="1":
    ans.append(pn[i])
  if len(ans)==n:
    break
print(str(ans).replace("[","").replace("]","").replace(",",""))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){

	int a, b;
	cin >> a >> b;

	for (int i = a-1; i >= 0; i--)
		cout << b - i << " ";

	for (int i = 1; i < a; i++)
		cout << b + i << " ";
	cout << endl;

	return 0;
}


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

int n, k, r, s, p, ans, sc[150], v[100005];
string a;
int main() {
	int i;
	cin>> n>> k>> sc['s']>> sc['p']>> sc['r']>> a;
	for(i=0; i<k; i++) ans += sc[a[i]], v[i] = 1;
	for(; i<n; i++) {
		if(!v[i-k] || a[i] != a[i-k]) ans += sc[a[i]], v[i] = 1;
	}
	cout<< ans;
	return 0;
}

Measured memory_bytes: 896
import sys
n = [0 for i in range(3)]
for i in range(3):
    n[i] = [int(i) for i in input().split()]

b = n[0]
a = [0, n[1][0]-b[0], n[2][0]-b[0]]
for i in range(1, 3):
    for j in range(1, 3):
        if a[i]+b[j] != n[i][j]:
            print('No')
            sys.exit()

print('Yes')






Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    ll x;
    cin >> x;
    ll q = x / 11;
    ll r = x % 11;
    ll res = 2 * q;
    if (r > 0)
        ++res;
    if (r > 6)
        ++res;
    cout << res << endl; 

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    
    if(10%p==0){
        ll ans = 0;
        rep(i,n){
            if( (s[i]-'0') % p == 0 ){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    int ten = 1;
    for(int i=n-1;i>=0;i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1]+a)%p;
        ten *= 10; ten %= p;
    }
    vector<int> cnt(p);
    ll ans = 0;
    for(int i=n;i>=0;i--){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;
}

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

int main() {
  unsigned long N,A,B;
  cin >> N >> A >> B;
  
  unsigned long i = 0;
  unsigned long c = 0;
  c = B-A;
  if(c%2 == 0){
    i = c/2;
  }
  else{
    i = (c + 1)/2 + min(N-B, A-1);
  }
  
  cout << i;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}









int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int sum=0;
  for(int i=0;i<=N;i++){
    int summ=0;
    int NN=i;
    while(NN>0){
      summ+=NN%10;
      NN/=10;
    }
    if(summ>=A&&summ<=B){
    sum+=i;}
  }
  cout<<sum<<endl;



  

  


  

    


  

  
  
  
  
}


  
  

  

  




Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

  int weight[N+1],value[N+1];

  for(int i = 1 ; i<=N; i++)
  {
    cin>>weight[i]>>value[i];
  }

  long long dp[N+1][W+1] = {0};

  for(int i = 0 ; i<=N ; i++)
  {
    for(int j = 0 ; j<=W; j++)
    {
      dp[i][j] = 0;
    }

  }

  for(int i = 1 ; i<=N ; i++)
  {
    for(int j = 1 ; j<=W ; j++)
    {
      dp[i][j] = dp[i-1][j];
      if(j - weight[i] >= 0)
      {
        dp[i][j] = max(dp[i][j] , value[i] + dp[i-1][j - weight[i]]);
      }
    }
  }
  
  /*for(int i = 0 ; i<=N ; i++)
  {
    for(int j = 0 ; j<=W; j++)
    {
      cout<<dp[i][j]<<" ";
    }

    cout<<endl;
  }*/


  //cout<<endl;

  cout<<dp[N][W];
  
  return 0;
}

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

void main()
{
    auto N = readln.chomp.to!int;
    auto js = new int[](N);
    foreach (a; readln.split.to!(int[])) ++js[a-1];
    foreach (j; js) writeln(j);
}

Measured memory_bytes: 10848
#include <iostream>
#include <vector>
#include <memory>

template <class Key>
class BinarySearchTree {
    struct Node {
        bool isvalid;  // falseなら空Node
        Key key;

        std::unique_ptr<Node> lch, rch;
        Node() : isvalid(false), key(0) {}
    };
    using pNode = std::unique_ptr<Node>;

private:
    pNode root;

    // keyを持つNodeのポインタを返す
    // なければkeyを持つべき空Nodeのポインタを返す
    pNode& search(Key key, pNode& node) {
        if (!node->isvalid) return node;
        if (key == node->key) return node;
        return search(key, (key < node->key ? node->lch : node->rch));
    }

    void dfs(int type, pNode& node, std::vector<Key>& v) {
        if (!node->isvalid) return;

        if (type < 0) v.push_back(node->key);
        dfs(type, node->lch, v);
        if (type == 0) v.push_back(node->key);
        dfs(type, node->rch, v);
        if (type > 0) v.push_back(node->key);
    }

public:
    explicit BinarySearchTree() : root(new Node()) {}

    void insert(Key key) {
        pNode& node = search(key, root);
        if (node->isvalid) return;

        node->isvalid = true;
        node->key = key;
        node->lch.reset(new Node());
        node->rch.reset(new Node());
    }

    // type < 0 : 行きがけ順
    // type = 0 : 通りがけ順
    // type > 0 : 帰りがけ順
    std::vector<Key> tour(int type) {
        std::vector<Key> ret;
        dfs(type, root, ret);
        return ret;
    }
};

int main() {
    int Q;
    std::cin >> Q;

    BinarySearchTree<int> bst;
    for (int q = 0; q < Q; ++q) {
        std::string type;
        std::cin >> type;

        if (type == "insert") {
            int key;
            std::cin >> key;
            bst.insert(key);
        } else {
            auto in = bst.tour(0);
            for (auto k : in) std::cout << " " << k;
            std::cout << std::endl;

            auto pre = bst.tour(-1);
            for (auto k : pre) std::cout << " " << k;
            std::cout << std::endl;
        }
    }
    return 0;
}



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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), ab(n);
    rep(i, n){
        cin >> a[i] >> b[i];
        ab[i] = b[i] - a[i]%b[i];
    }
    reverse(ab.begin(), ab.end());
    ll ans = 0;
    rep(i, n){
        if(i > 0) ab[i] = b[n-1-i] - (a[n-1-i]+ans)%b[n-1-i];
        if(ab[i] != b[n-1-i] && b[n-1-i] > 1) ans += ab[i];
    }
    
    //rep(i, n) cout << a[i] << " "; cout << endl;
    //rep(i, n) cout << b[i] << " "; cout << endl;
    //for(ll i = n-1; i >= 0; --i) cout << ab[i] << " "; cout << endl;

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

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

#define fi first
#define se second

const int N = 100100;
const int mod = 1e9 + 7;

using namespace std;

int n;
int a[N];

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        for(int i = 1; i <= n; i++){
                int x;
                cin >> x;
                a[x] += 1;
        }
        int res = 0;
        for(int i = 2; i < N; i++){
                res = max(res, a[i] + a[i - 1] + a[i - 2]);
        }
        cout << res << "\n";
}


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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e5 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int n;
int a[N], f[N][3];

void upd(int &x, int y) { x = max(x, y); }
signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 0, n) FOR(j, 0, 2) f[i][j] = -oo;

    f[0][1] = 0;
    f[1][1] = 0;
    f[1][2] = a[1];
    FOR(i, 2, n) {
        if(i % 2 == 0)  {
            if(f[i - 2][0] > -oo) upd(f[i][0], f[i - 2][0] + a[i]);
            upd(f[i][0], f[i - 1][1]);
            // f[i][1]
            if(f[i - 2][1] > -oo) upd(f[i][1], f[i - 2][1] + a[i]);
            upd(f[i][1], f[i - 1][2]);
        } else {
            if(f[i - 2][1] > -oo) upd(f[i][1], f[i - 2][1] + a[i]);
            upd(f[i][1], f[i - 1][1]);
            // f[i][2]
            if(f[i - 2][2] > -oo) upd(f[i][2], f[i - 2][2] + a[i]);
        }
        //cout << i << ' ' << f[i][0] << ' ' << f[i][1] << ' ' << f[i][2] << '\n';
    }
    cout << f[n][1];
}


Measured memory_bytes: 9916
import os
from collections import Counter, defaultdict

import sys

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
C = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

color_counts = [defaultdict(int) for _ in range(N + 1)]
for c in range(1, N + 1):
    color_counts[c][0] = N
color_v_weights = [[] for _ in range(N + 1)]
color_v = [0 for _ in range(N + 1)]
color_v_next = [1 for _ in range(N + 1)]


# color_parents = [[] for _ in range(N + 1)]
# color_stack = [[] for _ in range(N + 1)]
# children_counts = defaultdict(int)


def dfs(v, p):
    color = C[v]
    color_v_prev = color_v[color]

    children_cv = []
    ret = 1
    for u in graph[v]:
        if u == p:
            continue
        cv = color_v_next[color]
        children_cv.append(cv)
        color_v[color] = cv
        color_v_next[color] += 1
        cnt = dfs(u, v)
        ret += cnt
        color_counts[color][cv] += cnt
    color_v[color] = color_v_prev
    color_counts[color][color_v_prev] -= ret
    return ret


dfs(0, None)
counter = Counter(C)

for color, cc in enumerate(color_counts[1:], start=1):
    ans = N * (N - 1) // 2 + counter[color]
    for cnt in cc.values():
        ans -= cnt * (cnt - 1) // 2
    print(ans)


Measured memory_bytes: 444804
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;
int main() {
  int H,W,Ch,Cw,Dh,Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  vector<vector<bool>> S(H,vector<bool>(W));
  int i,j;
  char c;
  for(i=0;i<H;i++)for(j=0;j<W;j++) {
    cin >> c;
    S[i][j] = (c=='.');
  }
  vector<vector<int>> d(H,vector<int>(W,2000000000));
  priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> q;
  d[Ch-1][Cw-1] = 0;
  q.push(pair<int,pair<int,int>>(0,pair<int,int>(Ch-1,Cw-1)));
  while(!q.empty()) {
    pair<int,pair<int,int>> p = q.top();
    q.pop();
    if(d[p.second.first][p.second.second] < p.first || !S[p.second.first][p.second.second])continue;
    else {
      if(0<=p.second.first+1 && p.second.first+1<H && 0<=p.second.second && p.second.second<W)if(S[p.second.first+1][p.second.second] && d[p.second.first+1][p.second.second] > d[p.second.first][p.second.second]) {
        d[p.second.first+1][p.second.second] = d[p.second.first][p.second.second];
        q.push(pair<int,pair<int,int>>(d[p.second.first+1][p.second.second],pair<int,int>(p.second.first+1,p.second.second)));
      }
      if(0<=p.second.first-1 && p.second.first-1<H && 0<=p.second.second && p.second.second<W)if(S[p.second.first-1][p.second.second] && d[p.second.first-1][p.second.second] > d[p.second.first][p.second.second]) {
        d[p.second.first-1][p.second.second] = d[p.second.first][p.second.second];
        q.push(pair<int,pair<int,int>>(d[p.second.first-1][p.second.second],pair<int,int>(p.second.first-1,p.second.second)));
      }
      if(0<=p.second.first && p.second.first<H && 0<=p.second.second+1 && p.second.second+1<W)if(S[p.second.first][p.second.second+1] && d[p.second.first][p.second.second+1] > d[p.second.first][p.second.second]) {
        d[p.second.first][p.second.second+1] = d[p.second.first][p.second.second];
        q.push(pair<int,pair<int,int>>(d[p.second.first][p.second.second+1],pair<int,int>(p.second.first,p.second.second+1)));
      }
      if(0<=p.second.first && p.second.first<H && 0<=p.second.second-1 && p.second.second-1<W)if(S[p.second.first][p.second.second-1] && d[p.second.first][p.second.second-1] > d[p.second.first][p.second.second]) {
        d[p.second.first][p.second.second-1] = d[p.second.first][p.second.second];
        q.push(pair<int,pair<int,int>>(d[p.second.first][p.second.second-1],pair<int,int>(p.second.first,p.second.second-1)));
      }
      for(i=-2;i<3;i++)for(j=-2;j<3;j++) {
        if(0<=p.second.first+i && p.second.first+i<H && 0<=p.second.second+j && p.second.second+j<W)if(S[p.second.first+i][p.second.second+j] && d[p.second.first+i][p.second.second+j] > d[p.second.first][p.second.second] + 1) {
          d[p.second.first+i][p.second.second+j] = d[p.second.first][p.second.second]+1;
          q.push(pair<int,pair<int,int>>(d[p.second.first+i][p.second.second+j],pair<int,int>(p.second.first+i,p.second.second+j)));
        }
      }
    }
  }
  cout << (d[Dh-1][Dw-1]<2000000000?d[Dh-1][Dw-1]:-1) << endl;
}

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
  int a,b;
cin >> a >> b; 
cout << a+b/2;
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
c = Counter(S)
max = 0
for s in set(S):
  if max < c[s]:
    max_words = [s]
    max = c[s]
  elif max == c[s]:
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))


Measured memory_bytes: 44264
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
long long inf = 1e18;
int main()
{
  int n ;
  cin >> n;
  vector<ll> a(n);
  
  for(int i =0;i<n;i++)
    cin >> a[i];
  
  vector<ll> prefix(n+1,0);
  
  for(int i = 1;i<=n;i++)
    prefix[i] = prefix[i-1] + a[i-1];
      
  vector<vector<long long int>> dp(n,vector<long long int>(n,0));

  for(int l = 2; l <= n; l++)
  {
    int i = 0;
    int j = i+l-1;
    while(j<n)
    {
      dp[i][j] = inf;
      for(int k = i;k < j;k++)
      {
            dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k+1][j]) ;
      }
      dp[i][j] +=  (prefix[j+1] - prefix[i]);
      i++;j++;
    }
  }

  cout << dp[0][n-1] << endl;  
  
  return 0;
}


Measured memory_bytes: 4884
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};


int dig(int a){
  int r=0;
  while(a!=0){
    int xp=a%10;
    a/=10; if(xp==1) ++r;
  }
  return r;
}

int fact[2000005];
int infact[2000005];

int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}

int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}

void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}

int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}
void q1(){
  string s; cin>>s;
  if(s>="a" && s<="z") cout<<"a";
  else cout<<"A";
}
void q2(){
  int n,k; cin>>n>>k;
  int a[n]; f(i,0,n) cin>>a[i];
  sort(a,a+n);
  int s=0;
  f(i,0,k)s+=a[i];
  cout<<s;
}
void q3(){
  string ret="";
  int a; cin>>a;
  while(a!=0){
    a--;
    ret+=(a%26 +'a');
    a/=26;
  }
  reverse(ret.begin(),ret.end());
  cout<<ret;
}
void q4(){
  int n; cin>>n;
   int a[100005]={0};
   int s=0;
  f(i,0,n){
    int x; cin>>x;
    s+=x;
    a[x]++;
  }
  int q; cin>>q;
  while(q--){
    int b,c; cin>>b>>c;
    s-=a[b]*b;
    s+=a[b]*c;
    a[c]+=a[b];
    a[b]=0;
    cout<<s<<"\n";
  }
 
}
void q5(){
  int n; cin>>n;
  int x=0;
  int a[n]; f(i,0,n){
    cin>>a[i];
    x^=a[i];
  } 
   f(i,0,n) cout<<(x^a[i])<<" ";
}
int32_t main(){
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  q4();
  return 0;
  facto();
  int k; cin>>k;
  string s; cin>>s;
  int l=k+s.size();
  int xp=s.size();
  // total = 26^l - those which do not contain subsequence
  // --- i= 0 to  xp-1 prefix present as subseqeunce and remaining have 25^(l-i)
  int ret=1;
  f(i,0,l){
    ret*=26; ret%=mod;
  }
  int sub=0;

  f(i,0,xp){
    // l choose i
    sub+= (nck(l,i)*po(25,l-i));
    sub%=mod; 
  }

  cout<<((ret-sub)%mod + mod) %mod <<"\n";
  return 0;
}


Measured memory_bytes: 4420
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
resH = [True] * H
resW = [True] * W

for h in range(H):
    judge = False
    for w in range(W):
        if a[h][w] == "#":
            judge = True
    resH[h] = judge

for w in range(W):
    judge = False
    for h in range(H):
        if a[h][w] == "#":
            judge = True
    resW[w] = judge

for h, row in enumerate(a):
    tmp = []
    for w, element in enumerate(row):
        if resH[h] and resW[w]:
            tmp.append(element)
    if tmp:
        print(*tmp, sep="")


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++) 
#define E "\n"

int solve()
{
	int k;
	string s;
	cin >> k >> s;
	if(s.size()<=k) cout<<s<<E;
	else
	{
		f(i,0,k) cout<<s[i];
		cout<<"...";
	}
	return 0;	
}


int32_t main()
{
     int t = 1;
    // cin >> t;
     while(t--)
     {
          solve();
     }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    double tmp = log(n) / log(3);
    int ans = tmp;
    if (n > pow(3, ans)) ans++;
    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    string str;
    cin>>n>>str;
    int cntr=0,cntl=0;
    for(int i=0;i<n;i++){
        if(str[i]=='R'){
            cntr++;
        }
    }
    for(int i=0;i<cntr;i++){
        if(str[i]=='W'){
            cntl++;
        }
    }
    printf("%d",cntl);
    return 0;
}


Measured memory_bytes: 3812
import java.util.Scanner;

public class Main {

	// 2点間を通る直線の傾きを求める
	public static double getA (double x1, double y1, double x2, double y2) {
		if (x1 == x2) return Double.MAX_VALUE;
		return (y2 - y1) / (x2 - x1);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for (int i = 0; i < n; i++) {
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			double x4 = sc.nextDouble();
			double y4 = sc.nextDouble();
			double a = getA(x1,y1,x2,y2);
			double b = getA(x3,y3,x4,y4);
			System.out.println(Math.abs(a - b) < 0.0000001 ? "YES" : "NO");
		}

	}

}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<bool> ten(n);
	bool iszero = true;
	int count=0;
	for(int i = 0; i < n;  i++) {
		cin >> a[i];
		if(a[i] % 10 == 0) {
			ten[i] = true;
		} else {
			iszero = false;
		}
		count += a[i];
	}
	if(iszero) {
		printf("0\n");
		return 0;
	}
	if(count % 10 != 0 ) {
		printf("%d\n", count);
		return 0;
	}
	int min = 999;
	for(int i = 0; i < n; i++) {
		if(ten[i] == true)
			continue;
		if(min > a[i])
			min = a[i];
	}
	printf("%d\n", count - min);
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  ll ans = 0;
  map<ll, ll> m;
  for (int i = n-1; i >= 0; i--){
    ans += m[a[i] + i];
    m[i - a[i]]++;
  }

  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 27388
#include <iostream>
#include <string>
#include <stack>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
  char s[256],c ;
  string st;
  int len, i;
  stack<char> stack;

  while( true ){
    fgets( s,255,stdin );
    st = s;
    len = st.length();
    if( st[len-1]=='\n' ) st[--len]='\0';

    if( len==1 && st[0]=='.' ) break;
    //    cout << st << endl;

    while( !stack.empty() ) stack.pop();

    for( i=0;i<len;i++ ){
      c = st.at(i);
      switch( c ){
      case '(':
      case'[': stack.push( c ); break;
      case ')':
	if( stack.empty() ){
	  stack.push( c );	  i=len;
	}else{
	  if( stack.top()=='(' ) stack.pop();
	  else i=len;
	}
	break;
      case ']':
	if( stack.empty() ){
	  stack.push( c );	  i=len;
	}else{
	  if( stack.top()=='[' ) stack.pop();
	  else i=len;
	}
	break;
      default :
	break;
      }
    }

    if( stack.empty() ) cout << "yes"<<endl;
    else         cout << "no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
T = [0] + [int(x) for x in input().split()]
M = int(input())
s = sum(T)
 
answer = []
for _ in range(M):
  a,b = map(int,input().split())
  answer.append(s+b-T[a])
 
print(*answer,sep='\n')

Measured memory_bytes: 3064
#include<stdio.h>
int n,m;
int i,j,k;
int Map[205][205];
int F[410][205][205];
int Max(int a,int b,int c,int d)
{
    if(a>=b&&a>=c&&a>=d)
        return a;
    if(b>=a&&b>=c&&b>=d)
        return b;
    if(c>=a&&c>=b&&c>=d)
        return c;
    if(d>=a&&d>=b&&d>=c)
        return d;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
            scanf("%d",&Map[i][j]);
    int res = Map[1][1] + Map[n][m];
    Map[1][1] = Map[n][m] = 0;
    for(k=1;k<=n+m-2;k++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if(i==n&&j==n&&k==n+m-2)
                    F[k][i][j]=Max(F[k-1][i-1][j],F[k-1][i][j-1],F[k-1][i][j],F[k-1][i-1][j-1])+Map[i][k+2-i]+Map[j][k+2-j];
                else  if(i!=j&&k+2-i>=1&&k+2-j>=1)
                    F[k][i][j]=Max(F[k-1][i-1][j],F[k-1][i][j-1],F[k-1][i][j],F[k-1][i-1][j-1])+Map[i][k+2-i]+Map[j][k+2-j];
    printf("%d\n",F[n+m-2][n][n] + res);
    return 0;
}


Measured memory_bytes: 49792
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc135/tasks/abc135_c
 */
public class Main {

  private static long answer(long[] mons, long[] heroes) {
    long remain = mons[0];
    long sum = 0;
    for (int i = 0; i < heroes.length; i++) {
      long killed = Math.min(heroes[i], remain);
      long killed2 = Math.min(heroes[i] - killed, mons[i + 1]);
      remain = mons[i + 1] - killed2;
      sum += killed + killed2;
    }

    return sum;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] mons = new long[n+1];
    long[] heroes = new long[n];
    for (int i = 0; i < n + 1; i++) {
      mons[i] = scan.nextInt();
    }
    for (int i = 0; i < n; i++) {
      heroes[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(mons, heroes));
  }
}


Measured memory_bytes: 85220
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, k, y, x;
    cin >> n >> k >> y >> x;
    
    ll sum = 0;
    if(n > k) sum = k*y + (n-k)*x;
    else sum = n*y;

    cout << sum << endl;
    
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int cost[1100][1100];
int main()
{
	int H, W;
	cin >> H >> W;
	int sh, sw, gh, gw;
	cin >> sh >> sw >> gh >> gw;
  sh--;sw--;gh--;gw--;
	char field[1100][1100];
	fx(H) {
		string s;
		cin >> s;
		fy(W) {
			field[x][y] = s[y];
		}
	}
	fx(H) {
		fy(W) {
			cost[x][y] = INT_MAX;
		}
	}
	cost[sh][sw] = 0;
	priority_queue<pair<int,pair<int, int>>> Q;
	Q.push(make_pair(0,make_pair(sh,sw)));
	while (Q.size()) {
		auto q = Q.top(); Q.pop();
		int x = q.second.first, y = q.second.second;
      	if(cost[x][y]<-q.first){continue;}

		if (x+1<H&&field[x+1][y] == '.'&& cost[x + 1][y] > cost[x][y]) {
			cost[x + 1][y] = cost[x][y];
			Q.push(make_pair(-cost[x+1][y],make_pair(x+1, y)));
		}
		if (x - 1 >= 0 && field[x - 1][y] == '.'&& cost[x - 1][y] > cost[x][y]) {
			cost[x - 1][y] = cost[x][y];
			Q.push(make_pair(-cost[x-1][y],make_pair(x-1, y)));
		}
		if (y + 1 < W && field[x][y + 1] == '.'&& cost[x ][y + 1] > cost[x][y]) {
			cost[x][y + 1] = cost[x][y];
			Q.push(make_pair(-cost[x][y + 1],make_pair(x, y + 1)));
		}
		if (y - 1 >= 0 && field[x][y - 1] == '.'&& cost[x][y - 1] > cost[x][y]) {
			cost[x][y - 1] = cost[x][y];
			Q.push(make_pair(-cost[x][y - 1],make_pair(x, y - 1)));
		}
        for (int i = -2; i <= 2;i++) {
			for (int j = -2; j <= 2;j++) {
				if (x+i>=0&&x+i<H && y+j>=0&& y+j<W && field[x+i][y+j]=='.') {
					if (cost[x+i][y+j]>cost[x][y]+1) {
						cost[x + i][y+ j] = cost[x][y]+1;
						Q.push(make_pair(-cost[x + i][y+ j],make_pair(x + i, y + j)));
					}
				}
			}
		}
	}

	if (cost[gh][gw]==INT_MAX) {
		ce(-1)
	}
	else {
		ce(cost[gh][gw])
	}

    return 0;
}



Measured memory_bytes: 8996
#include <stdio.h>
int abs(int n){
		if(n<0){
		return -1*n;}else
		return n;}
int main(void)
{int N,A,M,B,x,i,k,l,m,flag,sum;
	scanf("%d",&N);
	int a[100000];
	int b[100000];
	int c[50];
	int d[50];
	int tmp[50];
	b[0]=1;
	flag=0;
	for(i=0;i<=N-1;i++){
		scanf("%d",&a[i]);}
	
	for(x=0;x<=N-1;x++){
		b[x+1]=a[b[x]-1];}
	for(k=1;k<=N;k++){
		if(b[k]==2){
			flag=1;
			sum=k;
			break;}}
if(flag==1)
printf("%d",k);
else
printf("-1");



	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
int main(void){
    char a[202],b[101],c[101];
    int i;
     
    scanf("%s",a);
    scanf("%s",b);
    for(i=0;a[i] != '\0';i++)
        c[i] = a[i];
    strcat(a,c);
    if(strstr(a,b)!=NULL)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}
 

Measured memory_bytes: 532
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

vll C(600), S(600), F(600);
ll N;

ll calc(ll start)
{
        ll now = 0;
        rep(i, start, N-1) {
                if (now < S[i]) now = S[i];
                if (now % F[i] != 0) {
                        now += F[i] - (now%F[i]);
                }
                now += C[i];
        }
        return now;
}

int main()
{
        cin >> N;
        rep(i, 0, N-1) cin >> C[i] >> S[i] >> F[i];
        
        rep(i, 0, N) {
                cout << calc(i) << endl;
        }
}

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

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;

		vector<pair<string, string> > table(n);
		for(int i=0; i<n; i++){
			cin >> table[i].first >> table[i].second;
		}

		sort(table.begin(), table.end());

		int ans = 0;
		for(int i=0; i<table.size(); i++){
			string end = table[i].second;
			ans++;
			for(int j=i+1; j<table.size(); j++){
				if(end <= table[j].first){
					end = table[j].second;
					table.erase(table.begin()+j);
					j--;
				}
			}
		}
		cout << ans << endl;
	}
}


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

int main()
{
	// 入力
	int a, b;
	cin >> a >> b;

	int ans = a * b;



	// 出力
	cout << ( ans & 0x01 ? "Odd" : "Even" ) << endl;

	return 0;
}

Measured memory_bytes: 256