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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		int a = 0;
		int b = 0;
		int c = 0;
		
		for(int i = 0; i < 3; i++) {
			if(S.charAt(i) == 'a') {
				a++;
			} else if(S.charAt(i) == 'b') {
				b++;
			} else {
				c++;
			}
		}
		if(a == 1 && b == 1 && c == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


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

    vector<ll> ab;
    ll cnt = 0;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        ab.push_back(a+b);
        cnt += b;
    }
    sort(ab.begin(), ab.end(), greater<ll>());
    ll ans = 0;
    rep(i, (n+1)/2){
        ans += ab[2 * i];
    }
    ans -= cnt;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {


        


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                if (n == 0) { break; }
                int score = 0;
                for (int i = 0; i < n / 4; i++) {
                    score += int.Parse(Console.ReadLine());
                }
                Console.WriteLine(score);
                
            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 5600
function Main(input){
  //入力値Nを数値化して確保
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  //入力値Kを数値化して確保
  inputStr = input[1].split(" ");
  var K = Number.parseInt(inputStr[0]);
  
  //ループで回しながら全パターン試す
  var ans = 1;
  for( i=0 ; i<N ; i++){
    ans = Math.min(ans*2,ans+K);
  }
  //結果表示
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int roundup(int a){
  int result;
  if(a%10 != 0){
  	result = (a + (10-a%10));
  }
  else{
    result = a;
  }
  return result;
}

int main(){
  vector<int> a(5);
  
  for(int i=0;i<5;i++){
  	cin >> a[i];
  }
  
  int result = 0;
  int tmp=10;
  for(int i=0;i<5;i++){
    if(a[i]%10 != 0){
    	tmp=min(tmp,a[i]%10);
    }
  	result += roundup(a[i]);
  }
 
  cout << result - (10 - tmp) << endl;;
}
	


Measured memory_bytes: 256
def solve():
    dp = [[] for _ in range(n+1)]
    dp[n].append(0)
    for i in range(n)[::-1]:
        dp[i] = dp[i+1]
        x = a[i]
        for y in dp[i+1]:
            x = min(x,x^y)
        if s[i] == "0":
            if x:
                dp[i].append(x)
        else:
            if x:
                return 1
    return 0
t = int(input())
for i in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    s = input()
    print(solve())

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

using namespace std;
using namespace __gnu_pbds;

typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 2e5+100;
const int Mod = 1e9+7;

int h, n;
int health[1005], cost[1005];
int dp[10005][1005];

int solve(int tot, int pos)
{
    if(tot <= 0) return 0;
    if(pos == n) return 1e8;
    int &ret = dp[tot][pos];
    if(ret != -1) return ret;
    int ret1 = 1e8, ret2 = 1e8;
    ret2 = solve(tot, pos+1);
    ret1 = cost[pos] + solve(tot-health[pos], pos);
    return ret = min(ret1, ret2);
}

int main()
{
    ios::sync_with_stdio(false);

    memset(dp, -1, sizeof dp);
    cin>>h>>n;
    for(int i=0 ; i<n ; i++) cin>>health[i]>>cost[i];
    int Ans = solve(h, 0);
    cout<<Ans<<endl;

    return 0;
}


Measured memory_bytes: 40192
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)res=res*a%_MOD;
  }
  return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}

//////////////////////////////////////////////////////////////////

void Solve(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}



Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
    int H,W;
    while(H!=0 || W!=0){
        scanf("%d",&H);
        scanf("%d",&W);
        if(H!=0 || W!=0){
            for(int a = 0;a < H;a++){    
                for(int b = 0;b < W;b++){
                    if(a == 0 || a == H-1){
                        printf("#");
                    }else if(b == 0 || b == W-1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }else{
        break;
        } 
    }          
    return 0;
}

Measured memory_bytes: 1000
#include<iostream>
#include<stack>
#include<string>
#include<sstream>
using namespace std;

int main(){
    stack<int> S;

    string expr;
    getline(cin,expr);

    istringstream is(expr);

    while(!is.eof()){
        string op;
        is >> op;

        int tmp1,tmp2;

        switch(op[0]){
            case '+':
                tmp1 = S.top(); S.pop();
                tmp2 = S.top(); S.pop();
                S.push(tmp2+tmp1);
                break;

            case '-':
                tmp1 = S.top(); S.pop();
                tmp2 = S.top(); S.pop();
                S.push(tmp2-tmp1);
                break;
            
            case '*':
                tmp1 = S.top(); S.pop();
                tmp2 = S.top(); S.pop();
                S.push(tmp2*tmp1);
                break;
            
            default:
                istringstream is2(op);
                is2 >> tmp1;
                S.push(tmp1);
                break;
        }
    }
    cout << S.top() << endl;
    return 0;

}


Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N,M,X;
    cin>>N>>M>>X;
    int ans=0;
    int count=0;

    vector<int>A(M);
    for(int i=0;i<M;i++){
        cin>>A[i];
    }
    for(int i=0;i<M;i++){
        if(A[i]<X){
            ans++;
        }
        if(A[i]>X){
            count++;
        }
    }
    cout<<min(ans,count)<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
const ll LIM =1e9+7;

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}



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


    int n;cin>>n;
    vector<int> a(3);
    a[0] = n/100;
    a[1] = n%100/10;
    a[2] = n%10;
    rep(i,3){
        if(a[i]==7){
            fin("Yes");
        }
    }
    fin("No");


}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

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

    int n = b - a;

    int eastt = n * (n + 1) / 2;

    cout << eastt - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

struct Edge {
    int from, to, w;
    Edge() {}
    Edge(int f, int t, int _w)
        : from(f), to(t), w(_w) {}
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<Edge>> Tree(n);
    Edge odds = Edge(-1, -1, -1);
    REP(i, 0, n - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        Tree[a].emplace_back(a, b, c);
        Tree[b].emplace_back(b, a, c);
        if (c % 2 == 1) {
            odds = Edge(a, b, c);
        }
    }
    if (odds.w == -1) {
        REP(i, 0, n) {
            cout << 0 << endl;
        }
    } else {
        vector<int> color(n, -1);
        function<void(int, int, int)> rec = [&](int v, int c, int w) {
            if (color[v] != -1) return;
            if (w % 2 == 1) {
                c = !c;
            }
            color[v] = c;
            for (auto &ver : Tree[v]) {
                rec(ver.to, c, ver.w);
            }
        };
        rec(odds.from, 0, odds.w);
        rec(odds.to, 1, odds.w);
        REP (i, 0, n) {
            cout << color[i] << endl;
        }
    }

    return 0;
}


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

struct Task{
    long a;
    long b;
    bool operator<(const Task &another) const{
        return b < another.b;
    };
};

int main(){
    int n;
    cin >> n;
    Task task[n];
    for(int i = 0; i < n; i++) cin >> task[i].a >> task[i].b;
    sort(task, task + n);
    bool available = true;
    long time = 0;
    for(int i = 0; i < n; i++){
        time += task[i].a;
        if(time > task[i].b){
            available = false;
            break;
        }
    }
    cout << (available ? "Yes" : "No") << endl;
    return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> can(100, 0);
    for (int i = 1; i < 10; i++)
        for (int k = 1; k < 10; k++)
            can[i * k] = 1;
    int n;
    cin >> n;
    if (can[n]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// https://www.youtube.com/watch?v=4QCdOAIOt6Y&list=PLn8m49B2OVF4kVTE0TK1PT-R0R9QhTVyS&index=3
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string a,b,ans; cin>>a>>b;
    int n = a.size() , m = b.size();

    int dp[n+1][m+1] = {};
    int path[n+1][m+1] = {};
    // path[i][j] ==  { 0 : go left} { 1 : go above} { 2 : select this}

    dp[0][0] = 0;

    if(a[0] == b[0])
        dp[0][0] = 1 , 
        path[0][0] = 2;

    for(int i=0 ; i<n ; i++)
    {
        for(int j=0 ; j<m ; j++)
        {
            if(i>0)
            {
                dp[i][j] = dp[i-1][j];
                path[i][j] = 0;                 // we came from rleft
            }
            if(j > 0)   
                if(dp[i][j-1] > dp[i][j])
                    dp[i][j] = dp[i][j-1],
                    path[i][j] = 1;             // we came from above
            
            if(a[i] == b[j])        // this is where i was wrong
            {
                int ans = 1;
                if(i>0 and j>0) 
                {
                    ans = 1 + dp[i-1][j-1]; 
                }
                if(ans > dp[i][j])
                {
                    dp[i][j] = ans;
                    path[i][j] = 2;
                }
            }
        }
    }
    //////////////////
    // cout<<endl;    
    // for(int i=0 ; i<n ; i++)
    // {
    //     for(int j=0 ; j<m ; j++)
    //         cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }

    // cout<<endl;
    // for(int i=0 ; i<n ; i++)
    // {
    //     for(int j=0 ; j<m ; j++)
    //         cout<<path[i][j]<<" ";
    //     cout<<endl;
    // }
    //////////////

    int i = n-1, j = m-1;

    while(i>=0 and j>=0)
    {

        if(path[i][j] == 0)
            i--;
        else if (path[i][j] == 1)
            j--;
        else
            {
                ans += a[i];
                i-- , j--;
            }
    }
    reverse(ans.begin() , ans.end());
    cout<<ans;


}

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

public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] args) {
        FastReader scanner = new FastReader();
        int N = scanner.nextInt();
        int[][] A = new int[3][N];
        for (int j = 0; j < N; j++) {
            for (int i = 0; i < 3; i++) {
                A[i][j] = scanner.nextInt();
            }
        }

        for (int j = 1; j < N; j++) {
            A[0][j] += Math.max(A[1][j - 1], A[2][j - 1]);
            A[1][j] += Math.max(A[0][j - 1], A[2][j - 1]);
            A[2][j] += Math.max(A[0][j - 1], A[1][j - 1]);
        }
        System.out.println(Math.max(A[0][N - 1], Math.max(A[1][N - 1], A[2][N - 1])));
    }
}

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

int main(){	
	int x,y;
	cin >> x >> y;
	string ans = "No";
	if(x*2<=y && y<=x*4 && y%2==0){ ans = "Yes";}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vector<int> numf(n),numb(n);

    rep(i,1,m){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        uf.merge(a,b);
        numf[a]++;numf[b]++;
    }
    rep(i,1,k){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        if(uf.issame(a,b)){
            numb[a]++;numb[b]++;
        }
    }
    rep(i,0,n-1){
        int ans = uf.size(i) - numf[i] - numb[i] - 1;
        cout << ans << endl;
    }
    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3200
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 1e9+7;
pii a[200005];
int main(){
    int n;
    scanf("%d", &n);
    rep(i,2*n){
        scanf("%d", &a[i].first);
        a[i].second = i;
    }
    sort(a,a+2*n);
    ll ans = 1;
    int hoge = 0;
    rep(i,2*n){
        if(a[i].second < n){
            if(hoge< 0) ans = ans * (-hoge) % mod;
            hoge++;
        }else{
            if(hoge > 0) ans = ans * hoge % mod;
            hoge--;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
A, B = gets.split.map(&:to_i)

b = Array.new(100){Array.new(100, '.')}
(50 ... 100).each{|i| b[i] = ['#'] * 100}
if B > 1
  c = 0
  (0.step(49, 2).to_a).repeated_permutation(2) do |i, j|
    b[i][j] = '#'
    c += 1
    break if c >= B - 1
  end
end
if A > 1
  c = 0
  (51.step(99, 2).to_a).repeated_permutation(2) do |i, j|
    b[i][j] = '.'
    c += 1
    break if c >= A - 1
  end
end
puts "100 100"
b.each{|l| puts l.join}

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>


using namespace std;

int main (void){

	int width;
	int height;

	int dp[32][32];
	bool status[32][32];
	int n;
	int nx,ny;

	while(true){
		scanf("%d%d",&width,&height);
		if((width==0)||(height==0))break;

		for(int i=0;i<32;i++){
			for(int j=0;j<32;j++){
				dp[i][j] = 0;
				status[i][j] = false;
			}
		}
		dp[1][1] = 1;

		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d%d",&nx,&ny);
			status[nx][ny] = true;
		}

		for(int i=1;i<=width;i++){
			for(int j=1;j<=height;j++){
				if(!status[i][j]){
					dp[i][j] += dp[i-1][j] + dp[i][j-1]; 
				}
			}
		}

		printf("%d\n",dp[width][height]);

	}



	return 0;
}

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

int main(){
	string s,t;		cin>>s>>t;
	char StoT[26], TtoS[26];
	for(int i=0;i<26;i++){
		StoT[i]=TtoS[i]='*';
	}



	string ans="Yes";
	bool check=false;
	for(int i=0;i<s.length();i++){
		int sAlpha = s[i]-'a';
		int tAlpha = t[i]-'a';

		if(StoT[sAlpha]=='*'){
			StoT[sAlpha]=t[i];
		}
		if(TtoS[tAlpha]=='*'){
			TtoS[tAlpha]=s[i];
		}

		if(StoT[sAlpha]==t[i] && TtoS[tAlpha]==s[i]){
			//printf("%c <==> %c\n",s[i],t[i]);
		}else{
			ans="No";
			break;
		}


	}



	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 400010
const ll MOD = 998244353;
vpi V;
ll N,a,b;

bool cmp(pi a, pi b){
	return a.f+a.s < b.f+b.s;
}

struct node{
	int s,e,m,v;
	node *l, *r;
	node(int _s, int _e):s(_s), e(_e){
		m=(s+e)/2;v=0;
		if (s!=e){l=new node(s,m);r=new node(m+1,e);}
	}
	void up(int x, int val){
		if (s==e){v=max(v,val);return;}
		if (x<=m)l->up(x,val);
		else r->up(x,val);
		v=max(l->v,r->v);
	}
	int query (int x, int y){
		if (s==x&&e==y)return v;
		if (y <= m)return l->query(x,y);
		if (x > m)return r->query(x,y);
		return max(l->query(x,m), r->query(m+1,y));
	}
}*root;

vi des;
int lst[MAXN];
ll dp[MAXN];
vi AL[MAXN];

int main(){
	cin>>N;
	for (int i=0;i<N;++i){
		cin>>a>>b;
		--b;
		V.pb(a,a+b);
		des.pb(a);
		des.pb(a+b);
	}
	sort(ALL(des));
	des.resize(unique(ALL(des)) - des.begin());
	for (auto &i:V){
		int a = i.f;
		int b = i.s;
		i = mp(lb(ALL(des),a)-des.begin()+1, lb(ALL(des),b)-des.begin()+1);
	}
	root = new node(1,SZ(des));
	sort(ALL(V));
	// for (auto i:V)cout<<i.f<<' '<<i.s<<'\n';
	lst[SZ(V)-1] = SZ(V)-1;
	AL[V.back().f].pb(V.back().s);
	root->up(V.back().f, lst[SZ(V)-1]);
	for (int i=SZ(V)-2;i>=0;--i){
		int l = root->query(V[i].f,V[i].s);
		l = max(l,i);
		lst[i] = l;
		root->up(V[i].f, l);
		AL[V[i].f].pb(V[l].s);
	}

	dp[0] = 1;
	for (int i=1;i<=SZ(des);++i){
		dp[i] += dp[i-1];
		dp[i] %= MOD;
		// cout<<"AL: ";
		for (auto x:AL[i]){
			// cout<<x<<' ';
			dp[x]+=dp[i-1];
			dp[x] %= MOD;
		}
		// cout<<'\n';
	}
	cout<<dp[SZ(des)];
}

Measured memory_bytes: 65244
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n ,m;
    cin >> n >> m;
    int sou=0;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        sou+=a[i];
    }
    int kazu=0;
    for(int i=0;i<n;i++){
        if(a[i]*4*m>=sou)kazu++;
    }
    if(kazu>=m)cout << "Yes" << endl;
    else cout << "No" << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll sum(ll x){
	ll res=0;
	while(x)res+=x%10,x/=10;
	return res;
}
ll num(vector<int>x){
	ll res=0;
//	for(int i=x.size()-1;i>=0;i--)printf("%d\n",x[i]);
	for(int i=x.size()-1;i>=0;i--)res=res*10+x[i];
	return res;
}
vector<int> get(ll x){
	vector<int>res;
	while(x)res.push_back(x%10),x/=10;
	return res;
}
ll f(ll x){
	vector<int>tmp1=get(x);
	double mn=1e18;ll res=-1;
	for(int i=0;i<tmp1.size();i++)
		for(int d=tmp1[i];d<=9;d++){
		vector<int>tmp2=tmp1;tmp2[i]=d;
		for(int j=0;j<i;j++)tmp2[j]=9;
		ll y=num(tmp2),sy=sum(y);
		if((double)y/sy<mn)mn=(double)y/sy,res=y;
	}
	return res;
}
ll n;
int main(){
//	vector<int>tmp=get(1000);
//	for(int i=0;i<tmp.size();i++)printf("%d\n",tmp[i]);
//	ll tmp2=num(tmp);
//	printf("%lld\n",tmp2);
	scanf("%lld",&n);
	for(ll i=1,ans=1;i<=n;i++,ans=f(ans+1))
		printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main(){
        string c[2];
        cin>>c[0]>>c[1];
        if(c[0][0]==c[1][2]&&c[1][1]==c[0][1]&&c[0][2]==c[1][0]){
                cout<<"YES"<<endl;
        }
        else{
                cout<<"NO"<<endl;
        }
        return 0;
}


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


int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> ans(n);
  int r = 0, l = 0;
  int c = 0;
  rep(i, n) {
    if (s[i] == 'R') {
      if (l != 0) {
        ans[c] += (r+1)/2 + l/2;
        ans[c+1] += (l+1)/2 + r/2;
        r = 1; l = 0;
      } 
      else r++;
    }
    else {
      if (l == 0) c = i-1;
      l++;
    }
  }
  ans[c] += (r+1)/2 + l/2;
  ans[c+1] += (l+1)/2 + r/2;
  rep(i, n) cout << ans[i] << " ";
  cout << endl;
}



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

int main() {
	int N;
	cin >> N;
	vector<long> A(N);
	long sum = 0;
	int minus = 0;
	for (long& i : A) {
		cin >> i;
		if (i < 0) ++minus;
		sum += labs(i);
	}
	if (minus % 2) {
		long tmp = INT_MAX;
		for (long& i : A) tmp = min(tmp, labs(i));
		//cout << sum << endl;
		cout << sum - 2 * tmp;
	}
	else cout << sum;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    string s;
    cin >> s;
    if(s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]) {
        print("Yes");
        return;
    }
    if(s[0]==s[1]&&s[3]==s[2]&&s[2]!=s[1]) {
        print("Yes");
        return;
    }
    if(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]) {
        print("Yes");
        return;
    }
    print("No");
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void);
int main(void){
  int a[3],n=0,m=0,i;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
    if(a[i]>m){
      m=a[i];
      n=i;
    }
  }
  printf("%d",a[0]*a[1]*a[2]/(2*a[n]));
  return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n;
int a[N];
int pre[N]={0},suf[N]={0};
int main(){
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(itn i=1;i<=n;i++)cin>>a[i];
	for(itn i=1;i<=n;i++){
		pre[i]=max(pre[i-1],a[i]);
	}
	for(int i=n;i>=1;i--)suf[i]=max(suf[i+1],a[i]);
	for(int i=1;i<=n;i++){
		o(max(pre[i-1],suf[i+1]));
	}
}

Measured memory_bytes: 10624
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    input! {
    a:String,
    }
    let mut v=[0;26];
    let mut x=['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'];
    let a=a.chars().collect_vec();
    for i in 0..a.len() {
        for j in 0..26 {
            if a[i]==x[j] {v[j]=1}
        }
    }
    for i in 0..26 {
        if v[i]==0 {println!("{}",x[i]);exit(0)}
    }
    println!("None")
}

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

int main(){
  long int n,a,b;
  cin >> n >> a >> b;
  long int c = 0,nn;
  for(int i = 1; i <= n; ++i){
    int j = i;
    nn = 0;
    while(j >= 1){
      //cout << nn << endl;
      nn += (j % 10);
      j /= 10;
    }
    if(nn >= a && nn <= b){
      c += i;
    }
  }

  cout << c << endl;

}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   ll a, b, c;
   cin >> a >> b >> c;
   if (a%2==0 || b%2==0 || c%2==0) {
      cout << 0 << endl;
      return 0;
   }

   cout << min({a*b, c*b, c*a}) << endl;

   return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int N;
	cin >> N;
	ll min = 1e18;
	ll profit = -1e10;
	rep(i, N){
		ll x;
		cin >> x;
		if(profit < (x-min)) profit = x-min;
		if(min >= x) min = x;
	}
	cout << profit << endl;

}



Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;

int n,k;
ll ans;

int main(){
	int i,j;
	scanf("%d%d",&n,&k);
	if (!k){
		printf("%lld\n",1ll*n*n);
		return 0;
	}
	for (i=k+1;i<=n;i++){
		ans+=1ll*(i-k);
		for (j=i;j<=n;j+=i){
			if (j+k>n) break;
			if (j+i<=n) ans+=1ll*(i-k);
			else ans+=1ll*(n-j-k+1);
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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;}
int const INF = 1001001001;


int main()
{
    ll n;
    cin >> n;
    for(ll x = 1; x <= 3500; x++) {
        for(ll y = 1; y <= 3500; y++) {
            if(4*x*y - n*y - n*x == 0) continue;
            if((n*x*y) % (4*x*y - n*y - n*x) == 0) {
                ll z = (n*x*y) / (4*x*y - n*y - n*x);
                if(z > 0) {
                    cout << x << ' ' << y << ' ' << z << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

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



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

  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + (100 * (10 - n)) << endl;
  }

  return 0;
}

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

int main(){
  int a[5];
  for(int i=0;i<5;i++)
    cin>>a[i];
  for(int j=0;j<5;j++)
    for(int i=0;i<4;i++)
      if(a[i]<a[i+1]) swap(a[i],a[i+1]);
  for(int i=0;i<4;i++)
    cout<<a[i]<<' ';
  cout<<a[4]<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

int solve(const string& s1, const string& s2, int sp1, int sp2){

  int tmp = 0;
  int res = 0;
  int len = min(s2.length()-sp2,s1.length()-sp1);
  
  
  for(int i = 0; i < len; i++){
    if(s1[sp1+i] != s2[sp2+i]){
      res = max(res,tmp);
      tmp = 0;
    }else{
      tmp++;
    }
  }
  return max(tmp,res);
}

int main(){
  
  string s1,s2;
  while(getline(cin,s1) && getline(cin,s2)){
    int p1 = s1.length();
    int p2 = 0;
    int ans = 0;

    while(p1!=0||p2<=(int)s2.length()){
      if(p1 != 0) p1--;
      else p2++;
      ans = max(ans,solve(s1,s2,p1,p2));
     }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int main() {
#ifdef LOCAL
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, m;
    cin >> n >> m;
    vector<int> G[n];
    forn(i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].pb(y);
        G[y].pb(x);
    }
    forn(i, n) {
        cout<<sz(G[i])<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a, &b, &c)
	if a >= c && b <= c {
		fmt.Println("Yes")
	} else if a <= c && c <= b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
import kotlin.*

fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.next()
        val dp = Array(s.length + 1) { 0L }
        val dp2 = Array(s.length + 1) { 0L }
        dp[0] = 0
        dp2[0] = 1
        for (i in 1..s.length) {
            // 右端i
            for (j in 0 until i) {
                // 左端j
                val num = s.substring(j, i).toLong()
                dp[i] += dp[j] + num * dp2[j]
                dp2[i] += dp2[j]
            }
        }

        println(dp[s.length])
    }
}

class MyScanner {
    private var ptr = 0
    private var l = listOf<String>()

    fun next(): String {
        if (ptr >= l.size) {
            var s: String
            do {
                s = readLine()!!
            } while (s.isEmpty())
            l = s.split(' ')
            ptr = 0
        }
        return l[ptr++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun list(): List<String> {
        ptr = l.size
        val s = readLine()!!
        return if (s.isEmpty()) listOf() else s.split(' ')
    }

    fun intList() = list().map { s -> s.toInt() }
    fun longList() = list().map { s -> s.toLong() }
    fun doubleList() = list().map { s -> s.toDouble() }

    fun array() = list().toTypedArray()
    fun intArray() = intList().toIntArray()
    fun longArray() = longList().toLongArray()
    fun doubleArray() = doubleList().toDoubleArray()
}


Measured memory_bytes: 36588
YES = "YES"
NO = "NO"

def sq(x)
	return x * x
end

gets.to_i.times do
	puts ->(l){
		if sq(l[0]) + sq(l[1]) == sq(l[2])
			return YES
		elsif sq(l[1]) + sq(l[2]) == sq(l[0])
			return YES
		elsif sq(l[2]) + sq(l[0]) == sq(l[1])
			return YES
		end
		return NO
	}.call gets.split(' ').map(&:to_i)
end

Measured memory_bytes: 6108
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;


int main()
{
	int a,b;
	int ans;

	cin >> a;
	cin >> b;
	if (a == 1) {
		if (b == 2) {
			ans = 3;
		}
		else if (b == 3) {
			ans = 2;
		}
	}
	else if (a == 2) {
		if (b == 1) {
			ans = 3;
		}
		else if (b == 3) {
			ans = 1;
		}
	}
	else if (a == 3) {
		if (b == 1) {
			ans = 2;
		}
		else if (b == 2) {
			ans = 1;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n; vector<int> G[1 << 18];
int p[1 << 18];
bool onloop[1 << 18];
bool used[1 << 18];
vector<int> v;
//移り先のgrundy数の候補
vector<int> c[1 << 18];
//各頂点のgrundy数
int g[1 << 18];

queue<int> q;

void dfs(int root) {
	rep(i, G[root].size()) {
		int to = G[root][i];
		if (onloop[to])continue;
		dfs(to); c[root].push_back(g[to]);
	}
	sort(c[root].begin(), c[root].end());
	rep(i, c[root].size()+1) {
		if (!count(c[root].begin(), c[root].end(), i)) {
			g[root] = i; return;
		}
	}
}
int sta; int gr[1 << 18];
//g[sta] = xとして大丈夫かどうか
bool ok(int x) {
	int cur = p[sta]; int fr = sta;
	gr[sta] = x;
	while (cur != sta) {
		rep(i, c[cur].size() + 2) {
			if (i != gr[fr] && count(c[cur].begin(), c[cur].end(), i) == 0) {
				gr[cur] = i; break;
			}
		}
		fr = cur; cur = p[cur];
	}
	int mem = 0;
	rep(i, c[sta].size() + 2) {
		if (i != gr[fr] && count(c[sta].begin(), c[sta].end(), i)==0) {
			mem = i; break;
		}
	}
	return mem == x;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i]; p[i]--;
		G[p[i]].push_back(i);
	}
	int cur = 0;
	while (!used[cur]) {
		used[cur] = true; v.push_back(cur);
		cur = p[cur];
	}
	int now = 0;
	while (v[now] != cur) {
		now++;
	}
	Rep(i, now, v.size()) {
		onloop[v[i]] = true;
	}
	Rep(i,now, v.size()) {
		dfs(v[i]);
	}
	sta = v[now];
	vector<int> u;
	rep(i, c[sta].size() + 2) {
		if (!count(c[sta].begin(), c[sta].end(), i))u.push_back(i);
		if (u.size() == 2)break;
	}
	if (ok(u[0]) || ok(u[1]))cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	//stop
	return 0;
}


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

int main() {
	int a, b, c;

	cin >> a >> b >> c;
	if (a + b + c == 17) {
		if (a == b&&c == 7) {
			cout << "YES";
		}
		if (c == b&&a == 7) {
			cout << "YES";
		}
		if (a == c&&b == 7) {
			cout << "YES";
		}
	}
	else
	{
		cout << "NO";

	}
	
		return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 int n;
 string s;
 int a,b;
 cin>>s;
 if( s == "AAA" || s == "BBB" ){
  cout<<"No"<<endl;
 }else{
  cout<<"Yes"<<endl;
 }
    return 0;
}


Measured memory_bytes: 256
def solve(A):
    N = len(A)
    p = max(A)
    if p > min(A)+1:
        return False

    cnt = sum(int(a==p) for a in A)

    if p == N-1 and cnt == N:
        return True

    cnt_max = 2*(N-p)
    cnt_min = N-p+1

    return cnt_min <= cnt <= cnt_max

if __name__ == '__main__':
    N = int(input())
    A = tuple(map(int,input().split()))
    print('Yes' if solve(A) else 'No')

Measured memory_bytes: 20908
K = int(input())
S = input()
N = len(S)
mod = int(1e9+7)


wk = pow(26,K,mod)
inv26 = pow(26,-1,mod)

ans = wk
for i in range(1,K+1):
  wk = (wk * 25 * inv26) % mod
  wk = (wk * (N-1+i) * pow(i,-1,mod) % mod)
  ans = (ans + wk)%mod
    
print(ans)


Measured memory_bytes: 11032
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int main(){
    bool trump[52];
    memset(trump, false, sizeof(trump));

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string mark;
        int number, offset;
        cin >> mark; cin >> number;

        if("S" == mark) { offset = 0; }
		else if("H" == mark) { offset = 13; }
        else if("C" == mark) { offset = 26; }
        else if("D" == mark) { offset = 39; }

        trump[offset + number - 1] = true;
    }

    for(int i = 0; i < sizeof(trump) / sizeof(trump[0]); ++i){
		if(!trump[i]){
            string output;
            if(13 > i) { output = "S "; }
            else if(26 > i) { output = "H "; }
            else if(39 > i) { output = "C "; }
            else { output = "D "; }

            cout << output << i % 13 + 1 << endl;
        }
	}

    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int MAXN = 50, MAXT = 11, INF = (10000);
int d[MAXT][MAXT];
int times[MAXT];
int a, b, c, t;
int anst, ansc;

int main()
{
    int n;
    while(cin >> n && n)
    {
        memset(d, INF, sizeof(d));
        memset(times, 0, sizeof(times));
        t = 0;

        REP(MAXT) d[i][i] = 0;

        REP(n)
        {
            cin >> a >> b >> c;
            d[a][b] = d[b][a] = c;
            t = max(t, a + 1);
            t = max(t, b + 1);
        }
        anst = t;
        ansc = INF;
        //cout << "town"<<t << endl;

        rep(k,t)rep(i,t)rep(j,t)
        {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }

        rep(i,t)rep(j,t)
        {
            times[i] += d[i][j];
            //cout << i << "to" << j << " " << d[i][j] << endl;
        }

        rep(i,t)if( ansc > times[i]) {anst = i; ansc = times[i];}

        cout << anst << " " << ansc << endl;
    }
    return 0;
}

Measured memory_bytes: 0
x, y, r, g, n = map(int, input().split())
rt = list(map(int, input().split()))
rt.sort(reverse=True)
rt = rt[:x]
gt = list(map(int, input().split()))
gt.sort(reverse=True)
gt = gt[:y]
nt = list(map(int, input().split()))
nt.sort(reverse=True)
rt.extend(gt)
rt.extend(nt)
rt.sort(reverse=True)
rt = rt[:x+y]
print(sum(rt))


Measured memory_bytes: 22528
#include <stdio.h>

int main(void){
    long long int n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);
    
    if(a>b || (n==1 && a!=b))printf("0\n");
    else if(n==1 && a==b)printf("1\n");
    else printf("%lld\n", (n-2)*(b-a)+1);
    
    return 0;
}


Measured memory_bytes: 1692