akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char a[10], b[10];
int main(){
	scanf("%s%s", a + 1, b + 1);
	for(int i = 1; i <= 3; ++i) if(a[i] != b[3 - i + 1]) return puts("NO") & 0;
	puts("YES");
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>  
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i = a; i <=b; i++)
#define rep2(i,a,b) for(int i = a; i>=b; i--)
#define PB push_back 
#define MP make_pair
#define db long double
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define INF 2000000000
const double PI = acos(-1);
const int N = 100005;
#define eps 1e-6
#define MOD 1000000007
  int32_t main() 
  {
    IOS



        int n,m;
        cin >> n >> m;
        if(m == n)
        {
          cout << "Yes";
        }
        else
        {
          cout << "No";
        }


    return 0;
      }
        

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

vector<int> primes;
int check[10000001];

void find_multiples(int num, int end)
{
	for (int i = 2 * num; i <= end; i += num)
	{
		check[i] = 0;
	}
}

void sieve(int start, int end)
{
	for (int i = 0; i <= end; i++)
	{
		check[i] = 1;
	}

	for (int i = 2; i <= end; i++)
	{
		if (check[i])
		{
			find_multiples(i, end);
		}
	}

	for (int i = start; i <= end; i++)
	{
		if (check[i]) primes.push_back(i);
	}
}

int main()
{	
    int x;
    cin >> x;
	sieve(0, 10000000);

	for (int i = 0; i < primes.size(); i++)
	{
		if (primes[i] >= x)
        {
            cout << primes[i] << endl;
            return 0;
        }
	}
}

Measured memory_bytes: 46480
// hhttps://atcoder.jp/contests/apg4b/tasks/APG4b_ca
// g++ -std=c++11 ex22.cpp && ./a.out
#include <vector>
#include <tuple>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cmath>

using namespace std;

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

    double ell = log(N) / log(K);
    cout << int(ell) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] arr1 = in.next().toCharArray();
            char[] arr2 = in.next().toCharArray();
            int len = arr1.length;
            int ans = 0;

            for (int i = 0; i  < len; i++) {
                if (arr1[i] != arr2[i]) {
                    ans++;
                }
            }

            out.println(ans);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException 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());
        }

    }

}

Measured memory_bytes: 39256
#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define ll long long
using namespace std;
typedef pair<char,int> pii;
set<ll>mapa;
const int maxv=2300000;
int n,pos[maxv+10],br;
ll primes[maxv],rows[1010],cols[1010],aa[519][510];
vector<ll>a[510][510];
void check(){

ll maxx=LONG_MIN;
ll minn=LONG_MAX;
set<ll>mapa2;
    for(int i=1;i<=n;i++){

        for(int j=1;j<=n;j++){

            if(i<n){
                mapa.insert(max(aa[i][j],aa[i+1][j])%min(aa[i][j],aa[i+1][j]));
            }
            if(j<n){
                mapa.insert(max(aa[i][j],aa[i][j+1])%min(aa[i][j],aa[i][j+1]));
            }

            maxx=max(maxx,aa[i][j]);
            minn=min(minn,aa[i][j]);
            mapa2.insert(aa[i][j]);
        }

    }
printf("%d %d %lld %lld\n",mapa.size(),mapa2.size(),maxx,minn);
}
void sito(){

    for(int i=2;i<=maxv;i++){
        if(pos[i])continue;
        primes[++br]=i;
        for(int j=i;j<=maxv;j+=i)pos[j]=1;
    }

}
ll lcm(ll a,ll b){
  return (a/__gcd(a,b))*b;
}
void fix(int x,int y){

    ll lc=1;

    if(aa[x+1][y]!=0){lc=lcm(lc,aa[x+1][y]);}
    if(aa[x-1][y]!=0){lc=lcm(lc,aa[x-1][y]);}
    if(aa[x][y+1]!=0){lc=lcm(lc,aa[x][y+1]);}
    if(aa[x][y-1]!=0){lc=lcm(lc,aa[x][y-1]);}

    aa[x][y]=lc+1;
}
int dist(int x,int y,int x1,int y1){
   return abs(x-x1)+abs(y-y1);
}
int main(){

    ///freopen("test.txt","r",stdin);

    scanf("%d",&n);

    if(n==2){
        printf("4 7\n23 10\n");
        return 0;
    }

    sito();

    int curr=0;
    for(int i=0;i<n;i++)
        rows[i*2]=primes[++curr];

    for(int i=0;i<n;i++)
        cols[i*2]=primes[++curr];

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){

            if(dist(1,1,i,j)%2==0){
                a[i][j].pb(rows[dist(1,1,i,j)]);
                aa[i][j]=rows[dist(1,1,i,j)];
            }

        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){

            if(n%2){
               if(dist(n,1,i,j)%2==0){
                a[i][j].pb(cols[dist(n,1,i,j)]);
                aa[i][j]*=cols[dist(n,1,i,j)];
               }
            }
            else{
                if(dist(n,1,i,j)%2==1){
                    a[i][j].pb(cols[dist(n,1,i,j)-1]);
                    aa[i][j]*=cols[dist(n,1,i,j)-1];
                }
            }

        }
    }


    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if((i+j)%2)fix(i,j);
            printf("%lld ",aa[i][j]);
        }
        printf("\n");
    }


    return 0;
}


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

int main() {
  int H, N, B;
  int A = 0;
  cin >> H >> N;

  for (int i = 0; i < N; i++) {
    cin >> B; 
    A += B;
  }
  
  if (A >= H) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int main(){
        ll n, q;
        scanf("%ld %ld", &n, &q);

        std::vector<std::vector<ll>> links(n, std::vector<ll>(0));
        for(ll i=0; i<n-1; i++){
                ll a, b;
                scanf("%ld %ld", &a, &b);
                links[a-1].push_back(b-1);
                links[b-1].push_back(a-1);
        }

        std::vector<ll> cost(n);
        for(ll i=0; i<q; i++){
                ll p, x;
                scanf("%ld %ld", &p, &x);
                cost[p-1] += x;
        }

        std::queue<P> que;
        que.push(P(0,0));
        std::vector<bool> used(n, 0);
        while(!que.empty()){
                P p = que.front(); que.pop();
                used[p.first] = 1;
                cost[p.first] += p.second;
                for(ll apex: links[p.first]){
                        if(!used[apex]) que.push(P(apex, cost[p.first]));
                }
        }

        for(ll i=0; i<n; i++) printf("%ld\n", cost[i]);
        return 0;
}

Measured memory_bytes: 19568
#include <stdio.h>

int main(void)
{
	char str[20][20];
	int sum[9], sum2[9], mor, aft;
	int i;
	
	for (i = 0; i < 9; i++){
		scanf("%s %d %d", str[i], &mor, &aft);
		
		sum2[i] = mor + aft;
		sum[i] = mor * 200 + aft * 300;
	}
	for (i = 0; i < 9; i++){
		printf("%s %d %d\n", str[i], sum2[i], sum[i]);
	}
	return (0);
}

Measured memory_bytes: 596
N = int(input())
A = list(map(int,input().split()))

ma = max(A)
Er = [0 for _ in range(ma + 5)]
is_c = [0 for _ in range(ma + 5)]

for i in range(N):
    temp = A[i]
    if Er[temp] != 2:
        a = 0
        while(1):
            a += 1
            tt = a * temp
            if tt >= ma + 5:
                break
            Er[tt] += 1
        
ans = 0
for i in range(N):
    temp = A[i]
    is_c[temp] += 1
    if is_c[temp] == 2:
        continue  
    if Er[temp] == 1:  ans += 1
        
print(ans)

Measured memory_bytes: 217100
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define pr(x) cout<<#x<<" "<<x;
#define pl(x) cout<<#x<<" "<<x<<endl;
#include<math.h>
#include<algorithm>
using namespace std;
int num[10];
bool dfs(int step,int btop,int ctop){
    if(step==9){
        if(num[step]>btop||num[step]>ctop){
            return true;
        }
        else return false;
    }
    bool b = false;
    bool c = false;
    if(num[step]>btop){b = dfs(step+1,num[step],ctop);}
    if(num[step]>ctop){c = dfs(step+1,btop,num[step]);}

    return (b||c);

}

int main(){
    int t;
    cin>>t;
    while(t--){
      memset(num,0,sizeof(num));
      for(int i = 0;i<10;i++){
        cin>>num[i];
      }
      bool ans = dfs(0,0,0);
      if(ans){cout<<"YES"<<endl;continue;}
      else{cout<<"NO"<<endl;continue;}


    }

}

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

int main()
{
	string a, b, c;
	cin >> a >> b >> c;

	if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#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 N;
    cin >> N;
    vector<vector<int>>cnt(10,vector<int>(10));
    for(int i = 1; i <= N; i++) {
        string T = to_string(i);
        cnt[T[0]-'0'][T[T.size()-1]-'0']++;
    }
    int ans = 0;
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
<?php

$max = trim(fgets(STDIN));
$numbers = explode(' ', trim(fgets(STDIN)));

if(in_array(0, $numbers))
{
  echo '0' . PHP_EOL;
  return;
}

$result = 1;

foreach($numbers as $number)
{
  // echo $result * $number . PHP_EOL;
  // echo '割り算: ' . (pow(10, 18) / $result) . ' result: ' . $result . ' number: ' . $number . PHP_EOL;
  if(intdiv(pow(10, 18) , $result) < $number)
  {
    echo '-1' . PHP_EOL;
    return;
  }
  $result *= $number;
}

echo $result . PHP_EOL;


Measured memory_bytes: 25436
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    se = input().rstrip()

    S = "S" in se
    N = "N" in se
    E = "E" in se
    W = "W" in se

    if (S ^ N) or (E ^ W):
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61868
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL a[4320];
LL p = 0;

vector<int> ans;
vector<pair<LL, LL>> nums;
int maxdp[4040];
int dp[4040][4040];
int n;
bool comp(const pair<LL, LL> &x, const pair<LL, LL> &y){
    if(a[x.second] - a[x.first - 1] == a[y.second] - a[y.first - 1]){
        return x > y;
    }
    return a[x.second] - a[x.first - 1] < a[y.second] - a[y.first - 1];
}

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> a[i];
    for(int i = 1;i <= n;i++)a[i] += a[i-1];
    for(int i = 1;i <= n;i++){
        for(int j = i;j <= n;j++){
            nums.emplace_back(pair<LL, LL>(i, j));
        }
    }
    sort(ALL(nums), comp);
    REP(i, (int)nums.size()){
        int from = nums[i].first;
        int to = nums[i].second;
        if(from == 1){
            dp[from][to] = 1;
        }
        else if(maxdp[from - 1]){
            dp[from][to] = max(maxdp[from - 1] + 1, dp[from][to]);
        }
        maxdp[to] = max(maxdp[to], dp[from][to]);
    }
    int m = maxdp[n];
    cout << m << endl;
    for(int x = n;x >= 1;){
        for(int j = x;j >= 0;j--){
            if(dp[j][x] == m){
                m--;
                ans.emplace_back(j);
                x = j - 1;
                break;
            }
        }
    }   
    for(int i = ans.size() - 2;i >= 0;i--){
        cout << ans[i] - 1;
        if(i)cout << " ";
    }       
    cout << endl;
    return 0;
}


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

int main()
{
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
    sort(A,A+N);
    int Count=0;
    for(int i=0;i<N;)
    {
        int Value=A[i];
        int Freq=upper_bound(A,A+N,Value)-lower_bound(A,A+N,Value);
        if(Freq%2==1)
        {
            Count++;
            i=i+Freq;
        }
        else
        {
            i=i+Freq;
        }
    }
    cout<<Count<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
const int N=1e4+10;
const int INF=1e9+10;
int min(int a,int b){return a>b?b:a;}
int main(){
    int n,w,dp[N],x,y;
    scanf("%d%d",&n,&w);
    for(int i=1;i<N;i++)dp[i]=INF;
    dp[0]=0;
    while(n--){
        scanf("%d%d",&x,&y);
        for(int j=N-1;j>=x;j--)dp[j]=min(dp[j],dp[j-x]+y);
    }
    for(int i=N-1;i>=0;i--)if(dp[i]<=w){
        printf("%d\n",i);
        return 0;
    }
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int a,b;cin>>a>>b;
  int ans;
  if(b%a==0){
  	ans=a+b;
  }else{
  	ans=b-a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
typedef pair<int, int> p;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n>>m;
	vector<p> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end(),greater<p>());
	int ans = 1;
	int hasi = a[0].first+1;
	for (int i = 0; i < a.size(); i++) {
		if (hasi > a[i].second) {
			hasi = a[i].first+1;
			ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int K;
  cin>>K;
  queue<string> que;
  que.push("1");
  que.push("2");
  que.push("3");
  que.push("4");
  que.push("5");
  que.push("6");
  que.push("7");
  que.push("8");
  que.push("9");
  string state;
  string ans;
  for(int i=1;i<=K;++i) {
    state = que.front();que.pop();
    if(i==K) ans = state;
    if(state[state.size()-1]=='0') {
      state.push_back('0');
      que.push(state);
      state.pop_back();
      state.push_back('1');
      que.push(state);
      state.pop_back();
    }
    else if(state[state.size()-1]=='9') {
      state.push_back('8');
      que.push(state);
      state.pop_back();
      state.push_back('9');
      que.push(state);
      state.pop_back();
    }
    else {
      state.push_back(state[state.size()-1]-1);
      que.push(state);
      state.pop_back();
      state.push_back(state[state.size()-1]);
      que.push(state);
      state.pop_back();
      state.push_back(state[state.size()-1]+1);
      que.push(state);
      state.pop_back();
    }
  }
  cout<<ans<<endl;
}



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

using namespace std;

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

  int count_A = 0;
  int64_t answer = 0;

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'A') {
      count_A++;
    } else if (i + 1 < S.length() && S[i] == 'B' && S[i + 1] == 'C') {
      answer += count_A;
      i++;
    } else {
      count_A = 0;
    }
  }

  cout << answer << endl;

  return 0;
}


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

constexpr int INF = 1e9;

int main() {
    int n;
    while(cin >> n, n) {
        map<string, int> cost;
        for(int i=0; i<n; ++i) {
            string s;
            int p;
            cin >> s >> p;
            cost[s] = p;
        }
        map<string, vector<string>> recipe;
        int m;
        cin >> m;
        for(int i=0; i<m; ++i) {
            string o;
            int k;
            cin >> o >> k;
            for(int j=0; j<k; ++j) {
                string q;
                cin >> q;
                recipe[o].push_back(q);
            }
        }

        for(int i=0; i<n; ++i) {
            for(auto& p : cost) {
                if(recipe.count(p.first) == 0) {
                    continue;
                }
                int sum = 0;
                auto& r = recipe[p.first];
                for(int j=0; j<r.size(); ++j) {
                    sum += cost[r[j]];
                }
                p.second = min(p.second, sum);
            }
        }
        string t;
        cin >> t;
        cout << cost[t] << endl;
    }
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
vector<set<int>> v;
vector<int> vv;
void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) vv.pb(p);
} 

int main()
{
	fast
	SieveOfEratosthenes(1e6);
	int n;
	cin>>n;
	int a[n];
	int o;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
		if(i==0)
			o=a[i];
		else
			o=__gcd(o,a[i]);
	}
	v.resize(1e6+1);
	int f=1;
	for(auto i:vv)
	{
		for(int j=i;j<=1e6;j+=i)
			{
				v[j].insert(i);
			}
			
	}
	set<int> xx;
	int zz=0;
	for(int i=0;i<n;i++)
	{
		zz+=v[a[i]].size();
		for(auto j:v[a[i]])
			xx.insert(j);
	}
	if(zz==xx.size())
		f=1;
	else
		f=0;
	if(f)
		cout<<"pairwise coprime";
	else
	{
		if(o==1)
			cout<<"setwise coprime";
		else
			cout<<"not coprime";

	}
	return 0;
}


Measured memory_bytes: 238468
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl();
    let T = rl();

    let count = S
        .chars()
        .zip(T.chars())
        .into_iter()
        .filter(|&(s, t)| s == t)
        .count();

    println!("{}", count)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::deque<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b) * h/ 2 << 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[] num = new int[6];
		SwitchDice dice = new SwitchDice(num);
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		dice.setFace(num);
		String str = sc.next();
		dice.order(str);
		System.out.println(dice.getFace());
		sc.close();
	}
}

class SwitchDice {

	private int face[] = new int[6];

	SwitchDice(int[] num) {
		for (int i = 0; i < 6; i++) {
			this.face[i] = num[i];
		}
	}

	public void order(String str) {
		char[] order = str.toCharArray();
		int tmp;
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				tmp = face[0];
				face[0] = face[1];
				face[1] = face[5];
				face[5] = face[4];
				face[4] = tmp;
				break;
			case 'S':
				tmp = face[0];
				face[0] = face[4];
				face[4] = face[5];
				face[5] = face[1];
				face[1] = tmp;
				break;
			case 'E':
				tmp = face[0];
				face[0] = face[3];
				face[3] = face[5];
				face[5] = face[2];
				face[2] = tmp;
				break;
			case 'W':
				tmp = face[0];
				face[0] = face[2];
				face[2] = face[5];
				face[5] = face[3];
				face[3] = tmp;
				break;
			}
		}
	}

	public int getFace() {
		return face[0];
	}

	public void setFace(int[] face) {
		this.face = face;
	}
}


Measured memory_bytes: 26296
n,m=map(int,input().split())
ans=["a"]*n
for i in range(0,m):
  s,c=map(int,input().split())
  if ans[s-1]=="a" or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    break
else:
  if n==1 and ans[0]=="a":
    ans[0]=0
  elif ans[0]=="a":
    ans[0]=1
  for i in range(0,n):
    if ans[i]=="a":
      ans[i]=0
  if i>=2 and ans[0]==0:
    print(-1)
  else:
    if n==3:
      ans=int(ans[0])*100+int(ans[1])*10+int(ans[2])
    elif n==2:
      ans=int(ans[0])*10+int(ans[1])
    else:
      ans=int(ans[0])
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

main()
{
    ll x;
    cin>>x;
    if(x==0) cout<<1;
    else cout<<0;
        
}


Measured memory_bytes: 3628
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        //int[] input = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        int input=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        Console.WriteLine(input%2==0?input:input*2);
        Console.ReadLine();
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(){
  int n, i, count = 0;
  double d;
  scanf("%d %lf", &n, &d);
  double x[n], y[n];

  for(i = 0; i < n; i++){
    scanf("%lf %lf", &x[i], &y[i]);
    if(x[i]*x[i] + y[i]*y[i] <= d*d){
      count++;
    }
  }

  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 4872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;

ll solve(int n, int W, arr w, longarr v) {
	longmat dp(n + 1, longarr(W + 1, 0));
	for (int i = 0; i <= n; ++i) dp[i][0] = 0;
	for (int i = 0; i <= W; ++i) dp[0][i] = 0;

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= W; ++j) {
			ll x = dp[i - 1][j];
			ll y = (j >= w[i - 1]) ? (v[i - 1] + dp[i - 1][j - w[i - 1]]) : 0;
			dp[i][j] = max(x, y);
		}
	}
	return dp[n][W];
}

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif
	int n, W;
	cin >> n;
	cin >> W;
	arr w(n, 0);
	longarr v(n, 0);
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	cout << solve(n, W, w, v);

}

Measured memory_bytes: 80256
n = int(input())
s = input()
point = 0

# 100の位
for i in range(10):
    # Sのn-2番目までにiがあるか
    str_i = str(i)
    for a in range(n-2):
        if s[a] == str_i:
            now_i = a
            break
    # 作れなかった場合打ち切り
    else:
        continue
    # 10の位
    for j in range(10):
        str_j = str(j)
        for b in range(now_i+1,n-1):
            if s[b] == str_j:
                now_j = b
                break
        else:
            continue
        # 1の位
        for k in range(10):
            str_k = str(k)
            for c in range(now_j+1,n):
                # 暗証番号がそろった
                if s[c] == str_k:
                    point += 1
                    break

print(point)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 114514;
		for(char c = 'a'; c <= 'z'; c++) {
			String ns = s;
			int count=0;
			while(!ns.matches("("+c+")*")) {
				count++;
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < ns.length()-1; i++) {
					if(ns.charAt(i)==c||ns.charAt(i+1)==c) {
						sb.append(c);
					} else {
						sb.append('P');
					}
				}
				ns = sb.toString();
			}
			min = Math.min(min, count);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 27604
fun main(args: Array<String>) {
    val X = readLine()!!.toInt()

    var max = 1
    for (i in 2..32) {
        if (i < X) {
            max = Math.max(max, calc(i, X))
        }
    }
    println(max)

}

private fun calc(x: Int, X: Int): Int {
    var result = x
    while (true) {
        val temp = result * x
        if (temp <= X) {
            result = temp
        } else {
            break
        }
    }
    return result
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  unordered_set<int> r;
  unordered_set<int> g;
  unordered_set<int> b;

  char c;
  for (int i = 0; i < n; ++i) {
    cin >> c;
    if (c == 'R') {
      r.insert(i);
    } else if (c == 'G') {
      g.insert(i);
    } else if (c == 'B') {
      b.insert(i);
    }
  }

  ll ans = 0;
  for (auto i : r) {
    for (auto j : g) {
      int t = b.size();
      if (b.find(2 * i - j) != b.end()) --t;
      if (b.find(2 * j - i) != b.end()) --t;
      if ((i + j) % 2 == 0 && b.find((i + j) / 2) != b.end()) --t;
      ans += max(0, t);
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(){
	int i,j;
	char a[11];
	int n;
	while(scanf("%s",a)!=EOF){
		n=0;
		for(i=0;i<11;i++){
			a[i]-='0';
		}
		n+=a[0];
		n+=a[1]*9;
		n+=a[2]*6;
		n+=a[3]*4;
		n+=a[4]*6;
		n+=a[5]*6;
		n+=a[6]*4;
		n+=a[7]*6;
		n+=a[8]*9;
		n+=a[9]*1;
		printf("%d\n",n%10);
	}
	return 0;
}

Measured memory_bytes: 540
from collections import deque

h,w=map(int, input().split())
c_h,c_w=map(int, input().split())
d_h,d_w=map(int, input().split())
map=[[-1]*w for i in range(h)]
 
for gyou in range(h):
    tmp=input()
    for retu in range(w):
        if tmp[retu]=="#":map[gyou][retu]=-2
 
genzai=deque()
wapu=deque()
genzai.append([c_h-1,c_w-1])
wapu.append([c_h-1,c_w-1])
 
map[c_h-1][c_w-1]=0
 
def idou(gyou,retu,kaisuu):
    wapu.append([gyou,retu])
    for i in (-1,1):
        if 0<=gyou+i and gyou+i<h:
            if map[gyou+i][retu]==-1:
                map[gyou+i][retu]=kaisuu
                genzai.append([gyou+i,retu])
                wapu.append([gyou+i,retu])
                
        if 0<=retu+i and retu+i<w:
            if map[gyou][retu+i]==-1:
                map[gyou][retu+i]=kaisuu
                genzai.append([gyou,retu+i])
                wapu.append([gyou,retu+i])

def idou_wapu(gyou,retu,kaisuu):
    for i in range(-2,3):
        for j in range(-2,3):
            if 0<=gyou+i and gyou+i<h and 0<=retu+j and retu+j<w:
                if map[gyou+i][retu+j]==-1:
                    map[gyou+i][retu+j]=kaisuu+1
                    genzai.append([gyou+i,retu+j])

wapu_kaisuu=0

while len(genzai)!=0:
 
    while len(genzai)>0:
        idou(genzai[0][0],genzai[0][1],wapu_kaisuu)
        genzai.popleft()
    
    while len(wapu)>0:
        idou_wapu(wapu[0][0],wapu[0][1],wapu_kaisuu)
        wapu.popleft()
    
    wapu_kaisuu+=1

    if map[d_h-1][d_w-1]!=-1:
        print(map[d_h-1][d_w-1])
        exit()


print(map[d_h-1][d_w-1])

Measured memory_bytes: 137152
#include<bits/stdc++.h>
using namespace std;
const int N=402,M=100002;
int n,m,i,j,ans,x[M],y[M],k;
bool vis[N],mp[N][N],fl;
int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d%d",&x[i],&y[i]);
	for (i=1;i<=n;i++){
		mp[i][i]=1;
		for (j=m;j;j--){
			bool &xx=mp[i][x[j]],&yy=mp[i][y[j]];
			if (xx && yy){
				vis[i]=1;
				break;
			}else if (xx) yy=1;
			else if (yy) xx=1;
		}
	}
	for (i=1;i<=n;i++) if (!vis[i])
		for (j=i+1;j<=n;j++) if (!vis[j] && !mp[i][j]){
			fl=1;
			for (k=1;k<=n;k++)
				if (mp[i][k] && mp[j][k]) fl=0;
			ans+=fl;
		}
	printf("%d",ans);
}

Measured memory_bytes: 1152
#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, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    int n = s.size(), m = t.size();
    rep(i,m) {
        if (i == n || s.at(i) < t.at(i)) {
            cout << "Yes" << endl;
            return 0;
        }
        if(t.at(i) < s.at(i)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var S = ReadLine();

        var ans = 1;

        for (int i = 1; i < N; i++)
        {
            if (S[i - 1] != S[i])
                ans++;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 27836
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = 0;

    for (int i = 1; i <= n; i++) {
      int tmp = 0;
      String s = Integer.toString(i);
      for (int j = 0; j < s.length(); j++) {
        tmp += Character.getNumericValue(s.charAt(j));
      }
      if ((a <= tmp) && (tmp <= b)) {
        ans += i;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 36876
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

from collections import defaultdict


def main():
    n = int(input())
    a = list(map(int, input().split()))
    maxa = max(a)
    mina = min(a)
    dica = defaultdict(lambda: 0)
    for _a in a:
        dica[_a] += 1
    if dica[maxa] < 2:
        print("Impossible")
    elif mina != (maxa+1)//2:
        print("Impossible")
    else:
        if ((maxa+1)%2 == 1 and dica[mina] != 1) or ((maxa+1)%2 == 0 and dica[mina] != 2):
            print("Impossible")
        else:
            mina += 1
            for _a in range(mina, maxa+1):
                if _a not in dica or dica[_a] < 2:
                    print("Impossible")
                    break
            else:
                print("Possible")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	long long H, W;
	cin >> H >> W;
	pair<long long, long long> P[N];
	for (int i = 0; i < N; i++) {
		cin >> P[i].first >> P[i].second;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (P[i].first >= H && P[i].second >= W) {
			ans++;
	}
   }
	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);
        long x = sc.nextLong();
        long y = sc.nextLong();
        if (x % y == 0) {
            System.out.println(-1);
        } else {
            System.out.println(x);
        }


    }

}


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

int main()
{
  int n, y; cin >> n >> y;
  int x = (4*n - y);
  bool valid = (x >= 0) and ((x&1) == 0);
  x = x/2;
  int s = n - x;
  valid = valid and (x<=n) and (s>=0) and (y == (2*x+4*s));
  cout << (valid ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    if((C+B-1)/B<=(A+D-1)/D)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl; 
    }
    if (s == "Cloudy") {
        cout << "Rainy" << endl; 
    }
    if (s == "Rainy") {
        cout << "Sunny" << endl; 
    }
    return 0;
}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;
    
    vector<ll> v(n);
    
    for (ll i = 0; i < n; i++) {
    	cin >> v[i];
    }
    
    sort(v.begin(), v.end(), greater<>());
    
    ll before = v[0];
    ll one, two = 0;
    
    for (ll i = 1; i < n; i++) {
    	if (v[i] == before) {
    		if (one == 0) {
    			one = v[i];
    			before = 0;
    		} else {
    			two = v[i];
    			break;
    		}
    	} else {
    		before = v[i];
    	}
    }
    
    cout << one * two << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;   
int main(){
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  int i;                                                          
  for(i=0;i<3;i++){
    if(s[i]==t[i]) cnt++;                    
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int nMax=1e7+1, MOD=998244353;
ULL inv[nMax], Fact[nMax], invF[nMax];
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }
ULL Comb(int n, int r){ return (((Fact[n]*invF[r])%MOD)*invF[n-r])%MOD; }

int main(){
ULL N, ans, d=0; cin >> N;
inv[1]=Fact[0]=Fact[1]=invF[0]=invF[1]=1;
for(int i=2; i<nMax; i++){ 
  inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
  Fact[i]=(Fact[i-1]*i)%MOD; invF[i]=(invF[i-1]*inv[i])%MOD;
}
for(int i=N/2+1; i<=N; i++){ d=(d+(Comb(N, i)*pw(2, N-i))%MOD)%MOD; }
d=(2*d)%MOD; ans=(pw(3, N)+MOD-d)%MOD;
cout << ans << "\n";
}

Measured memory_bytes: 234624
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long ll;

/////////////////////////////////DEBUG/////////////////////////////////
void printd(const char* format)
{
  #ifdef DEBUG
    std::cout << format;
  #endif
}
template<typename T, typename... Targs>
void printd(const char* format, T value, Targs... Fargs)
{
  #ifdef DEBUG
    for ( ; *format != '\0'; format++ ) {
        if ( *format == '%' ) {
           std::cout << value;
           printd(format+1, Fargs...);
           return;
        }
        std::cout << *format;

    }
  #endif
}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef DEBUG
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////////////////////////////// YAY /////////////////////////////////
void solve()
{
  int n; cin>>n;
  int x = ((n/1000)+1)*1000-n;
  if(x==1000)x=0;
  std::cout << x << '\n';
}

int main(int argc, char const *argv[]) {
  int t;
  t=1;

  #ifdef DEBUG
    freopen("input.txt","r", stdin);
    clock_t start, end;
    start = clock();
    cin>>t;
  #endif


  for(int i = 1; i<=t; i++)
  {
    // std::cout << "Case "<<i<<": " << '\n';
    solve();
  }

  #ifdef DEBUG
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    time_taken *= 1000;
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " ms " << endl;
  #endif
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll cnt[26];
signed main() {
	string s;
	cin >> s;
	rep(i, s.size())cnt[s[i] - 'a']++;
	for (int i = 0; i < 26; i++) {
		if (!cnt[i]) {
			cout << char('a' + i) << endl;
			return 0;
		}
	}
	puts("None");
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 512
import itertools
import math
import fractions
import functools
import copy
a, b, k = map(int, input().split())

ans = []
for i in range(1, min(a,b)+1):
    if a % i == 0 and b % i == 0:
        ans.append(i)

ans.sort(reverse=True)

print(ans[k-1])


Measured memory_bytes: 64108
N, W = [int(i) for i in input().split()]
V = [[int(i) for i in input().split()] for j in range(N)]

INF = 10 ** 18
sup_v = 10 ** 5
DP = [INF] * (sup_v + 1)
DP[0] = 0

for w, v in V:
    for i in range(sup_v, -1, -1):
        DP[i] = min(DP[i], DP[i-v] + w)

for i in range(sup_v, -1, -1):
    if DP[i] <= W:
        print(i)
        break

Measured memory_bytes: 42220