akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int a = reader.nextInt();
    int b = reader.nextInt();
    out.println(Math.min(n * a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public 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();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] nextArray(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDoubleArray(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public int[][] nextIntMatrix(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLongMatrix(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDoubleMatrix(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
}


Measured memory_bytes: 23124
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
c=[]
d,p=0,a[0]
for x in a:
  if p==x:
    d+=1
  else:
    c.append(d)
    d=1
    p=x
c.append(d)
c.sort(reverse=1)
k=min(k,len(c))
print(sum(c[k:]))

Measured memory_bytes: 24996
n = int(input())
s = n * (n + 1) / 2
s -= ((3 + 3 * (n // 3)) * (n // 3)) / 2
s -= ((5 + 5 * (n // 5)) * (n // 5)) / 2
s += ((15 + 15 * (n // 15)) * (n // 15)) / 2
print(int(s))

Measured memory_bytes: 9208
#include <cstdio>
#include <map>
#include <algorithm>

int main()
{
  long long n, m;
  scanf("%lld%lld", &n, &m);
  std::map<long long, long long> mp;
  for (long long i = 0; i < n; ++i)
  {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    mp[a] += b;
  }
  long long ans = 0;
  long long count = 0;
  for (auto &p : mp)
  {
    long long a = std::min(m - count, p.second);
    count += a;
    ans += a * p.first;
    if (count == m) break;
  }
  printf("%lld\n", ans);
  return 0;
}

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

void solve()
{
	int n,k;
	cin>>n>>k;
	multiset<int,greater<int>> s;
	ll a[n];
	ll maxi = 0;
	ll sum = 0;
	for (int i = 0; i < n; ++i)
	{
		// int e;
		cin>>a[i];
		maxi = max(maxi,a[i]);
		sum += a[i];
		// mini
		// s.insert(e);
	}
	// if(sum<=k)
	// {
	// 	cout<<0<<endl;
	// 	return;
	// }
	ll l = 1, r = maxi,ans = maxi;
	while(l<=r)
	{
		ll mid = (l+r)/2;
		int temp = 0;
		for (int i = 0; i < n; ++i)
		{
			if(a[i]>mid)
			temp += a[i]/mid;
		}
		if(temp>k)
		{
			l = mid + 1;
		}
		else
		{
			ans = mid;
			r = mid - 1;
		}
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd(0,25);

    cin >> d;
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    rep(_,10){
        rep(i,d)now[i] = rnd(mt);
        ll now_s = score();
        if(best < now_s){
            best = now_s;
            swap(t,now);
        }
    }


    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn],b[maxn];
int main(){
	int n;
	long long d;
	cin>>n>>d;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		long long k=(long long)a[i]*a[i];
//		if(k>=d*d) continue;
		k+=(long long)b[i]*b[i];
		if(k<=d*d) ans++;
//		cout<<k<<" "<<d*d<<endl;
	} 
	cout<<ans<<endl;
} 

Measured memory_bytes: 5208
#include<stdio.h>
#include<stdlib.h>
 
int power(int m, int n);
 
int main(void)
{
    int n,a[15],x[15][14],y[15][14],i,j,k,ans=0,which[15],honests,success;
 
    scanf("%d",&n);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",a+i);
        for ( j = 0; j < a[i]; j++)
        {
            scanf("%d %d",x[i]+j,y[i]+j);
            x[i][j]--;
        }
    }
 
    for ( k = 0; k < power(2,n); k++)
    {
        honests=0;
        for ( i = 0; i < n; i++)
        {
            which[i]=(k>>i)&1;;
            honests+=which[i];
        }
        success=1;
        for ( i = 0; i < n; i++)
        {
            if (which[i]==1)
            {
                for ( j = 0; j < a[i]; j++)
                {
                    if(which[x[i][j]]!=y[i][j]) success=0;
                }
            }
        }
        if(success==1&&ans<honests) ans=honests;
    }
 
    printf("%d",ans);
 
    return 0;
}
 
int power(int m, int n)
{
    int p=1;
    for (int i = 0; i < n; i++) p*=m;
    return p;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int ans;
int h, w;
int ttm[30][30];

int c;

bool ok(int x, int y){
    return x == 0 ||
        y == 0 ||
        ttm[y][x] == ttm[y][x - 1] ||
        ttm[y][x - 1] == ttm[y - 1][x - 1] ||
        ttm[y - 1][x - 1] == ttm[y - 1][x] ||
        ttm[y - 1][x] == ttm[y][x];
}

void dfs(int x, int y){
    //cout << x << " " << y << endl;
    //for (int i = 0; i < h; i++){
    //    for (int j = 0; j < w; j++){
    //        printf("%2d ", ttm[i][j]);
    //    }
    //    cout << endl;
    //}
    if (x == w){
        if (y == h - 1){
            ans++;
            return;
        }
        else dfs(0, y + 1);
        return;
    }

    if (ttm[y][x]) dfs(x + 1, y);
    else{
        if (x + 1 != w && ttm[y][x + 1] == 0){
            ttm[y][x] = ttm[y][x + 1] = c++;
            if (ok(x, y)) dfs(x + 2, y);
            ttm[y][x] = ttm[y][x + 1] = 0;
        }
        if (y + 1 != h && ttm[y + 1][x] == 0){
            ttm[y][x] = ttm[y + 1][x] = c++;
            if (ok(x, y)) dfs(x + 1, y);
            ttm[y][x] = ttm[y + 1][x] = 0;
        }
    }
}

int main(){
    while (cin >> h >> w && h){
        ans = 0;
        c = 1;
        memset(ttm, 0, sizeof(ttm));
        dfs(0, 0);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
}


int main(){
  int n,m;cin>>n>>m;
  vector<int> a(m);for(int i=0;i<m;i++)cin>>a[i];
  vector<int> step(n+1);
  step[0]=1;
  for(int i=1;i<=n;i++){
    if(a.size() && a[0]==i){step[i]=0;a.erase(a.begin());}
    else if(i==1)step[i]=1;
    else {step[i]=step[i-1]+step[i-2];step[i]=step[i]%mod;}
  }
  cout<<step[n]<<endl;


  //for(int i=0;i<=n;i++)cout<<step[i]<<endl;
  return 0;
}


Measured memory_bytes: 1024
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################
n = I1()
res = 0
n-=1
print(n*(n+1)//2)
'''
for i in range(1,n+1):
    Mi = i % pi
    res+=Mi
'''

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str,s="CODEFESTIVAL2016";
    cin>>str;
    int ans=str.size()-s.size();
    for(int i=0;i<s.size();i++)
        if(str[i]!=s[i])
            ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    def factorization(num):
        result = []
        count = 0
        temp = num
        for i in range(2, int(num ** 0.5) + 1):
            if temp % i == 0:
                count = 0
                while temp % i == 0:
                    count += 1
                    temp /= i
                result.append(count)
        if temp != 1:
            result.append(1)
        return result
    C = []
    c = 0
    for i in range(1, 40):
        c += i
        C.append(c)
    def combi(num, C):
        for i, c in enumerate(C):
            if num < c:
                return i
        return -1
    n = int(input())
    exps = factorization(n)
    count = 0
    for e in exps:
        count += combi(e, C)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63680
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n]);
    let mut ra = vec![0usize; n];
    ra[n - 1] = a[n - 1];
    for i in 1..n {
        ra[n - 1 - i] = (ra[n - i] + a[n - 1 - i]);
    }
    for i in 0..n {
        ra[i] = (ra[i] - a[i]) % 1_000_000_007;
    }

    let mut sum: usize = 0;
    for i in 0..n {
        sum += a[i] * ra[i] % 1_000_000_007;
        sum %= 1_000_000_007;
    }

    println!("{}", sum % 1_000_000_007);
}


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

int main()
{
  int a,b,c;
  char op;
  while(1){
  cin>>a>>op>>b;
    if(op == '+') c=a+b;
    else if(op == '-') c=a-b;
    else if(op == '*') c=a*b;
    else if(op == '/') c=a/b;
    else if(op == '?') break;
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main()
{
    int a = 0;
    int N;
    cin >> N;
    int n = N;
    while(n > 0){
         a = a + n % 10;
         n = n / 10;
    }
    // 出力
    if(N % a == 0){
          cout << "Yes" << endl;
    }else{
          cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define f first
#define s second
const int maxn = 1e7+10;
int spf[maxn];
void crivo(){
    spf[1] = 1;
    for(ll i=2; i<maxn; i++){
        if(!spf[i]){
            spf[i] = i;
            for(ll j=i*i; j<maxn; j+=i){
                if(!spf[j]) spf[j] = i;
            }
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    crivo();
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1; i<=n; i++){
        int aux = i, last = spf[i], qtd = 0;
        vector<pii> div;
        while(spf[aux] != 1){
            if(last != spf[aux]){
                div.push_back({last, qtd});
                last = spf[aux];
                qtd = 1;
            }
            else qtd++;
            aux /= spf[aux];
        }
        div.push_back({last, qtd});
        ll qtd_div = 1;
        for(auto x : div) qtd_div *= x.s+1;
        ans += i*qtd_div;
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
  int64_t n,a=0,b=0;
  cin >> n;
  vector<int64_t> h(n);
  for(int64_t i=0; i<n; i++){
    cin >> h[i];
  }
  for(int64_t i=0; i<n-1; i++){
    if(h[i]>=h[i+1])
      a++;
    else{
      a=0;
    }
    if(a>b){
      b=a;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 1024
h,w = map(int,input().split())
a = [''] * h
for i in range(h):
    a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end = '')
        print()


Measured memory_bytes: 4468
<?php
// Try AtCoder
// author: Leonardone @ NEETSDKASU

function gets() { return trim(fgets(STDIN)); }
function geti() { return intval(gets()); }
function getVals() { return explode(' ', gets()); }
function getInts() { return array_map(intval, getVals()); }

$N = geti();

$ans = array();

for ($i = 0; $i < $N; $i++) {
    $a = geti();
    if (isset($ans[$a])) {
        unset($ans[$a]);
    } else {
        $ans[$a] = true;
    }
}

echo count($ans);

Measured memory_bytes: 18036
#include <iostream>
//#include <iomanip>
//#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

	string p, a, c, ans, buf, rep;
	int n, b, e, cnt;

	cin >> p >> n;

	while (n--){
		cin >> a;

		if (a == "print"){
			cin >> b >> e;
			cnt = e - b;
			ans = p.substr(b, cnt + 1);
			cout << ans << endl;
		}
		else if (a == "reverse"){
			cin >> b >> e;
			cnt = e - b;
			buf = p.substr(b, cnt + 1);
			for (int i = 0; i <= cnt; i++){
				p[b + i] = buf[cnt - i];
			}
		}
		else if (a == "replace"){
			cin >> b >> e >> rep;
			cnt = e - b;
			for (int i = 0; i <= cnt; i++){
				p[b + i] = rep[i];
			}
		}

	}


	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll acc = a+b+c;
    unordered_set<string> used;
    auto tmp = to_string(a) + "_" + to_string(b) + " " + to_string(c);
    used.insert(tmp);
    ll ans = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        a = (acc-a)/2;
        b = (acc-b)/2;
        c = (acc-c)/2;
        ans += 1;
        auto tmp = to_string(a) + "_" + to_string(b) + " " + to_string(c);
        if (used.count(tmp) > 0) {
            cout << -1 << endl;
            return 0;
        }
        used.insert(tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
#![allow(unused)]

use std::{cell, cmp, collections, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();
    if n % 2 == 0 {
        println!("{}", n);
    } else {
        println!("{}", 2 * n);
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
//Patwari26
//#include template<t> as mine
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    ll ans=0;
    ll curr=0;
    vi v(n);
    rep(i,0,n-1) cin>>v[i];
    rep(i,0,n-1){
        ans=(ans+(v[i]*curr)%hell)%hell;
        curr=(curr+v[i])%hell;
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    // time
    return 0;
}

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

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

  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }

  int ans = 1001001001;
  for(int i=0; i<=100; i++){
    int sum = 0;
    for(int j=0; j<n; j++){
      sum += (vec.at(j)-i)*(vec.at(j)-i);
    }
    ans = min(ans,sum);
  }

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

Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 500010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll cnt[100010];
void solve(){
  ll N;
  cin >> N;
  ll sum = 0;
  rep(i, N){
    ll a;
    cin >> a;
    cnt[a]++;
    sum += a;
  }
  ll Q;
  cin >> Q;
  rep(i, Q){
    ll b, c;
    cin >> b >> c;
    sum += cnt[b] * (c - b);
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << sum << endl;
  }
}

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


Measured memory_bytes: 4416
N, M = map(int, input().split())
total_time = M*1900+(N-M)*100

e = 0
err = 10**(-3)
prev = -100
i = 0
while abs(prev-e) > err:
    prev = e
    e += (1-(1/2)**M)**i*(1/2)**M*total_time*(i+1)
    i += 1


def floor(x, y):
    return ((-x)//y)*(-1)


print(int(floor(e, 1)))


Measured memory_bytes: 38896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int count = sc.nextInt();
            if (count == 0) break;
            int[] score = new int[count];
            int sum = 0;
            double average = 0;
            for (int i=0; i<count; i++) {
                score[i] = sc.nextInt();
                sum += score[i];
            }  
            average = (double)sum/count;
            double d = 0;
            for (int i=0; i<count; i++) {
                d += (score[i]-average)*(score[i]-average);
            }
            double b = (double)d/count;
            System.out.println(Math.sqrt(b));
        }
    }
}



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

int main() {
	int n;
	while (cin >> n, n) {
		vector <int> r, w;
		r = w = vector <int> (n);
		int sumR = 0, sumW = 0;
		rep (i, n) {
			cin >> r[i] >> w[i];
			sumR += r[i];
			sumW += w[i];
		}

		vector <int> copyR = r;
		sort(r.begin(), r.end());

		if (sumR >= 2*r.back()) {
			cout << sumR + sumW << endl;
		} else {
			int gap = r.back() - (sumR - r.back());
			vector <vector <int>> dp(n, vector <int> (gap + 1, 0));
			dp[0][0] = true;
			w.erase(w.begin() + (find(copyR.begin(), copyR.end(), r.back())-copyR.begin()));
			range (i, 1, n) {
				rep (j, gap + 1) {
					if (j - w[i - 1] < 0) continue;
					dp[i][j] |= dp[i - 1][j];
					dp[i][j] |= dp[i - 1][j - w[i-1]];
				}
			}

			int maxJ = 0;
			rep (i, n) rep (j, gap + 1) if (dp[i][j]) maxJ = max(maxJ, j);
			cout << 2*r.back() + sumW - maxJ << endl;
		}
	}
	return 0;
}


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

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return i * 2;
}

int right(int i) {
    return i * 2 + 1;
}

int main() {
    int h;
    cin >> h;
    vector<int> T(h + 1);
    for (int i = 1; i <= h; i++) {
        cin >> T.at(i);
    }

    for (int i = 1; i <= h; i++) {
        printf("node %d: key = %d, ", i, T.at(i));
        if (parent(i) >= 1) {
            printf("parent key = %d, ", T.at(parent(i)));
        }
        if (left(i) <= h) {
            printf("left key = %d, ", T.at(left(i)));
        }
        if (right(i) <= h) {
            printf("right key = %d, ", T.at(right(i)));
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3224
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	double a,b,h,m;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	double deg=(h+m/60)*360/12,deg2=m*360/60,deg3=abs(deg-deg2);
	//printf("%lf %lf %lf\n",deg,deg2,deg3);
	printf("%.10lf\n",sqrt(a*a+b*b-2*a*b*cos(deg3*acos(-1)/180)));
}

Measured memory_bytes: 2644
N = int(input())
list = []
for i in range(N):
    a,b=input().split()
    list.append((float(a), b))

ans = 0

for j in range(N):
    if list[j][1] == "JPY":
        ans += list[j][0]
    else:
        ans += 380000 * list[j][0]

print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;
     
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int cnt_v = 1;
vector<int> tree;
vector<int> add;

void build(int n)
{
    while (cnt_v < n)
        cnt_v <<= 1;
    tree.resize(cnt_v * 2 - 1, 0);
    add.resize(cnt_v * 2 - 1, 0);
}

void push(int x)
{
    tree[x * 2 + 1] += add[x];
    add[x * 2 + 1] += add[x];
    tree[x * 2 + 2] += add[x];
    add[x * 2 + 2] += add[x];
    add[x] = 0;
}

void upd(int x, int lx, int rx, int l, int r, int v)
{
    if (lx >= r || l >= rx)
        return;
    else if (lx >= l && rx <= r)
    {
        tree[x] += v;
        add[x] += v;
    }
    else
    {
        push(x);
        upd(x * 2 + 1, lx, (lx + rx) / 2, l, r, v);
        upd(x * 2 + 2, (lx + rx) / 2, rx, l, r, v);
        tree[x] = max(tree[x * 2 + 1], tree[x * 2 + 2]);
    }
}

int get(int x, int lx, int rx, int l, int r)
{
    if (lx >= r || l >= rx)
        return -inf;
    else if (lx >= l && rx <= r)
        return tree[x];
    else
    {
        push(x);
        return max(get(x * 2 + 1, lx, (lx + rx) / 2, l, r), get(x * 2 + 2, (lx + rx) / 2, rx, l, r));
    }
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    build(m);
    vector<pair<int, int> > a;
    vector<pair<int, pair<int, int> > > e;
    rep(i, 0, n)
    {
        int x, y;
        cin >> x >> y;
        x++; y--;
        if (x <= y)
        {
            e.push_back({x - 1, {1, sz(a)}});
            e.push_back({y, {-1, sz(a)}});
            a.push_back({x - 1, y - 1});
        }
    }
    sort(e.begin(), e.end());
    rep(i, 0, m)
        upd(0, 0, cnt_v, i, m, 1);
    int ans = 0;
    int pos = 0;
    rep(i, 0, m)
    {
        while (pos < sz(e) && e[pos].fi == i)
        {
            if (e[pos].se.fi == 1)
            {
                int x = e[pos].fi, y = a[e[pos].se.se].se;
                upd(0, 0, cnt_v, x, y + 1, 1);
            }
            else
            {
                int y = e[pos].fi, x = a[e[pos].se.se].fi;
                upd(0, 0, cnt_v, x, y + 1, -1);
            }
            pos++;
        }
        ans = max(ans, tree[0]);
        upd(0, 0, cnt_v, i, m, -1);
    }
    cout << max(0, max(ans, n) - m) << endl;
    return 0;
}

Measured memory_bytes: 14512
import sys


def analyze_figure(data):
    """
    ??????????????????????????§?????????????????£???????????????'1'????????£?????????????????¢??????
    ??????????????¨????????¶??????????????¢??????????????????
    """
    for i, row in enumerate(data):
        if '1' not in row:
            continue
        dot = row.count('1')
        if dot == 1:  # B, D, F???????????????
            x = row.index('1')
            try:
                if data[i+2][x] == '1':
                    return 'B'
                elif data[i+1][x+1] == '1':
                    return 'F'
                else:
                    return 'D'
            except IndexError:
                return None
        else:  # A, C, E, G???????????????
            x = row.index('1')
            try:
                if data[i][x+2] == '1':
                    return 'C'
                elif data[i+1][x] == '0':
                    return 'E'
                elif data[i+1][x+1] == '1':
                    return 'A'
                else:
                    return 'G'
            except IndexError:
                return None


if __name__ == '__main__':
    data = []
    for line in sys.stdin:
        t = line.strip()
        if t:
            t = '00' + t + '00'
            data.append(t)
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')
        # data.append('00000000')


        # ???????????????
        if len(data) == 8:
            data.append('000000000000')
            data.append('000000000000')
            ans = analyze_figure(data)

            # ???????????¨???
            if ans:
                print(ans)
            data = []

Measured memory_bytes: 7488
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int gcd(int x, int y)
{
    if (y == 0)
        return x;
    else
        return gcd(y, x % y);
}

int gcd(vector<ll> v){
    int res = v[0];
    for (int num : v){
        res = gcd(res, num);
    }
    return res;
}

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


    int n;
    cin >> n;
    ll a;
    vector<ll> v;

    REP(i,n){
        cin >> a;
        v.emplace_back(a);
    }

    cout << gcd(v) << endl;

    return 0;

}

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

w = list(map(int, input().strip().split()))

sf = [0] * N
sb = [0] * N
sf[0] = w[0]
sb[N-1] = w[-1]
for i in range(1,N):
    sf[i] = sf[i-1] + w[i]
    sb[N-1-i] = sb[N-i] + w[N-1-i]

ans = [999999] * N
for i in range(N-1):
    ans[i] = abs(sf[i] - sb[i+1])

print(min(ans))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
#define add(x,y)(x=(x+y)%MOD)

ll a[1010];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	sortup(a,n);
	ll ans=0;
	rep(i,0,k)ans+=a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define SIZE 205
#define INF 1000000005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
vector <int> vx;
int H[SIZE];
ll dp[2][SIZE];
ll all[SIZE];
ll mpow(ll m,ll t){
	if(t==0) return 1LL;
	ll ret=mpow(m,t/2);
	ret=ret*ret%MOD;
	if(t%2==1) ret=ret*m%MOD;
	return ret;
}
int main(){
	int n;
	scanf("%d",&n);
	vx.push_back(INF);
	vx.push_back(1);
	for(int i=0;i<n;i++){
		scanf("%d",&H[i]);
		vx.push_back(H[i]);
	}
	sort(vx.begin(),vx.end());
	vx.erase(unique(vx.begin(),vx.end()),vx.end());
	int pos=0;
	for(int i=0;i+1<vx.size();i++){
		int low=vx[i]+1,up=vx[i+1];
		up=min(up,H[0]);
		if(low>up) dp[pos][i]=0;
		else{
			dp[pos][i]=2LL*(mpow(2,up-low+1)-1LL)%MOD*mpow(2,H[0]-up)%MOD;
		}
	}
	all[0]=2LL;
	for(int i=1;i<n;i++){
		pos^=1;
		memset(dp[pos],0,sizeof(dp[pos]));
		int t=lower_bound(vx.begin(),vx.end(),H[i])-vx.begin();
		for(int j=0;j+1<vx.size();j++){
			if(dp[pos^1][j]==0) continue;
			if(j+1<=t){
				ll vl=dp[pos^1][j];
				if(H[i-1]<H[i]) vl=vl*mpow(2,H[i]-H[i-1])%MOD;
				dp[pos][j]+=vl;
				if(dp[pos][j]>=MOD) dp[pos][j]-=MOD;
			}else{
				all[i]+=dp[pos^1][j]*2LL%MOD;
				if(all[i]>=MOD) all[i]-=MOD;
			}
		}
		if(all[i-1]!=0){
			for(int j=0;j+1<vx.size();j++){
				int low=vx[j]+1,up=vx[j+1];
				low=max(low,H[i-1]+1);
				up=min(up,H[i]);
				if(low<=up){
					dp[pos][j]+=all[i-1]*2LL%MOD*(mpow(2,up-low+1)-1LL)%MOD*mpow(2,H[i]-up)%MOD;
					if(dp[pos][j]>=MOD) dp[pos][j]-=MOD;
				}
			}
			all[i]+=all[i-1]*2LL%MOD;
			if(all[i]>=MOD) all[i]-=MOD;
		}
	}
	ll ret=all[n-1];
	for(int i=0;i+1<vx.size();i++){
		ret+=dp[pos][i];
		if(ret>=MOD) ret-=MOD;
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,count=0;
  cin>>n;
  for(long long i=1;i<=9;i++){
    for(long long j=i;j<=9;j++){
       if(n==(i*j)){
         cout<<"Yes"<<endl;
         count++;
         break;
       }
  }
  if(count!=0){
  	break;
  }
}
  if(count==0){
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std ;

const int MAX = 3e5 + 10 ;

int arr[MAX] , prefE[MAX] , prefW[MAX] , suffE[MAX] , suffW[MAX] ;
int n ;
string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	cin>>s ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(i != 0)
		{
			prefE[i] = prefE[i-1] ;
			prefW[i] = prefW[i-1] ;
		}
		if(s[i] == 'E')
			prefE[i]++ ;
		else
			prefW[i]++ ;
	}
	for(int i = n-1 ; i >= 0 ; --i)
	{
		if(i != n-1)
		{
			suffE[i] = suffE[i+1] ;
			suffW[i] = suffW[i+1] ;
		}
		if(s[i] == 'E')
			suffE[i]++ ;
		else
			suffW[i]++ ;
	}
	int ans = 1e9 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x = 0 , y = 0 ;
		if(i != 0)
			x = prefW[i-1] ;
		if(i != n-1)
			y = suffE[i+1] ;
		ans = min(ans , x+y) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

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

int check(long P, int A[], int n, int k) 
{
	int i = 0;
	for (int j = 0; j < k; j++) {
		long sum = 0;
		while (sum + A[i] <= P) {
			sum += A[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

long solve(int A[], int n, int k) 
{
	long left = 0;
	long right = n * 10000;
	long mid;
	while (right - left > 1) 
	{
		mid = (left + right) / 2;
		long t = check(mid, A, n, k);
		if (t >= n) right = mid;
		else left = mid;
	}
	return right;
}

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

	int A[100000] = { 0 };

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

	long ans = solve(A, n, k);
	cout << ans << endl;
}

Measured memory_bytes: 3476
s = input()

m_flag = [False, False]

if 1 <= int(s[:2]) <= 12:
    m_flag[0] = True

if 1 <= int(s[2:]) <= 12:
    m_flag[1] = True

if m_flag[0] and m_flag[1]:
    print("AMBIGUOUS")

if m_flag[0] and not m_flag[1]:
    print("MMYY")

if not m_flag[0] and m_flag[1]:
    print("YYMM")

if not m_flag[0] and not m_flag[1]:
    print("NA")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	n, _ := strconv.Atoi(line)
	if n%2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 10010010010
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


  



 int main(){
     int a,b,c; cin >> a >> b >> c;
     int ans = c - (a - b);
     if(ans < 0) ans = 0;
     cout << ans << endl;




 }



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		System.out.println(judge(sc.nextInt(), sc.nextInt(), sc.nextInt()));

		sc.close();
	}

	static String judge(int a, int b, int c) {
		for (int i = 1; i <= b; i++) {
			if (i * a % b == c) {
				return "YES";
			}
		}
		return "NO";
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

void solve(){
  ins(S);
  if(sz(S) == 2){
    die(S[0] == S[1] ? "1 2" : "-1 -1");
  }
  rep(i , sz(S) - 2){
    if(S[i] == S[i+2] || S[i] == S[i+1] || S[i+1] == S[i+2]){
      out(i+1,i+3);exit(0);
    }
  }
  out("-1 -1");
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String before, after;
    public static void main(String[] args) {
        read();
        slove();
    }
    static boolean read(){
        before = sc.nextLine();
        return true;
    }
    static void slove(){
        after = "";
        before = before.toLowerCase();
        for(int i = 0; i < before.length(); i++){
            char letter = before.charAt(i);
            char convert = (char)((letter -  'a' - 3 + 26)%26 + 'a');
            after += Character.toString(convert).toUpperCase();
        }

        System.out.println(after);
    }
}

Measured memory_bytes: 12000
#include<stdio.h>

int main(){
	char i[1001];
	int c,l;

	gets(i);
	for(c=0;c<1000;c++){
		if(i[c]=='a' && i[c+1]=='p' && i[c+2]=='p' && i[c+3]=='l' && i[c+4]=='e'){
			i[c]='p';
			i[c+1]='e';
			i[c+2]='a';
			i[c+3]='c';
			i[c+4]='h';
		} else if(i[c]=='p' && i[c+1]=='e' && i[c+2]=='a' && i[c+3]=='c' && i[c+4]=='h'){
			i[c]='a';
			i[c+1]='p';
			i[c+2]='p';
			i[c+3]='l';
			i[c+4]='e';
		}
	}
	printf("%s\n",i);
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
main(){

 int a,b;

 scanf("%d%d",&a,&b);

 if(a<b){
  printf("a < b\n");
 }
 else if(a > b){
  printf("a > b\n");
}
 else{
  printf("a == b\n");
}


return 0;

} 

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

int main() {
    int N; cin >> N;
    map<int, bool> A;
    bool res = true;
    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        if(A[a]) res = false;
        A[a] = true;
    }
    cout << (res ? "YES\n" : "NO\n");
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int char_count(string& l, char c) {
  int ret = 0;
  for (char x : l) {
    if (c == x) ret++;
  }
  return ret;
}

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

  long n;
  cin >> n;

  vector<string> lines(n);

  for (string& l : lines) {
    cin >> l;
  }

  vector<int> counts(26, 0);

  for (int i = 0; i < 26; i++) {
    int c = char_count(lines[0], 'a' + i);
    for (string& l : lines) {
      c = min(c, char_count(l, 'a' + i));
    }
    counts[i] = c;
  }
  
  for (int i = 0; i < 26; i++) {
    cout << string(counts[i], 'a' + i);
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int N;
	string S, T;
	cin >> N;
	cin >> S >> T;
	string ans;
	for (int i = 0; i < N; i++) {
		ans.pb(S[i]);
		ans.pb(T[i]);
	}
	puts(ans);


	return 0;
}

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

int main() {
	// your code goes here
	int n,d,arr[100][100],cnt=0;
	vector<int>vec;
	cin>>n>>d;
	int f;
	for(int i=0;i<n;++i)
	{
	    for(int j=0;j<d;++j)
	        cin>>arr[i][j];
	}
	for(int i=0;i<n;++i)
	{
	    for(int j=i+1;j<n;++j)
	    {
	        f=0;
	        for(int k=0;k<d;++k)
	           f+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
	         vec.push_back(f);
	    }
	}
	for(auto it=vec.begin();it!=vec.end();++it)
	{
	    if(sqrt(*it)-floor(sqrt(*it))==0)
	    cnt++;
	}
	cout<<cnt;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll n,m;
    cin >> n;
    
    map<string,int> sn;
    REP(i,n){
        string tmp;
        cin >> tmp;
        sn[tmp]++;
    }

    cin >> m;
    map<string,int> tm;
    REP(i,m){
        string tmp;
        cin >> tmp;
        tm[tmp]++;
    }

    ll MAX = -100000;
    ll count = 0;
    for(auto itr=sn.begin(); itr!=sn.end(); itr++){
        string key = itr->first;
        ll val = sn[key] - tm[key];
        MAX = max(MAX,val);
        count++;
    }
    if(MAX<0){
        MAX = 0;
    }
    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 3536
//31
#include<iostream>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
  pair<double,double> hx,hy,lx,ly;
  while(cin>>hx.first>>hy.first>>hx.second>>hy.second>>lx.first>>ly.first>>lx.second>>ly.second){
    if(hx<lx){
      swap(hx,lx);
    }
    if(hy<ly){
      swap(hy,ly);
    }
    cout<<((hx.first<=lx.second&&hy.first<=ly.second)?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
s = input()

dp = [0] * len(s)

t = 0
for i in range(len(s)):
    if s[i] == 'R':
        t += 1
    else:
        dp[i] += t // 2
        dp[i - 1] += (t + 1) // 2
        t = 0
t = 0
for i in range(len(s))[::-1]:
    if s[i] == 'L':
        t += 1
    else:
        dp[i] += t // 2
        dp[i + 1] += (t + 1) // 2
        t = 0

print(*dp)

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


//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int b=0;b<(1<<n);b++){
    cout<<b<<":";
    for(int i=0;i<n;i++)
      if((b>>i)&1) cout<<" "<<i;
    cout<<"\n";
  }
  cout<<flush;
  return 0;
}


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

int main(){
  vector<ll> p(12),q(12);
  p.at(0)=1;
  int i;
  for(i=1;i<12;i++){
    p.at(i)=p.at(i-1)*26;
  }
  q.at(1)=26;
  for(i=2;i<12;i++){
    q.at(i)=q.at(i-1)+p.at(i);
  }
  
  ll n,m;
  cin >> n;
  i=1;
  while(q.at(i)<n){
    i++;
  }
  m=i;
  n -= q.at(i-1)+1;
  string s="";
  for(i=0;i<m;i++){
    s += 'a'+n/p.at(m-1-i);
    n %= p.at(m-1-i);
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3596