akhauriyash/Code-Regression huggingface dataset:
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    if (a < 10 && b < 10) {
      System.out.println(a * b);
    } else {
      System.out.println(-1);
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 24660
use std::collections::HashMap;

const MOD: i64 = 1000000007;


fn main() {
    let comb = Comb::new(1e5 as usize + 100, MOD);
    let (n, m) = read_tuple::<i64>();

    let fact = prime_factorize(m);

    let mut ans:i64 = 1;
    for (_p, count) in fact.iter() {
        ans *= comb.nck((count + n - 1) as usize, *count as usize);
        ans %= MOD;

    }
    println!("{:?}", ans);

}

fn prime_factorize(n: i64) -> HashMap<i64, i64> {
    let mut x = n;
    let mut res = HashMap::new();
    let mut is_prime = vec![true; n as usize + 1];

    let mut i = 2;
    while i * i <= n && x != 1 {
        if is_prime[i as usize] && x % i == 0 {
            let mut count = 0;
            while x % i == 0 {
                count += 1;
                x /= i;
            }
            res.insert(i, count);

            let mut j = 2;
            while i * j <= n {
                is_prime[(i * j) as usize] = false;
                j += 1;
            }
        }
        i += 1;
    }

    if x != 1 {
        res.insert(x, 1);
    }
    res
}


/// for nCk
pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}

impl Comb {
    /// initialize table 
    /// max: maximum that n as nCk takes
    /// m: MOD, a prime number
    /// O(n)
    pub fn new(max: usize, m: i64) -> Comb {
        let n = max;
        let mut fac = Vec::with_capacity(n);
        fac.push(1);
        fac.push(1);
        let mut finv = Vec::with_capacity(n);
        finv.push(1);
        finv.push(1);
        let mut inv = Vec::with_capacity(n);
        inv.push(1);
        inv.push(1);

        for i in 2..n {
            let i = i as i64;
            let new_fac = fac.last().unwrap() * i % m;
            fac.push(new_fac);
            let new_inv = m - inv[(m % i) as usize] * (m / i) % m;
            inv.push(new_inv);
            let new_finv = finv.last().unwrap() * inv.last().unwrap() % m;
            finv.push(new_finv);
        }

        Comb {
            max: max,
            m: m,
            fac: fac,
            finv: finv
        }
    }

    /// nCk
    pub fn nck(&self, n: usize, k: usize) -> i64 {
        // since n, k are usize, do not need to check `n < 0 || k < 0`
        if n < k || n > self.max {
            panic!("Invalid query (n, k) = ({}, {})", n, k);
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m
        }
    }
}



fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}


Measured memory_bytes: 983292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,a[N][N],s[N][N],l[N][N],r[N][N];
ll ans;
char ch[N];
void del(int x,int y){
	for (int i=y;i<=n;i++) s[x][i]-=a[x][y];
	a[x][y]=0;
	if ((a[x][y+1])&&(!a[x-1][y+1])) del(x,y+1);
	if ((a[x+1][y])&&(!a[x+1][y-1])) del(x+1,y);
}
void chkmin(int &x,int y){if (x>y) x=y;}
void chkmax(int &x,int y){if (x<y) x=y;}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		scanf(" %s",ch+1);
		for (int j=1;j<=n;j++)
		a[i][j]=(ch[j]=='#') ? 0 : (ch[j]-'0'),s[i][j]=s[i][j-1]+a[i][j];
	}
	memset(l,0x3f,sizeof(l));
	for (int i=n;i;i--)
	for (int j=n;j;j--)
	if (a[i][j]){
		int t=-a[i][j];
		l[j][i]=r[j][i]=j;
		if (a[i][j+1]) for (int x=i;x<=n;x++){
			chkmin(l[j][x],l[j+1][x]);chkmax(r[j][x],r[j+1][x]);
			if (l[j][x]<=r[j][x]) t+=s[x][r[j][x]]-s[x][l[j][x]-1];else break;
		}
		else for (int x=i;(x<=n)&&(l[j][x]<=r[j][x]);x++)
			t+=s[x][r[j][x]]-s[x][l[j][x]-1];
		ans+=a[i][j]*t;
		if (a[i-1][j]+a[i][j-1]==0) del(i,j);
	}
	else{memset(l[j]+i,0x3f,(n-i+1)*4);memset(r[j]+i,0,(n-i+1)*4);}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 35712
fun main() {
    val n = readLine()?.toLong() ?: return
    val musts = listOf('7', '5', '3')
    val digits = n.toString().length
    val patterns = mutableListOf<Long>()

    fun gen(r: Int, c: String, m: Int) {
        if (r == 0) {
            return
        }
        musts.forEach {
            val next = c + it
            if (next.length >= m && next.toList().containsAll(musts)) {
                patterns.add(next.toLong())
            }
            gen(r - 1, next, m)
        }
    }
    gen(digits, "", 3)
    println(patterns.count { it <= n }.toString())
}


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

int N, M;
int k[10], s[10][10], p[10];
int ans = 0;

void calc(vector<int>& v){  // v : N個のスイッチのON/OFF
    bool flag = true;
    int ON = 0;
    // M個の電球
    for(int i=0;i<M;i++){
        ON = 0;
        // ki個のスイッチ
        for(int j=0;j<k[i];j++){
            if(v[s[i][j]-1] == 1)
                ON++;
        }
        if(ON%2 != p[i]){
            flag = false;   // 点灯しない
            break;
        }
    }
    // M個の電球が全て点灯
    if(flag == true)
        ans++;
}

void dfs(int d, vector<int>& v){
    if(d == N){
        //for(int i=0;i<N;i++)
        //    cout << v[i];
        calc(v);
    }else{
        for(int i=0;i<2;i++){
            v.push_back(i);
            dfs(d+1, v);
            v.pop_back();
        }
    }
}


int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++)
            cin >> s[i][j];
    }
    for(int i=0;i<M;i++)
        cin >> p[i];

    vector<int> v;
    dfs(0, v);

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;

void solve()
{ 
int l,r,d;
  cin>>l>>r>>d;int count=0;
  while(l<r+1)
  {
    if(l%d==0)count++;
    l++;
  }cout<<count;
}



int main()
{fast
// #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
//  #endif
// ll t;
// cin>>t;
// while(t--)
{
solve();
}

}



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

int main() {
  int X;
  cin >> X;
  if (X < 30){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }


  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val a = arrayOf(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
    val k = readInteger()
    println(a[k - 1])
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 31996
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		map<string,string> conv;
		for(int i=0;i<n;i++){
			string from,to;
			cin >> from >> to;
			conv[from] = to;
		}
		int m;
		scanf("%d",&m);
		string res;
		for(int i=0;i<m;i++){
			string tmp;
			cin >> tmp;
			if(conv.find(tmp) != conv.end()){
				res.append(conv[tmp]);
			}
			else res.append(tmp);
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 1176
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 998244353;
// const ll MOD = 1e9+7;

//とりあえず1-indexedでつくったBIT
template <class T>
struct BinaryIndexedTree {
  T n;
  std::vector<T> bit;

  BinaryIndexedTree(T i) : n(i), bit(i + 1, 0){};

  // a番目にwを加算
  void add(T a, T w) {
    for (T x = a; x <= n; x += (x & -x)) {
      bit[x] += w;
    }
  }

  //[1,a]の和
  T sum(T a) {
    T ret = 0;
    for (T x = a; x > 0; x -= (x & -x)) {
      ret += bit[x];
    }
    return ret;
  }
};



int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll q;
  std::cin>>q;

  std::vector<ll> a(q),zaatsu,sumb(q),query(q);

  rep(i,0,q){
    std::cin>>query[i];
    ll b=0;
    if(query[i]==1){
      std::cin>>a[i]>>b;
      zaatsu.push_back(a[i]);
    }
    sumb[i]=b;
    if(i!=0)sumb[i]+=sumb[i-1];
  }

  std::sort(all(zaatsu));

  ll updatecnt=0;

  BinaryIndexedTree<ll> suma(q+2),count(q+2);

  rep(i,0,q){
    if(query[i]==1){
      a[i]=(ll)(std::lower_bound(all(zaatsu),a[i])-zaatsu.begin());
      count.add(a[i]+1,1);
      suma.add(a[i]+1,zaatsu[a[i]]);
      updatecnt++;
    }else{
      ll median=(updatecnt+1)/2;

      ll left=-1,right=q+1;
      while(right-left>1){
        ll mid=left+(right-left)/2;
        
        if(count.sum(mid)>=median)right=mid;
        else left=mid;
      }

      std::cout<<zaatsu[right-1]<<" ";

      ll n=count.sum(left),m=count.sum(q+2)-count.sum(right);
      ll ans=sumb[i]+(n-m)*zaatsu[right-1];
      ans-=suma.sum(left);
      ans+=(suma.sum(q+2)-suma.sum(right));
      std::cout<<ans<<"\n";
    }
  }

  return 0;
}

Measured memory_bytes: 11636
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
                
#define int long long
#define ll long long 
bool FLAG = 0;
#define debug(x) if (FLAG) { 	cerr << #x << " = " << x << endl;}
#define debug_vec(x) if (FLAG) {cerr << #x << " = {"; for (auto to x) cout << to << ", "; cout << "}" << endl}
#define F first
#define S second                               
#define sqr(x) ((x) * (x))
#define make make_pair
#define pb push_back
#define sz(x) (int)(x.size()) 
#define all(x) x.begin (), x.end ()
 
using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;
 
const int MOD = 998244353, N = (int)1e6+ 222;
const int INF = (int)1e18;
const ld eps = (ld)1e-6;
 
int dx[] = {0, -1, 0, 1, 0};
int dy[] = {0, 0, 1, 0, -1};         
                 
int n, a[N], l[N], r[N];
 
 
inline void solve () {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	a[n + 1] = -INF;
	stack <int> s;
	for (int i = 1; i <= n + 1; ++i) {
		while (!s.empty() && a[s.top()] > a[i]) {
			r[s.top()] = i - 1;
			s.pop();
		}
		s.push(i);
	}
	s.pop();
	a[0] = -INF;
	for (int i = n; i >= 0; --i) {
		while (!s.empty() && a[s.top()] > a[i]) {
			l[s.top()] = i + 1;
			s.pop();
		}
		s.push(i);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += (r[i] - i + 1) * (i - l[i] + 1) * a[i];		
	}
	cout << ans;
}	    
 
signed main () {
	#ifdef Maga
		freopen("input", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if( s.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
 
  if( count(next(s.begin(),2),prev(s.end(),1),'C') != 1){
    cout << "WA" << endl;
    return 0;
  }
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if( s.at(i) <= 'Z'){
      cnt++;
    }
  }
  if( cnt != 2){
    cout << "WA" << endl;
    return 0;
  }
  
  cout << "AC" << endl;
  
  
      
	
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int n = sc.nextInt();

        final int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        final int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            q[i] = sc.nextInt();
        }

        List<List<Integer>> list = new ArrayList<>();

        perm(IntStream.rangeClosed(1, n).boxed().collect(Collectors.toList()), new ArrayList<>(), list);

        List<Integer> lp = IntStream.of(p).boxed().collect(Collectors.toList());
        List<Integer> lq = IntStream.of(q).boxed().collect(Collectors.toList());

        int np = 0;
        int nq = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).toString().equals(lp.toString())) np = i + 1;
            if (list.get(i).toString().equals(lq.toString())) nq = i + 1;
        }

        System.out.println(Math.abs(np - nq));
    }

    private static void perm(List<Integer> candidate, List<Integer> perm, List<List<Integer>> perms) {
        if (candidate.size() == 0) {
            perms.add(perm);
        }
        for (int i = 0; i < candidate.size(); i++) {
            List<Integer> c = new ArrayList<>(candidate);
            List<Integer> p = new ArrayList<>(perm);
            p.add(c.get(i));
            c.remove(i);
            perm(c, p, perms);
        }
    }
}


Measured memory_bytes: 69152
N, M, K = map(int, input().split())

MOD = 998244353
MAX = 2 * 10 ** 5 + 1

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


ans = 0
for k in range(K + 1):
    ans += (comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD)) % MOD
    ans %= MOD

print(ans)


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

using namespace std;
using ll = long long;


void fact(int n, std::map<int,int>& xap){
    for(int i = 2; i + i < n; i++){
        while(n % i == 0){
            xap[i]++;
            n /= i;
        }
    }
    if(n == 1)return;
    xap[n]++;
}

ll gcd(ll a,ll b)
{
    while(a&&b){
        if(a>b) a = a%b;
        else b = b%a;
    }
    return a+b;
}

int main()
{
    int x;
    cin >> x;
    for(int i = x; i >= 1; i--){
        map<int,int> mp;
        fact(i,mp);
        int gc = 0;
        for(auto l : mp){
            gc = gcd(gc, l.second);
        }
        if(gc > 1){
            cout << i <<  endl;
            return 0;
        }
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
l = list(input())
l = list(map(int,l))

#print(l)

x = [0] * len(l)

for i in range(0,len(l)):
    if i % 2 == 0:
        x[i] = 0
    else:
        x[i] = 1

#print(x)

count = 0

for i in range(0,len(l)):
    if l[i] != x[i]:
        count += 1
    
print(min(count,len(l)-count))


Measured memory_bytes: 4652
def main():
    from itertools import accumulate
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n+1):
            if i*i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n//i != i:
                    # i が平方数でない
                    divs.append(n//i)
        return divs

    divs = enum_divisors(sumA)
    divs.sort(reverse=True)

    for d in divs:
        if d == 1:
            print(d)
            return
        diff_n = []
        for a in A:
            if a % d != 0:
                diff_n.append(a % d)
        diff_n.sort()
        diff_p = [d - dn for dn in diff_n]
        S_n = list(accumulate([0] + diff_n))
        S_p = list(accumulate([0] + diff_p))
        M = len(S_n) - 1
        if min(S_n[i] for i in range(1, M)
               if (S_n[i] - (S_p[M] - S_p[i])) == 0) <= K:
            print(d)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 74432
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	ll ans=0LL;
	cin >>n>>m;
	ll one=1900LL*m+100LL*(n-m);
	clog<<one<<endl;
	ans=one*(1LL<<m);
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
/*
AAtCoder Beginner Contest 097 A - Colorful Transceivers 結果:

*/

//#include<stdio.h>
//#include<string.h>
//#include<math.h>
//#include<stdlib.h>

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
//
//#ifdef DEBUG1
//#ifdef DEBUG2
//#ifdef DEBUGF
//#endif
//#define int long long

//#define DEBUG1
//#define DEBUGF

#include<stdio.h>
#include<math.h>

int main(void) {
	int a, b,c,d, ngflg = 0;
	//int a[100], b[100];
	//scanf("%d %d", &t, &n);
	//for (int i = 0; i < n; i++) {
	//	scanf("%d", &a[i]);
	//}
	//scanf("%d", &m);
	//for (int i = 0; i < m; i++) {
	//	scanf("%d", &b[i]);
	//}
#ifdef DEBUG1
	//for (int i = 0; i < n; i++) {
	//	printf("%d\n", a[i]);
	//}
	//for (int i = 0; i < m; i++) {
	//	printf("%d\n", b[i]);
	//}
#endif
	//int i = 0, j = 0;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	if ((c-a)*(c-a) <= d*d) { printf("%s\n", "Yes"); }
	else if ((c - b)*(c - b) <= d*d && (a - b)*(a - b) <= d*d) { printf("%s\n", "Yes"); }
	else{ printf("%s\n", "No"); }

	//if (a*a > b*b) { printf("%s\n", "Ant"); }
	//if (a*a < b*b) { printf("%s\n", "Bug"); }
	//if (a*a == b*b) { printf("%s\n", "Draw"); }



#ifdef DEBUGF
	getch();
#endif
	return 0;
}

//a = (int)sqrt((double)n) + 1;
//int ngflg = 0;
//scanf("%d", &n);
//scanf("%lld", &N);
//
//#define int long long
//signed main() {
//int *x = (int *)malloc(sizeof(int) * N);
//int *y = (int *)malloc(sizeof(int) * N);
//int desc(const void *a, const void *b) {return *(int *)b - *(int *)a;}
//qsort(num, 3, sizeof(int), desc);
//int d = pow(2, k);


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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i, n+1) a[i] = 0;
    rep(i, n) for (ll j = 0; j <= n; j += (i+1)) a[j]++;
    ll ans = 0;
    rep(i, n+1) ans += i * a[i];
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, K;
    cin >> N >> K;
    if(N / 2 + N % 2 >= K) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<int,int> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

ll a[60],p[60];
ll f(ll N, ll X){
    if(N==0)
        return (X<=0) ? 0 :1;
    else if(X <= 1+ a[N-1])
        return f(N-1, X-1);
    else
        return p[N-1] + 1 + f(N-1,X-2-a[N-1]);
}
int main(){
    ll N,X;
    cin >> N >> X;
    a[0]=1, p[0]=1;
    for(int i=1; i<=N; i++){
        a[i]=a[i-1]*2+3;
        p[i]=p[i-1]*2+1;
    }

    cout << f(N,X) << endl;
    return 0;
}



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

int main() {
  string A;
  cin >> A;
  map<char, long long> m;
  for (char c : A) {
    if (!m.count(c)) m[c] = 1;
    else m[c]++;
  }
  long long ans = 1 + A.size() * (A.size() - 1) / 2;
  for (pair<char, long long> p : m) ans -= m[p.first] * (m[p.first] - 1) / 2;

  cout << ans;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Random rnd = new Random();
        Scanner scan = new Scanner(System.in);
        long iNum, RiNum;
        iNum = scan.nextInt();
        long MinNum=0, MaxNum=0, SumNum=0; 
        
        for(int i=0; i<iNum; i++){
            RiNum=scan.nextInt();

            if(i==0) MinNum=MaxNum=SumNum=RiNum;
            else{
                MinNum=MinNum<RiNum ? MinNum : RiNum;
                MaxNum=MaxNum>RiNum ? MaxNum : RiNum;
                SumNum+=RiNum;
            }
        }
        System.out.println(MinNum+" "+MaxNum+" "+SumNum);
    }
}


Measured memory_bytes: 41348
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

int main(void){
	int N,M,p[100010],d[100010]={},x,y,ans=0;
	vector<int> v[100010];
	scanf("%d%d",&N,&M);
	reg(i,1,N)scanf("%d",&p[i]);
	reg(i,1,M){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	//同じ連結成分に入ってるなら同じ数字
	//同じ連結成分同士はどのようにでも入れ替えられる
	reg(i,1,N){
		if(d[i]!=0)continue;//ここを忘れるな
		queue<int> Q;
		set<int> S;//pの値
		vector<int> V;//順番
		Q.push(i);
		S.insert(p[i]);
		V.push_back(i);
		d[i]=i;
		while(!Q.empty()){
			int a = Q.front();Q.pop();
			rep(j,v[a].size()){
				int q = v[a][j];
				if(d[q]==0){
					d[q]=i;
					Q.push(q);
					S.insert(p[q]);
					V.push_back(q);
				}
			}
		}
		// printf("%d: ",i);
		rep(j,V.size()){
			// printf("%d ",V[j]);
			if(S.count(V[j])!=0)ans++;
		}
		// printf("\n");
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11512
#include <stdio.h>
#include <string.h>

int main(void) {
  // your code goes here
  char a[100],b[100],c[100];
  scanf("%s %s %s",a,b,c);
  int A=strlen(a)-1;
  int B=strlen(b)-1;
  int C=strlen(c)-1;
  if(a[A]==b[0] && b[B]==c[0])printf("YES\n");
  else  printf("NO\n");
  //else if(a[A]!=b[0] && b[B]==c[0]) printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[]) {
	string command;
	int i,n,num;
	list<int> v;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>command;
		if(command[0]=='i'){
			cin>>num;
			v.push_front(num);
		}else if(command[6]=='F'){
			v.pop_front();
		}else if(command[6]=='L'){
			v.pop_back();
		}else{
			cin>>num;
			for(list<int>::iterator it=v.begin();it!=v.end();it++){
				if(*it==num){
					v.erase(it);
					break;
			}	}
		}
	}
	i=0;
	for(list<int>::iterator it=v.begin();it!=v.end();it++)
	{
		if(i++)
			cout<<" ";
		cout<<(*it);	
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 34308
#include <iostream>
#include <string>

int main(){

	std::string a, b, c;

	std::cin >> a >> b >> c;

	if (a.back() == b.front() && b.back() == c.front()) {
		std::cout << "YES";
	}
	else {
		std::cout << "NO";
	}

	std::cin;


}

Measured memory_bytes: 256
def NS(s):
    return 'N' in s and 'S' in s

def EW(s):
    return 'W' in s and 'E' in s

s = list(input())
if len(set(s)) == 2:
    if NS(s) or EW(s):
        print("Yes")
    else:
        print("No")
elif len(set(s)) == 4:
    if NS(s) and EW(s):
        print("Yes")
    else:
        print("No")    
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 100005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;  cin>>n;
  string str;   cin>>str;
  ll ans = 0;
  ll r=0,g=0,b=0;
  f(n)
  {
    if(str[i] == 'R')r++;
    else if(str[i] == 'B')b++;
    else g++;
  }
  ans = r*b*g;
  for(int i =0;i<n;i++)
  {
    for(int j = i+1;j<n;j++)
    {
      if(str[i] != str[j] )
      {
        int k = 2*j -i;
        if(k>=n)continue;
        if(str[k] != str[j] && str[k] != str[i])ans--;
        
      }
    }
  }
cout << ans;
  
  return 0;
 }

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

int main() {
    int N;
    set<string> S;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string temp;
        cin >> temp;
        S.insert(temp);
    }

    cout << S.size() << endl;
    return 0;
}

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

int main(){
    string s, longest="";
    map<string, int> mp;
    while(cin >> s){
        mp[s]++;
        if(longest.size() < s.size())
            longest = s;
    }
    int maxi=0;
    string mode="";
    for(auto e : mp){
        if(e.second > maxi){
            maxi = e.second;
            mode = e.first;
        }
    }
    cout << mode << " " << longest << endl;

    return 0;
}


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

inline bool isleap(int year){
	if(year%400==0)
		return true;
	if(year%100==0)
		return false;
	if(year%4==0)
		return true;
	return false;
}

int main(void){
	int a,b;
	bool space=false;
	while(cin >> a >> b,a|b){
		if(space) puts("");
		bool ans=false;
		range(i,a,b+1) if(isleap(i)) cout << i << endl,ans=true;
		if(!ans) puts("NA");
		space=true;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll mypow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1) res = res*a;
        a = a*a;
        n >>= 1;
    }
    return res;
}
void solve(){
    ll n, k; cin >> n >> k;
    printf("%lld\n", k*mypow(k-1, n-1));
}

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

Measured memory_bytes: 256
import sys

counter = {k: 0 for k in  "abcdefghijklmnopqrstuvwxyz"}

while True:
    try:
        line = raw_input()
    except:
        break
    for i in line.lower():
        if i in counter.keys():
            counter[i] += 1
for k in sorted(counter.keys()):
    print "{} : {}".format(k,counter[k])

Measured memory_bytes: 6440
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
lis = [[] for _ in range(3)]
#print(lis)
for i in range(N):
    for j in range(N):
        lis[(i+j+2) % 3].append(c[i][j])
#print(lis)
val = [[] for _ in range(3)]
for i in range(3):#lis[i]
    for j in range(C):#d[]
        cnt = 0
        for k in lis[i]:
            #print(k)
            cnt += D[k-1][j]
        val[i].append(cnt)
#print(lis)
#print(val)
ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                continue
            ans = min(ans,val[0][i]+val[1][j]+val[2][k])
print(ans)



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    int cnt = 0;
    bool ok = false;
    REP(i,N){
        int a,b; cin >> a >> b;
        if(a==b){
            cnt++;
            if(cnt==3) ok = true;
        }else{
            cnt = 0;
        }
    }
    cout << (ok?"Yes":"No") << endl;
    return 0;
}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
import statistics

NN = int(input())
AA = list(map(int,input().split()))
BB = [0]*NN
for nn in range(1,NN+1):
    BB[nn-1] = AA[nn-1] - nn
#print(BB)
MBB = statistics.median(BB)

CC = list(map(lambda x: x - MBB, BB))
#print(CC)
ACC = list(map(lambda x: abs(x),CC))
ANS = sum(ACC)
print(int(ANS))

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n,m,v,p;
    cin>>n>>m>>v>>p;
    Array a(n);
    REP(i,n) cin>>a[i];

    sort(all(a),greater<ll>());

    auto check = [&](ll x)->bool{
        ll base = a[x]+m;
        ll ret = m*(v-1);
        ret=ret-(p-1)*m;
        rep(i,p-1,n){
            if(i==x) continue;
            if(a[i]>base) return false;
            ret-=min(m, base-a[i]);
        }
        return ret<=0;
    };

    ll l=p-1;
    ll r=n;
    while(l+1<r){
        ll m=l+r>>1;
        if(check(m)) l=m;
        else r=m;
    }
    cout<<r<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int N;
int A[210];

int main(){
    cin >> N;
    for (int i=0; i<N; ++i) cin >> A[i];
    
    int res = 0;
    
    while (true) {
        bool exist_odd = false;
        for (int i=0; i<N; ++i){
            if (A[i]%2 != 0) exist_odd = true;
        }
        
        if (exist_odd) break;
        
        for (int i=0; i<N; ++i){
            A[i] /= 2;
        }
        
        ++res;
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
s=list(input())
if s.count('W')>0 and s.count('E')>0 and s.count('N')>0 and s.count('S')>0:
    print("Yes")
elif s.count('W')>0 and s.count('E')>0 and s.count('N')==0 and s.count('S')==0:
    print('Yes')
elif s.count('W')==0 and s.count('E')==0 and s.count('N')>0 and s.count('S')>0:
    print('Yes')
else:
    print("No")


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

int main()
{
        long long n,q,a,b,c,i,f[100007]={0},s=0;
        cin>>n;
        for(i=0;i<n;i++)
        {
                cin>>a;
                s=s+a;
                f[a]++;
        }
        cin>>q;
        for(i=0;i<q;i++)
        {
            cin>>b>>c;
            s=s+f[b]*c;
            s=s-f[b]*b;
            f[c]=f[c]+f[b];
            f[b]=0;
            cout<<s<<endl;
        }
        return 0;
}


Measured memory_bytes: 4400
// B - Exponential
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  if (n == 1)
  {
    cout << 1 << endl;
    return 0;
  }
  rep(i, 1, n)
  {
    rep(j, 2, n)
    {
      a = pow(i, j);
      if (a <= n)
      {
        ans = max(ans, a);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
zeta = [0] * (max(A) + 1)
mod = 998244353
res = 0
for a in A:
  zeta[a] += a
for i in range(1, len(zeta)):
  for j in range(2 * i, len(zeta), i):
    zeta[i] += zeta[j]
for i in range(1, len(zeta)):
  zeta[i] *= zeta[i]
for i in range(len(zeta) - 1, 0, -1):
  for j in range(2 * i, len(zeta), i):
    zeta[i] -= zeta[j]
for a in A:
  zeta[a] -= a ** 2
for i in range(1, len(zeta)):
  zeta[i] //= 2
for i in range(1, len(zeta)):
  zeta[i] //= i
  res = (res + zeta[i]) % mod
print(res)

Measured memory_bytes: 139892
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x < r || x > w-r || y < r || y > h-r) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}



Measured memory_bytes: 26388
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

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

		String str = sc.nextLine();
		char[] charr = str.toCharArray();

		ArrayList<Integer> rList = new ArrayList<Integer>();
		ArrayList<Integer> wList = new ArrayList<Integer>();

		// 左側からWがあったら
		// 右側のRと交換

		// Rの番地リストと、Wの番地リストをつくる
		for (int i = 0; i < charr.length; i++) {

			if (charr[i] == (char) 'R') {
				rList.add(i);
			} else {
				wList.add(i);
			}

		}

		// wListを左から、rListを右からたどる
		Collections.reverse(rList);
		int count = 0;

		int listmax;

		if (rList.size() > wList.size()) {
			listmax = wList.size();
		} else {
			listmax = rList.size();
		}

		for (int j = 0; j < listmax; j++) {
			if (rList.get(j) < wList.get(j)) {
				break;
			}
			count++;
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 48144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll b=k+1;b<=n;++b){
    ans += n/b*(b-k);
    ans += max(n%b-k+1,0LL);
  }
  if(k==0) ans-=n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#define Dist(x,y) ((x)*(x)+(y)*(y))
using namespace std;

typedef struct{
  int height;
  int weight;
} Rectangle;

bool operator<(Rectangle r1,Rectangle r2){
  int di1=Dist(r1.height,r1.weight);
  int di2=Dist(r2.height,r2.weight);
  if(di1 < di2) return true;
  else if(di1 > di2) return false;
  else return (r1.height < r2.height);
}

int main(){
  int h,w;
  while(cin>>h>>w,w+h){
    Rectangle r;
    r.height=h;
    r.weight=w;
    Rectangle min;
    min.height=150;
    min.weight=150;
    for(int i=1;i<150;i++){
      for(int j=1;j<i;j++){
	Rectangle tmp;
	tmp.height=j;
	tmp.weight=i;
	if(r < tmp && tmp < min) min = tmp;
      }
    }
    cout<<min.height<<" "<<min.weight<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    if(0<=a&&a<=100){
        if(0<=b&&b<=100){
            if(0<=c&&c<=100){
                if(a<b&&b<c){
                    printf("Yes\n");
                }
                else{
                    printf("No\n");
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2048
import numpy as np
 
n,m = input().split(" ")
n = int(n)
m = int(m)
 
H = input().split(" ")
H = np.array([int(h) for h in H])
Hs = np.zeros(n)

for i in range(m):
    a, b = input().split(" ")
    a = int(a) - 1
    b = int(b) - 1
    Hs[a] = np.max([Hs[a], H[b]])
    Hs[b] = np.max([Hs[b], H[a]])
 
G = []
for i in range(n):
    if Hs[i] < H[i]:
        G += [i]
 
print(len(G))


Measured memory_bytes: 39440
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;



int main() {
   ll X,Y;
   cin>>X>>Y;
   int count=1;
   while(true){
       X*=2;
       if(X>Y){
           break;
       }
       count++;
   }
   cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
ll N,M;
//約数の列挙O(√n)
void divisor(ll n) {
    vector<ll> res;
    for (int i=1; i*i<=n; i++){
        if (n%i==0){
            if(i<=M/N)
            res.push_back(i);
            if (i!=n/i && n/i<=M/N) res.push_back(n/i);
        }
    }
    ll c=0;
    rep(i,0,res.size()){
        c=max(c,res[i]);
    }
    cout << c<<"\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>> N>>M;
    divisor(M);
}

Measured memory_bytes: 256