akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main{
        
    public static void main(String[] args)throws IOException{
	br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
	String s = next();
	String a = next();
	int ans = 0;
	for(int i = 0 ; i<3;i++){
	    if(s.charAt(i)==a.charAt(i)){
		ans++;
	    }
	}
	out.println(ans);
	out.close();
    }
    
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");
    static String next()throws IOException{
	while(!st.hasMoreTokens()){
	    st = new StringTokenizer(br.readLine());
	}
	return st.nextToken();
    }
    static int nextInt()throws IOException{
	return Integer.parseInt(next());
    }
    static long nextLong()throws IOException{
	return Long.parseLong(next());
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

int W, H, a;
vector<long long> P, Q;
cin>>W>>H;
for(int i = 0; i < W; ++i){
cin>>a;
P.push_back(a);
}
for(int i = 0; i < H; ++i){
cin>>a;
Q.push_back(a);
}

sort(P.begin(), P.end());
sort(Q.begin(), Q.end());

long long ptr1, ptr2;
ptr1 = 0;
ptr2 = 0;
int c1 = W + 1;
int c2 = H + 1;
long long ans = 0;
while(ptr1 < W && ptr2 < H){
    if(P[ptr1] <= Q[ptr2]){
        ans += (long long)(c2 * P[ptr1++]);
        c1--;
    }
    else{
        ans += (long long)(c1 * Q[ptr2++]);
        c2--;
    }
}
while(ptr1 < W){
        ans += (long long)(c2 * P[ptr1++]);
        c1--;
}
while(ptr2 < H){
        ans += (long long)(c1 * Q[ptr2++]);
        c2--;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,d,i,j,k,l,ans=0;
  set<int> s;
  cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  for(i=0;i<n;i++) for(j=0;j<d;j++) cin>>x.at(i).at(j);
  for(i=0;i*i<=16000;i++) s.insert(i*i);
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      l=0;
      for(k=0;k<d;k++) l+=(x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      if(s.count(l)) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
   
 int64_t n,k,s,false_answer;
 cin>>n>>k>>s;
 if(s==1)false_answer=2;
 else false_answer=s-1;
 
 for(int i =0;i<k;i++){
     cout<<s<<" ";
 }
 if(n!=k){
 for(int i=0;i<n-k-1;i++){
     cout<<false_answer<<" ";
 }
 
 cout<<false_answer<<endl;
 }else cout<<endl;
 
 /*
 for(int i=0;i<k+1;i++){
     if(i%2==0)cout<<1<<" ";
    else cout<<s-1<<" ";
 }
 for(int i=0;i<n-k-2;i++){
     cout<<s+1<<" ";
 }
 cout<<s+1<<endl;
 */
    
    
}

Measured memory_bytes: 1280
import java.util.*;

class Main{
public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	  int a = scan.nextInt();
	  int b = scan.nextInt();
	if(1<=a && a<=9 && 1<=b && b<=9) {
		System.out.println(a * b);
	}else {
		System.out.println(-1);
	}
 }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>

int main(void){
    char n[3];
    scanf("%s",n);
    
    if(n[0] == n[1]&&n[1] ==n[2]){
        printf("No");
    }
    else{
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  B - Papers, Please
//
//  Created by Hashizo on 2020/02/16.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {

	ll n;
	cin >> n;

	vector<ll> point(n);
	REP(i, n) {
		cin >> point[i];
	}

	bool flag = true;
	REP(i, n) {
		if ( (point[i] % 2) == 0) {
			if ((point[i] % 3) != 0 && (point[i] % 5) != 0){
				flag = false;
				break;
			}
		}
	}
	
	if(flag == true) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
	return 0;
}


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

const ll MAX = 1e9;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

string S, T;

int main(){
    cin >> S >> T;

    if(S.size() < T.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    bool flg;
    for(int i = S.size() - T.size(); i >= 0; --i){
        flg = true;
        string ans;
        rep(j, T.size()){
            if(S[i + j] != '?' && S[i + j] != T[j]){
                flg = false;
                break;
            }
        }

        if(flg){
            rep(j, T.size()) S[i + j] = T[j];
            break;
        }
    }

    if(!flg){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    rep(i, S.size()){
        if(S[i] == '?') cout << 'a';
        else            cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c,d,sum,max;
    scanf("%d %d %d",&a,&b,&c);
    sum=a+b+c;
    max=a;
    if(b>max)max=b;
    if(c>max)max=c;
    d=(max*3)-sum;
    if(d%2)d+=3;
    printf("%d",(d/2));
    
}

Measured memory_bytes: 128
import sys

INF = 10**9+7

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def nal(): return list(map(int, stdin.readline().split()))
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())

a, b = stdin.readline().strip().split(' ')

if(a == 'H'):
    print(b)
else:
    if(b == 'H'):
        print('D')
    else:
        print('H')


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, y; cin >> n >> y;
    for(int i = 0; i * 10000 <= y; i++){
        for(int l = 0; (i*10000 + l * 5000) <= y; l++){
            if( (y-10000*i - 5000*l) % 1000 == 0 && i + l + (y-10000*i - 5000*l) / 1000 == n){
                cout << i << " " << l << " " <<(y-10000*i - 5000*l) / 1000  << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

struct vertex {
	int cnt;
	int ord;
	char ch;
	int bef_num;
	bool end;
	vector<int>next_v;
};


int N, Q, alp[26];
string S[100000];
vector<vertex>v;

void make_tree(int x, string &s, int p) {
	v[x].cnt++;
	if (s.size() == p + 1) {
		v[x].end = true;
		return;
	}
	for (int i : v[x].next_v) {
		if (s[p + 1] == v[i].ch) {
			make_tree(i, s, p + 1);
			return;
		}
	}
	v[x].next_v.push_back(v.size());
	v.push_back({ 0,p + 1,s[p + 1],x,false,{} });
	make_tree(v.size() - 1, s, p + 1);
}

int tourist(string &s, int x) {
	if (s.size() == v[x].ord + 1)return 1;
	int t = v[x].end;
	for (int i : v[x].next_v) {
		if (alp[v[i].ch - 'a'] < alp[s[v[i].ord]-'a']) {
			t += v[i].cnt;
		}
	}
	for (int i : v[x].next_v) {
		if (s[v[i].ord] == v[i].ch) {
			return t + tourist(s, i);
		}
	}
}

int main() {
	cin >> N;
	v.push_back({ 0,-1,'X',-1,false,{} });
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		make_tree(0, S[i], -1);
	}
	for (int i = 1; i < v.size(); i++) {
		if (v[v[i].bef_num].next_v.size() == 1 && v[i].next_v.size() == 1 && !v[i].end) {
			v[v[i].next_v[0]].bef_num = v[i].bef_num;
			for (int j = 0; j < v[v[i].bef_num].next_v.size(); j++) {
				if (v[v[i].bef_num].next_v[j] == i) {
					v[v[i].bef_num].next_v[j] = v[i].next_v[0];
					break;
				}
			}
		}
	}
	cin >> Q;
	while (Q--) {
		int k;
		cin >> k;
		k--;
		for (int i = 0; i < 26; i++) {
			char c;
			cin >> c;
			alp[c - 'a'] = i;
		}
		cout << tourist(S[k], 0) << endl;
	}
}

Measured memory_bytes: 83692
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String S=sc.next();
            int L=S.length();
            if(S.equals("-")) break;
            int N=sc.nextInt();
            for(int i=0;i<N;i++){
                int K=sc.nextInt();
                String S2=S.substring(K,L);
                S2+=S.substring(0,K);
                S=S2;
            }
            System.out.println(S);
        }
    }
}


Measured memory_bytes: 26364
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test"
#define pii pair <int, int>
#define XX first
#define YY second

int A[100005];
int n;

signed main()
{
#ifdef lowie
	freopen(FLN".inp", "r", stdin);
	freopen(FLN".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i];
	n++;
	
	int ttl=0;
	for (int i=1; i<=n; i++) ttl+=max(A[i]-A[i-1], A[i-1]-A[i]);
	for (int i=1; i<n; i++) cout<<ttl-max(A[i]-A[i-1], A[i-1]-A[i])-max(A[i]-A[i+1], A[i+1]-A[i])+max(A[i+1]-A[i-1], A[i-1]-A[i+1])<<"\n";
}

// PLEASE REMOVE "cout" AND "cerr" DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/

Measured memory_bytes: 2048
import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        input >>= return . solve >>= output
        main

input :: IO (Double)
input = readLn

output :: Int -> IO ()
output = print

solve :: Double -> Int
solve v_crash = max 1 (ceiling ((h_crash + 5.0)/ 5.0))
    where
    h_crash = 4.9 * t * t
    t = v_crash / 9.8

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
int rev=0,q,l,r;
char str[1000005],tmp[1000005];
int main(){
	scanf("%s%d",tmp+1,&q);
	int n=strlen(tmp+1);
	for(int i=500000-n+1;i<=500000;i++)str[i]=tmp[i-500000+n];
	l=500000-n+1,r=500000;
	for(int i=1;i<=q;i++){
		int opt,o;
		char s[2];
		scanf("%d",&opt);
		if(opt==1)rev^=1;
		else {
			scanf("%d%s",&o,s);
			if(o==1){
				if(rev)str[++r]=s[0];
				else str[--l]=s[0];
			}
			else {
				if(!rev)str[++r]=s[0];
				else str[--l]=s[0];
			}
		}
	}
	if(rev)for(int i=r;i>=l;i--)cout<<str[i];
	else for(int i=l;i<=r;i++)cout<<str[i];
}


Measured memory_bytes: 896
import os
N=int(input())
a=list(map(int, input().split()))
if not (a[0]==0):
  print(0)
else:
  m=max(a)
  b=[0]*m
  flag=True
  for i in a[1:]:
    if i==0:
      print(0)
      flag=False
    b[i-1]+=1
  if flag:
    res=1
    #print(b)
    for i in range(1,len(b)):
      res*=b[i-1]**b[i]

    print((res)%998244353)

Measured memory_bytes: 56244
#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() {
  string S;
  cin >> S;

  set<char> s;
  rep(i, S.size()) {
    s.insert(S[i]);
  }

  bool nExists = s.count('N') > 0;
  bool sExists = s.count('S') > 0;
  bool eExists = s.count('E') > 0;
  bool wExists = s.count('W') > 0;

  bool nsOk = (nExists && sExists) || (!nExists && !sExists);
  bool ewOk = (eExists && wExists) || (!eExists && !wExists);

  if (nsOk && ewOk) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(){
	set<string>s;
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		string str;
		cin>>str;
		s.insert(str);
	}
	cout<<s.size();
}

Measured memory_bytes: 15692
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    int x;
    cin >> x;
    cout << x/11*2+((x-x/11*11)?(x-x/11*11 <= 6)?1:2:0) << endl;
}


Measured memory_bytes: 3608
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	n := len(s)
	if isP(s) && isP(s[0:n/2]) && isP(s[n/2+1:]) {
		fmt.Fprintln(writer, "Yes")
		return
	}
	fmt.Fprintln(writer, "No")
}

func isP(s string) bool {
	n := len(s)
	for i := 0; i < n/2; i++ {
		if s[i] != s[n-1-i] {
			return false
		}
	}

	return true
}


Measured memory_bytes: 640
n,a=int(input()),sorted(list(map(int,input().split())))
q,p=b,c=a[0],a[-1]
d=a[1:-1]
for i in d:
  if i<0:p-=i
  else:q-=i
print(p-q)
for i in d:
  if i<0:print(c,i);c-=i
  else:print(b,i);b-=i
print(c,b)

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

long long gcd(int a, int b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}
long long addgcd(int a, int b, int c)
{
    long long result = gcd(a, b);
    result = gcd(result, c);
    return result;
}

int main()
{
    long long n, m, sum;
    sum = 0;
    cin >> n >> m;
    int a[m];
    rep(i, m)
    {
        cin >> a[i];
    }
    rep(i, m)
    {
        sum += a[i];
    }
    if (n < sum)
    {
        cout << "-1";
    }
    else
    {
        cout << n - sum;
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  cout << n + n*n + n*n*n << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;


#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/




ll a[N],b[N];




int main()
{
    char c;
    cin>>c;
    ll k = c-'0';
    if(k<=42)cout<<"A"<<endl;
    else cout<<"a"<<endl;
	return 0;
}








Measured memory_bytes: 3608
#include <iostream>
#include <vector>
static const int N_MAX=100001;

using namespace std;

int N,M;
vector<int>G[N_MAX];
int H[N_MAX];



void solve(){
  
  int res=0;
  
  for(int i=1;i<=N;i++){
    bool highest=true;
    for(int j=0;j<G[i].size();j++){
      if(H[i]<=H[G[i][j]]){highest=false; break;}
    }
    if(highest==true) res+=1;
  }
  printf("%d",res);
}

int main(){
  
  cin>>N>>M;
  int h;
  for(int i=1;i<=N;i++){
    cin>>h;
    H[i]=h;
  }
  int u,v;
  for(int i=0;i<M;i++){
    cin>>u>>v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  solve();
  return 0;
}
    

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
                System.out.println(a+" "+b+" "+c);
            }
            else if(a < c){
                System.out.println(a+" "+c+" "+b);
            }
            else{
                System.out.println(c+" "+a+" "+b);
            }
        }
        else if(a > b){
            if(b > c){
                System.out.println(c+" "+b+" "+a);                
            }
            else if(a < c){
                System.out.println(b+" "+a+" "+c);
            }
            else{
                System.out.println(b+" "+c+" "+a);
            }
        }
    } 
}


Measured memory_bytes: 26348
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 4
ABC
A L
B L
B R
A R
)");
#define cin input
#endif

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

	string s;
	cin >> s;

	vector<pair<char, char>> v(q);

	for (auto& p : v)
		cin >> p.first >> p.second;

	reverse(v.begin(), v.end());

	int r = 0;

	int i = 0;
	for (auto p : v)
	{
		if (p.first == s[i] && p.second == 'L')
			++i;
		if (i && p.first == s[i - 1] && p.second == 'R')
			--i;
		if (i == n)
			break;
	}
	r += i;

	i = n - 1;
	for (auto p : v)
	{
		if (p.first == s[i] && p.second == 'R')
			--i;
		if (i != n - 1 && p.first == s[i + 1] && p.second == 'L')
			++i;
		if (i == -1)
			break;
	}
	r += n - 1 - i;
	r = n - min(n, r);

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 1028
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 800005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;


void solve()
{
    lli n;
    cin>>n;
    if(n<=1)
    {
        cout<<0;
        return ;
    }
    lli prod=1,o=1,t=1,ot=1;
    lli tot=1;
    for(lli i=1;i<=n;i++)
    {
        tot=((tot%M)*10)%M;
        o=((o%M)*9)%M;
        t=((t%M)*9)%M;
        ot=((ot%M)*8)%M;
    }
    lli ans=(tot%M-(o%M+t%M-ot%M+M)%M+M)%M;

    cout<<ans;
   





}



int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif
     // test
     {
        solve();
        nl
     }
    
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

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

const int UnionFindmax = 100010;
int UnionFind[UnionFindmax], Rank[UnionFindmax];

void UnionFindreset() {
	for (int i = 0; i < UnionFindmax; i++) {
	UnionFind[i] = i;
	Rank[i] = 0;
	}
}

int UnionFindroot(int x) {
	if (UnionFind[x] == x) {
		return x;
	}
	else {
		return UnionFind[x] = UnionFindroot(UnionFind[x]);
	}
}

bool UnionFindsame(int x, int y) {
	return UnionFindroot(x) == UnionFindroot(y);
}
void UnionFindconnect(int x, int y) {
	x = UnionFindroot(x);
	y = UnionFindroot(y);
	if (x == y) return;
	
	if (Rank[x] < Rank[y]) {
		UnionFind[x] = y;
	}
	else {
		UnionFind[y] = x;
		if (Rank[x] == Rank[y]) Rank[x]++;
	}
}


int main() {
	int N, M;
	cin >> N >> M;
	vector<int> p(N), x(M), y(M);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
	}
	for (int i = 0; i < M; i++) {
		cin >> x.at(i) >> y.at(i);
	}
	UnionFindreset();
	for (int i = 0; i < M; i++) {
		UnionFindconnect(x.at(i), y.at(i));
	}
	int counter = 0;
	for (int i = 0; i < N; i++) {
		if (UnionFindsame(p.at(i), i+1)) {
			counter++;
		}
	}
	cout << counter << endl;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input!{
      a: usize,
      b: usize,
      k: usize,
    }
    let mut nums = vec![];
    for i in 1..101 {
        if a%i == 0 && b%i==0 {
            nums.push(i);
        }
    }
    nums.sort();
    nums.reverse();
    println!("{}", nums[k-1]);
}


Measured memory_bytes: 4352
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut c=0;
    for i in 1..read::<i32>()+1{
        let mut m=0;
        for j in 1..i+1{if i%j<1{m+=1}}
        if i%2>0&&m==8{c+=1}
    }
    println!("{}",c)
}


Measured memory_bytes: 4352
#include <stdio.h>
long long n, m, i, j, k, a,b, ans;
int main(){
	scanf("%lld", &n);
	for(i=1; i<=n; i++){
		//1  n-i+1  n-i+1
		ans += (n-i+2)*(n-i+1)/2;
	}
	for(i=1; i<n; i++){
		scanf("%lld%lld", &a, &b);
		if(a > b) k=a, a=b, b=k;
		ans -= a * (n-b+1);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1736
N, M = map(int, input().split())
es = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, used):
    cnt = 0
    used[v] = 1
    if all(used):
        cnt+=1
    for nv in es[v]:
        if used[nv]:
            continue
        cnt += dfs(nv, used)
    used[v] = 0
    return cnt

used = [0] * N
cnt = dfs(0, used)
print(cnt)


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();
		int M=nextInt();

		int[] H = nextInts();
		int[] A = new int[M];
		int[] B = new int[M];
		boolean[] x = new boolean[N];
		Arrays.fill(x, true);
		for(int i=0;i<M;i++){
			A[i]=nextInt();
			B[i]=nextInt();
			if(H[A[i]-1]==H[B[i]-1]){
				x[A[i]-1]=false;
				x[B[i]-1]=false;
			}else if(H[A[i]-1]>H[B[i]-1]){
				x[B[i]-1]=false;
			}else{
				x[A[i]-1]=false;
			}
		}
		long ans = 0;
		for(int i=0;i<N;i++){
			if(x[i]){
				ans++;
			}
		}
		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 48972
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	long long  n,m,l[100005],r[100005],cnt=0,sum[100001],cnt1[1000];
	cin>>n>>m>>s;
	for(int i=1;i<n;i++){
		if(s[i]=='C'&&s[i-1]=='A')
			cnt++;		
			sum[i]=cnt;
	}
		for(int i=0;i<m;i++){
			cin>>l[i]>>r[i];
		}
			for(int i=0;i<m;i++){
				cout << sum[r[i] - 1]-sum[l[i] - 1] << endl;
			}
		}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool judge(string s) {
    int n = s.size();
    string t1 = s.substr(0, n / 2);
    string t2 = s.substr(n / 2, n - n / 2 + 1);
    return (t1 == t2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 1; i <= n; i++) {
        if(judge(s.substr(0, n - i))) {
            cout << n - i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
import java.util.HashSet;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int i;
		HashSet<Integer> set = new HashSet<>();
		for(i = 0; i < n; i++) {

			set.add(scan.nextInt());
		}
		if(n == set.size())
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 98612
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> p(N);
  rep(i,N) {
    cin >> p[i].F >> p[i].S;
  }
  sort(all(p));
  long double ans = 0.0;
  long double n = 0;
  do{
    for(int i = 0; i < N-1; i++){
      ans += sqrt((double)(p.at(i).F - p.at(i+1).F)*(p.at(i).F - p.at(i+1).F) + (p.at(i).S - p.at(i+1).S)*(p.at(i).S - p.at(i+1).S));
    }
    n++;
  }while(next_permutation(all(p)));


  ans = ans/n;

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] libra = new int[4];
		for(int i=0; i<libra.length; i++){
			libra[i] = sc.nextInt();
		};
		int left = libra[0] + libra[1];
		int right = libra[2] + libra[3];
		if(left == right) {
			System.out.println("Balanced");
		} else if(left > right) {
			System.out.println("Left");
		} else {
			System.out.println("Right");
		}
	}
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

func main() {
	var n, a int
	fmt.Scan(&n)

	var as = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		as[i] = a
	}

	res, right, xor, sum := 0, 0, 0, 0
	for left := 0; left < n; left++ {
		for ; right < n && xor ^ as[right] == sum + as[right]; right++ {
			xor ^= as[right]
			sum += as[right]
		}

		res += right - left

		if left == right {
			right++
		} else {
			xor ^= as[left]
			sum -= as[left]
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 5760
#include <stdio.h>
int main(void){
	double s;
	int a,w,h,x,y;
	
	scanf("%d %d %d %d",&w,&h,&x,&y);
	
	s = (double) w * h / 2;
	
	if(2*x == w && 2*y == h ) a = 1;
	else a = 0;
	printf("%lf %d\n",s,a);
	return 0;
}

Measured memory_bytes: 128
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    n = II()
    s = IS()
    c = [str(i).zfill(3) for i in range(1000)]
    cnt = 0
    for ci in c:
        id_1 = s.find(ci[0])
        if id_1 == -1: continue
        id_2 = s.find(ci[1], id_1+1)
        if id_2 == -1: continue
        id_3 = s.find(ci[2], id_2+1)
        if id_3 == -1: continue
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

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

int main(){
    int N;
  	cin >> N;
    int max_a = -1000000 ;
    int min_a = 1000000 ;
    long long sum = 0;

    for ( int i = 0 ; i < N ; i++ ){
        int a;
        cin >> a;
        max_a = max(max_a,a);
        min_a = min(min_a,a);
        sum += (long long)a;
    }

    cout << min_a << " " << max_a << " " << sum << endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int T;
ll n,a,b,c,d;
map<ll,ll> mp;
ll solve(ll n){
    if(n==0)return 0ll;
    if(n==1)return d;
    if(mp.count(n))return mp[n];
    ll res=1e18;
    if(d<=res/n)res=d*n;
    res=min(res,solve(n/2)+n%2*d+a);
    res=min(res,solve((n+1)/2)+(2-n%2)%2*d+a);
    res=min(res,solve(n/3)+n%3*d+b);
    res=min(res,solve((n+2)/3)+(3-n%3)%3*d+b);
    res=min(res,solve(n/5)+n%5*d+c);
    res=min(res,solve((n+4)/5)+(5-n%5)%5*d+c);
    return mp[n]=res;
}
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
        mp.clear();
        printf("%lld\n",solve(n));
    }
    return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int N;
  cin>>N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  
  int Q;
  cin>>Q;
  
  vector<vector<int>> vec(Q,vector<int>(2));
  for(int i=0;i<Q;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  
  long long sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  
  vector<int> app(100000,0);
  for(int i=0;i<N;i++){
    app[A[i]-1]++;
  }
  
  
  for(int i=0;i<Q;i++){
    sum=sum+(vec[i][1]-vec[i][0])*app[vec[i][0]-1];
    cout<<sum<<endl;
    app[vec[i][1]-1]+=app[vec[i][0]-1];
    app[vec[i][0]-1]=0;
  }
}

Measured memory_bytes: 9536
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int x = n%10;
      if(x==2 || x==4 || x==5 || x==7 || x==9){
      	System.out.println("hon");
      }else if(x==3){
        System.out.println("bon");
      }else{
        System.out.println("pon");
      }
    }
}


Measured memory_bytes: 35700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define soja(i,a,n) for(ll i=a;i<=n;i++)
#define ulta(i,n,a) for(ll i=n;i>=a;i--)
int main()
{
    ll n,m,k,sum=0,t;
   cin>>n;
   map<ll,ll> ma;
   soja(i,0,n-1)
   {
       cin>>k;
       if(ma[k]==INT_MAX)
        ma[k]=1;
       else
        ma[k]++;
        sum+=k;
   }
   cin>>t;
   soja(i,0,t-1)
   {
       cin>>n>>m;
       sum-=ma[n]*n;
       sum+=ma[n]*m;
       if(ma[m]==INT_MAX)
        ma[m]=ma[n];
       else
       ma[m]+=ma[n];
       ma[n]=0;
      // cout<<ma[m]<<" "<<ma[n]<<endl;
       cout<<sum<<endl;
   }

return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n - 2; i++) {
    if (s.substr(i, 3) == "ABC") {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  long long a,b,c;
  cin >>a>>b>>c;
  long long left =4*a*b;
  long long x=(c-a-b);
  long long right =x*x;
  if (x>0 && left < right){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> inputString = Arrays.asList(br.readLine().split(" "));
            int targetCakePieceA = Integer.parseInt(inputString.get(0));
            int targetCakePieceB = Integer.parseInt(inputString.get(1));

            String result = ":(";
            if (targetCakePieceA + targetCakePieceB <= 16 && targetCakePieceA <= 8 && targetCakePieceB <= 8) {
                result = "Yay!";
            }
            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main()
{
    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    if (U == S)
    {
        cout << A - 1 << " " << B << endl;
    }
    else if (U == T)
    {
        cout << A << " " << B - 1 << endl;
    }
}

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

int main() {

  string s;
  cin >> s;

  if (s == "MON") {
    cout << 6 << endl;
  } else if (s == "TUE") {
    cout << 5 << endl;
  } else if (s == "WED") {
    cout << 4 << endl;
  } else if (s == "THU") {
    cout << 3 << endl;
  } else if (s == "FRI") {
    cout << 2 << endl;
  } else if (s == "SAT") {
    cout << 1 << endl;
  } else if (s == "SUN") {
    cout << 7 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld double
using namespace std;
int main() {
    int n,x;
    cin>>n>>x;
    int h[n];
    for(int i = 0;i<n;i++){
        cin>>h[i];
    }
    int ans[n];
    ans[0] = 0;
    ans[1] = abs(h[0] - h[1]);
    for(int i = 2;i<n;i++){
        ans[i] = 1e9;
        for(int j = i-1 ;j>= max(0,i-x) ; j--){
            ans[i] = min(ans[j]+abs(h[j] - h[i]) , ans[i]);
        }
    }
    cout<<ans[n-1];
    return 0;
}


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

const ll INF = 1LL << 60;

ll K, cnt;
vector<ll> v;

int main() {
    cin >> K;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 1; i <= 9; i++) {
        pq.push(i);
    }


    ll ans = 0;
    ll cnt = 0;
    while (cnt < K) {
        ll a = pq.top(); pq.pop();
        if (a > 0) {
            cnt++;
        }
        if (cnt == K) {
            ans = a;
            break;
        }
        string target = to_string(a);
        // cout << target.size() << endl;
        ll keta = target.size();
        ll last = target[keta - 1] - '0';
        // 1文字
        if (last + 1 <= 9) {
            ll tmp = stol(target + to_string(last + 1));
            pq.push(tmp);
        }

        ll tmp = stol(target + to_string(last));
        pq.push(tmp);

        if (last - 1 >= 0) {
            ll tmp = stol(target + to_string(last - 1));
            pq.push(tmp);
        }
    }

    cout << ans << endl;
    // while (pq.size() > 0) {
    //     int a = pq.top(); pq.pop(); 
    //     cout << a << endl;
    // }
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int W, H, N; cin >> W >> H >> N;
  vector<vector<int>> sq(H,vector<int>(W,0));
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  rep(i,N){
    cin >> x[i] >> y[i] >> a[i];
  }
  rep(k,N){
    if(a[k]==1){
      rep(i,H) rep(j,W){
        if(j<x[k]) sq[i][j] = 1;
      }
    }
    if(a[k]==2){
      rep(i,H) rep(j,W){
        if(j>=x[k]) sq[i][j] = 1;
      }
    }
    if(a[k]==3){
      rep(i,H) rep(j,W){
        if(i>=H-y[k]) sq[i][j] = 1;
      }
    }
    if(a[k]==4){
      rep(i,H) rep(j,W){
        if(i<H-y[k]) sq[i][j] = 1;
      }
    }
  }
  int ans = 0;
  rep(i,H){
    rep(j,W){
      //cout << sq[i][j] << " ";
      if(sq[i][j]==0)ans++;
    }
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define im(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll r = a * c;
	r = max(r, a * d);
	r = max(r, b * c);
	r = max(r, b * d);
	cout << r << nl;
}


Measured memory_bytes: 3564