akhauriyash/Code-Regression huggingface dataset:
//
// Created by Koki Igarashi on 8/2/20.
//

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

int N;

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

    cin >> N;
    string cs;
    cin >> cs;
    set<int> wp, rp;
    FORO(i, N) {
        if(cs[i] == 'R') {
            rp.insert(i);
        } else {
            wp.insert(i);
        }
    }

    int ans = 0;
    for(auto rr = rp.rbegin();rr != rp.rend();rr++) {
        int r = *rr;
        if(wp.empty()) continue;
        auto w = *wp.begin();
        if(w > r) continue;
        wp.erase(w);
        wp.insert(r);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12980
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a > b) {
			int t = b; b = a; a = t;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < b; i++) sb.append(a);

		System.out.println(sb);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P,P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, a, b, c, x;
    while(cin >> n >> a >> b >> c >> x, n){
        int y[105];
        REP(i,n) cin >> y[i];
        int cnt = 0, k=0;
        while(k<n && cnt<=10000){
            if(x==y[k])k++;
            x = (a*x+b)%c;
            cnt++;
        }
        cnt--;
        if(k==n && cnt<=10000){
            cout << cnt << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3004
#include<bits/stdc++.h>
#include<math.h>
#include<string>
using namespace std;
int main(void){
	int n,i,j;
	string s2,s;
	string t;
	string tmp;
	cin >> s >> t;
	int prebegin;
	int begin = -1;
	for(i=0;i<s.size()-t.size()+1;i++){
		tmp=s.substr(i,1);
		s2 = s;
		if(tmp=="?"||tmp==t.substr(0,1)){
			prebegin = begin;
			begin = i; //はんていはじめ
			j=0;
			while(j<=t.size()-1){
				if(i>=s.size()){
					begin = prebegin;
					break;
				}
				tmp=s.substr(i+j,1);
				if(tmp!="?"&&tmp!=t.substr(j,1)){
					begin = prebegin;
					break;
				}
				j++;
			}
			//見つかった ただし後野にbeginが来た方が辞書順的にいいので検索を続ける
		}
	}
	if(begin==-1){
		cout << "UNRESTORABLE";
		return 0;
	}
	for(i=0;i<s.size();i++){
		if(i==begin){
			s.replace(i,t.size(),t);
		}else if(s.substr(i,1)=="?"){
			s.replace(i,1,"a");
		}
	}
	cout << s;
	return 0;
}

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



int main() {
   int n,y;
  cin >> n >> y;
  
  int res10000=-1;
  int res5000=-1;
  int res1000=-1;
  
  for(int i=0;i<=n;++i){
    for(int j=0;j+i<=n;j++){
      int k = n-i-j;
      int total = 10000*i+5000*j+1000*k;
      if(total==y){
        res10000 = i;
        res5000 =j;
        res1000 = k;
      }
    }
  }
  
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


Measured memory_bytes: 256
function main(input) {
    var args = input.trim().split(/\r\n|\n/).map((v, i) => {
        if (i === 0) {
            return parseInt(v,10);
        }
        const arr = v.trim().split(" ").map((v2, i) => {
            if (i % 2 === 0) {
                return v2
            }
            return parseInt(v2,10);
        });
        arr.push(i);
        return arr;
    });

    const limit = args[0];
    const values = args.splice(1, limit);
    values.sort((a, b) => {
        if(a[0] < b[0]) return -1;
        if(a[0] > b[0]) return 1;
        if(a[1] < b[1]) return 1;
        if(a[1] > b[1]) return -1;
    })
    console.log(values.map((v) => v[2]).join("\n"));
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

bool kaibun(string S){
  for(int i=0;i<S.size()/2;i++){
    if(S.at(i)!=S.at(S.size()-i-1)){
       return false;
    }
  }
       return true;
}

int main(){
  string S;
  cin>>S;
  string mae,ato;
  for(int i=0;i<(S.size()-1)/2;i++)
    mae.push_back(S.at(i));
  for(int i=(S.size()+1)/2;i<S.size();i++)
    ato.push_back(S.at(i));
  //cout<<mae<<" "<<ato<<endl;
  
  if(kaibun(mae)&kaibun(ato)&kaibun(S))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k, s; cin >> k >> s;
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			int tmp = s - i - j;
			if (0 <= tmp && tmp <= k)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {


	int x, y;
	cin >> x >> y;

	if (y >= 2 * x && y <= 4 * x && y % 2 == 0) {
		cout << "Yes";

	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3632
w = int(input())
n = int(input())

nums = list(range(1, w + 1))
for i in range(n):
    ab = input().split(",")
    a = int(ab[0]) - 1
    b = int(ab[1]) - 1

    _a = nums[a]
    nums[a] = nums[b]
    nums[b] = _a
print("\n".join([str(n) for n in nums]))

Measured memory_bytes: 6720
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d",&a,&b);
    if(a==1){
        if(b==2)
            c=3;
        else if(b==3)
            c=2;
    }
    else if(a==2){
        if(b==1)
            c=3;
        else if(b==3)
            c=1;
    }
    else if(a==3){
        if(b==1)
            c=2;
        else if(b==2)
            c=1;
    }
    printf("%d",c);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;

void Debug(auto a);

signed main(){
    int n;
    cin >> n;
    vec(c,n);
    vec(s,n);
    vec(f,n);

    REP(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    c[n-1] = s[n-1] = f[n-1] = 0;
    
    REP(i,n){
        int ans = 0;
        FOR(j,i,n-1){
            if(ans<s[j]){
                ans = s[j] + c[j];
            }
            else if(ans%f[j] == 0){
                ans += c[j];
            }
            else{
                ans = ans/f[j]*f[j]+f[j] + c[j];
            }
        }
        cout << ans << endl;
    }
    
    
    return 0;
}


 
void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	string str;
	cin >> str;
	int charge = 700;

	if (str.at(0) == 'o') charge += 100;
	if (str.at(1) == 'o') charge += 100;
	if (str.at(2) == 'o') charge += 100;

	cout << charge << endl;
	return 0;
}

Measured memory_bytes: 256
I, O, T, J, L, S, Z = map(int, input().split())
if I and J and L:
  a = ((I-1)//2 + (J-1)//2 + (L-1)//2)*2 + 3 + O
else:
  a = 0
b = (I//2 + J//2 + L//2)*2 + O
ans = max(a, b)
print(ans)

Measured memory_bytes: 3060
N = int(input())
a = [int(i) for i in input().split()]
b =  [int(i) for i in input().split()]
c =  [int(i) for i in input().split()]
ans = 0
for i in range(N-1):
    ans += b[a[i]-1]
    if a[i]+1 == a[i+1]:
        if a[i]-1 != N-1 :
            ans += c[a[i]-1]
ans += b[a[N-1]-1]
print(ans)

Measured memory_bytes: 3064
module Main (main) where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main =
  readInts >>= print . showAnswer . solve

type Input  = [Int]
type Output = Int

solve :: Input -> Output
solve [a,p] = (a*3+p) `div` 2

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | ByteString ByteString
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)       = bool "No" "Yes"  b
  show (YESNO b)       = bool "NO" "YES"  b
  show (AB b)          = bool "B"  "A"    b
  show (Number i)      = show i
  show (String s)      = s
  show (ByteString bs) = C8.unpack bs
  show (Compare o)     = ordering "<" "=" ">" o
  show (Compare2 o)    = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

indexMapBS :: Int -> (Char -> Char) -> ByteString -> ByteString
indexMapBS k f s = C8.concat [s1, C8.singleton (f c), s3]
  where
    (s1, s2) = C8.splitAt (k-1) s
    c = C8.head s2
    s3 = C8.tail s2

Measured memory_bytes: 380
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}


int main() {
    int n;
    cin >> n;
    vector<int>dp(n+10000,n);
    dp[0] = 0;
    for(int i = 0;i<n;i++) {
        for(int pow6 = 1;i+pow6<=n;pow6 *= 6) {
            chmin(dp[i+pow6],dp[i]+1); 
        }
        for(int pow9 = 1;i+pow9<=n;pow9 *= 9) {
            chmin(dp[i+pow9],dp[i]+1); 
        }
    }
    cout << dp[n] << endl;
}    

Measured memory_bytes: 640
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return -self.parents[self.find(x)]


n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xysort = [None] * n
for x, y in xy:
    xysort[x - 1] = y - 1

# 解説AC O(n)
uf = Unionfind(n)
tmp, yfrag = 0, [0] * n
for x, y in enumerate(xysort[:n - 1]):
    yfrag[y] = 1
    tmp += yfrag[n - x - 1] + (y > n - x - 1)
    if tmp < x + 1:
        uf.union(x, x + 1)

for x, y in xy:
    print(uf.size(x - 1))


Measured memory_bytes: 116336
#include <iostream>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long sum=2;
	for(int i=0;i<n;i++)
	{
		sum=2*sum+2;
	}
	cout<<sum<<endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    cout << (1000 - (N % 1000)) % 1000 << endl;

    return 0;
}


Measured memory_bytes: 3660
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	int X[11][11];

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}

	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < i; j++) {
			int tmp = 0;
			for (int k = 0; k < D; k++) {
				int s = X[i][k] - X[j][k];
				tmp += s * s;
			}
			int s = sqrt(tmp) + 0.5;
			if (s * s == tmp) {
				ans++;
			}
		}
	}


	cout << ans << endl;

	return 0;
}

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

int Bubble(vector<int> a, int N) {
    int j=0;
    int cnt=0;
    while(j<N*N) {
        for(int i=N-1; i>=1; i--) {
            if(a.at(i-1)>a.at(i)) {
                int tmp;
                tmp = a.at(i);
                a.at(i) = a.at(i-1);
                a.at(i-1) = tmp;
                cnt++;
            }
        }
        j++;
    }
  	for(int i=0; i<N; i++) {
        cout<<a.at(i);
        i==N-1 ? cout<<endl: cout<<' ';
    }
  
    return cnt;
}

int main() {
    int N;  cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin>>a.at(i);
    int count = Bubble(a, N);
    cout << count << endl;
}


Measured memory_bytes: 3148
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define MAX_COST 10000000
#define MOD 1000000007
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

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

int main() {
  int n; cin >>n;
  rep(i,n){
    cout << "ACL";
  }
  print("");
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N; cin>>N;
  REP(A,1,3500){
    REP(B,1,3500){
      int P=(4*A*B-N*A-N*B);
      if(P==0)
        continue;
      int C=N*A*B/P;
      if(C>0&&A*B*C*4==N*(A*B+C*A+B*C)){
        cout<<A<<" "<<B<<" "<<C<<endl;
        goto XYZ;
        }
      } 
    }
  XYZ:;
  }


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int k = int.Parse(Console.ReadLine());
        for(int i = 0; i < k; i ++) {
            Array.Sort(s);
            s[2] *= 2;
        }
        Console.WriteLine(s.Sum());
    }
}

Measured memory_bytes: 11348
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> mayHaveRed(n, false);
	mayHaveRed[0] = true;
	vector<int> ballNum(n, 1);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		mayHaveRed[y] = (mayHaveRed[x] || mayHaveRed[y]);
		ballNum[x]--;
		ballNum[y]++;
		if (ballNum[x] == 0) {
			mayHaveRed[x] = false;
		}
	}
	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (mayHaveRed[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() (i int) {
	sc.Scan()
	i, _ = strconv.Atoi(sc.Text())
	return
}

func main() {
	n := next()
	max, min := -2000000000, 2000000000
	var s int

	for i := 0; i < n; {
		s = next()
		if max < s-min {
			max = s - min
		}
		if min > s {
			min = s
		}
		i++
	}
	fmt.Println(max)
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0 ; i < (n) ; i++)
int main() {
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC";
    }else{
        cout << "ABC";
    }
    return 0;
}

Measured memory_bytes: 3524
using System;

class Program
{
	static void Main(string[] args)
	{
     	int max = int.Parse(Console.ReadLine());
      	string[] num = Console.ReadLine().Split(' ');
      	
      	int s1 = 0;
      	int s2 = 0;
      	int diff = 999;
      
      	for (int i = 0; i < max; i++) {
           s1 += int.Parse(num[i]);
           s2 = 0;
          
           for (int j = (i + 1); j < max; j++) {
             s2 += int.Parse(num[j]);
           }
           int tmp = Math.Abs(s1 - s2);
           if (diff > tmp) {
             diff = tmp;
           }
        }
      	Console.WriteLine(diff);
	}
}

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

int main() {
    int n, ans = 0;
    bool c = true;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A.at(i);
    }
    while(c) {
        c = false;
        for(int i = 0; i < n-1; i++) {
           if(A.at(i) > A.at(i+1)) {
               swap(A.at(i), A.at(i+1));
               c = true;
               ans++;
           }
        }
    }
    for(int i = 0; i < n; i++) {
        cout << A.at(i);
        if(i != n-1) cout << " ";
    }
    cout << endl <<  ans << endl;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0; i<3; i++){
        if(s.at(i) == t.at(i)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

ll f(ll n) {
  if (n < 0) return 0;
  ll res = 0;
  for (ll m = (n / 4) * 4; m <= n; m++) res ^= m;
  return res;
}

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  ll A, B;
  while (cin >> A >> B) {
    ll res = f(B) ^ f(A - 1);
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# けんちょんさんの記事見た！
# https://drken1215.hatenablog.com/entry/2020/06/21/225500
N = int(input())
res = ''

while N:
  N -= 1
  res += chr(ord('a') + N%26)
  N //= 26

print(res[::-1])  # 🍡( ´ ꒳ `🌸)さんありがとー٩(๑❛0❛๑)۶

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

using namespace std;

int main() {
  int n; cin >> n;
  while(n--){
    vector<int> a(9);
    vector<int> b(9);
    long long suma=0,sumb=0;
    for(int i=0;i<9;++i) cin >> a[i];
    for(int i=0;i<9;++i) cin >> b[i];
    sort(a.begin(),a.end()); sort(b.begin(),b.end());
    int anum=0,bnum=0;
    do{
      int asum=0,bsum=0;
      for(int i=0;i<9;++i){
	if(a[i]>b[i]) asum+=a[i]+b[i];
	else bsum+=a[i]+b[i];
      }
      if(asum>bsum) anum++;
      else bnum++;
    }while(next_permutation(b.begin(),b.end()));
    double nums=anum+bnum;
    printf("%.9f %.9f\n",(double)(anum)/nums,(double)(bnum)/nums);
  }
  
  return 0;
}



Measured memory_bytes: 3196
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

int bfs(vector<vector<char>> graph, vector<ii> start, int h, int w) {
    queue<iii> possible;
    set<ii> visited;
    int maximum = 0;
    for (ii start_loc : start) {
        possible.push(make_pair(start_loc, 0));
    }
    while (!possible.empty()) {
        ii xy = possible.front().first;
        int dist_from_start = possible.front().second;
        possible.pop();
        if (visited.find(xy) == visited.end()) {
            if (dist_from_start > maximum) {
                maximum = dist_from_start;
            }
            if (xy.first + 1 < h && graph[xy.first + 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first + 1, xy.second), dist_from_start + 1));
            }
            if (xy.first - 1 >= 0 && graph[xy.first - 1][xy.second] == '.') {
                possible.push(make_pair(make_pair(xy.first - 1, xy.second), dist_from_start + 1));
            }
            if (xy.second - 1 >= 0 && graph[xy.first][xy.second - 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second - 1), dist_from_start + 1));
            }
            if (xy.second + 1 < w && graph[xy.first][xy.second + 1] == '.') {
                possible.push(make_pair(make_pair(xy.first, xy.second + 1), dist_from_start + 1));
            }
            visited.insert(xy);
        }
    }
    return maximum;
}

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> graph(h, vector<char>(w));
    vector<ii> blacks;
    cin.get();
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin.get(graph[i][j]);
            if (graph[i][j] == '#') {
                blacks.push_back(make_pair(i, j));
            }
        }
        cin.get(); //get \n character
    }
    cout << bfs(graph, blacks, h, w);
}

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



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

    for(int i = 1; i <= N; i++)
    {
        string s = to_string(i);
        int sum = 0;
        for(int j = 0; j < s.size(); j++) sum += s.at(j) - '0';
        
        if(sum >= A && sum <= B) ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n; cin >> n;
    vector<ll> t(n); rep(i, n) cin >> t[i];
    ll m; cin >> m;
    vector<ll> p(m), x(m); rep(i, m) cin >> p[i] >> x[i];
    ll sum = 0;
    rep(i, n) sum += t[i];
    rep(i, m) cout << sum - t[p[i]-1] + x[i] << endl;
}

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

using namespace std;

void setIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    //freopen("solution.out", "w", stdout);
    freopen("1.in", "r", stdin);
#endif
}

const int inf = 1e9;

int main() {
    setIO();

    int n, k;
    cin >> n >> k;
    int h[n], dp[n];
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
        dp[i] = inf;
    }
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j < k + 1 && j + i < n; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << "\n";
    return 0;
}


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


int main(){
    int64_t N;
    int64_t ans = 0;
    cin >> N;
    vector<int64_t> a(N);
    for(int64_t i = 0; i < N;i++){
        cin >> a.at(i);
    }
    for(int64_t j = 0; j < N;j += 2){
        if(a.at(j)%2==1){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  i64 n;
  cin >> n;
  queue<i64> a[n];
  for (i64 i = 0; i < n; i++)
    for (i64 j = 0; j < n - 1; j++)
    {
      i64 t;
      cin >> t;
      a[i].push(t - 1);
    }

  i64 fin = 0;
  for (i64 i = 0;; i++)
  {
    bool match = false;
    vector<bool> use(n);
    for (i64 j = 0; j < n; j++)
      if (0 < a[j].size())
      {
        i64 jf = a[j].front();
        if (!use[j] && !use[jf] && 0 < a[jf].size() && j == a[jf].front() && jf == a[j].front())
        {
          match = true;
          use[jf] = true;
          use[j] = true;
          a[jf].pop();
          a[j].pop();
          fin++;
        }
      }
    if (!match)
    {
      cout << -1 << endl;
      return 0;
    }
    if (fin == n * (n - 1) / 2)
    {
      cout << i + 1 << endl;
      return 0;
    }
    if (1950 < chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000)
    {
      cout << n * (n - 1) / 2 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 8960
#include<stdio.h>
#define it register int
#define ct const int
#define il inline
#define P 1000000007
const int N=5005;
int fac[N],inv[N],ifac[N],a[N],f[N][N][2],ans,n;
bool flag;
int main(){
	scanf("%d",&n);it i,j,k;
	for(i=1;i<=n;++i) scanf("%d",&a[i]),flag|=(a[i]^2);
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
	for(i=2;i<=n;++i)
		fac[i]=(0ll+fac[i-1])*i%P,inv[i]=(0ll+inv[P%i])*(P-P/i)%P,ifac[i]=(0ll+ifac[i-1])*inv[i]%P;
	if(!flag) return printf("%d",(0ll+fac[n-1])*inv[2]%P),0;//大环
	f[0][0][0]=1;
	//f[i][j][0/1] : i个点 选择了环上j个点 是否选了一个度数为 d - 3 的点
	for(i=0;i<n;++i)
		for(j=0;j<n;++j)
			for(k=0;k<2;++k){
				if(f[i][j][k]){
					if(a[i+1]>0) //树
						f[i+1][j][k]=(f[i+1][j][k]+(0ll+f[i][j][k])*ifac[a[i+1]-1])%P;
					if(a[i+1]>1) //环
						f[i+1][j+1][k]=(f[i+1][j+1][k]+(0ll+f[i][j][k])*ifac[a[i+1]-2])%P;
					if(a[i+1]>2&&!k) //最后一个d-3还没选，把这个点选上去
						f[i+1][j+1][1]=(f[i+1][j+1][1]+(0ll+f[i][j][0])*ifac[a[i+1]-3])%P;
				}
			}
	for(i=3;i<n;++i) ans=(ans+(0ll+fac[i-1])*inv[2]%P*fac[n-i-1]%P*f[n][i][1])%P;
	printf("%d",ans); 
	return 0;
}


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

#define uint        unsigned int
#define ld          long double
#define int         long long
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*const int mod = 998244353;
int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}
*/


signed main()
{
    showoff;
    int n,a,b;
    cin >> n >> a >> b;
    if(a+b >= n)cout << min(a,b) << " " << a+b-n;
    else cout << min(a,b) << " " << 0;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin >> s;
    long long int q;
    cin >> q;
      
    for(long long int i=0;i<q;i++){
        string in;
        cin >> in;
        if(in=="print"){
            long long int a,b;
            cin>>a>>b;
            cout<< s.substr(a,b-a+1)<<endl;
              
        }else if(in=="reverse"){
            long long int a,b;
            cin>>a>>b;
            string k=s;
            for(long long int j=a;j<=b;j++){
                s[j]=k[a+b-j];
            }
        }else if (in=="replace"){
            long long int a,b;
            cin>>a>>b;
            for(long long int j=a;j<=b;j++){
                char c;
                cin>>c;
                s[j]=c;
            }
        }
    }
}


Measured memory_bytes: 3228
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	brokenStairs := ScanNums(m)

	brokenStairsCount := len(brokenStairs)
	brokenStairsMapping := map[int]bool{}
	for i := 0; i < brokenStairsCount; i++ {
		stairNum := brokenStairs[i]
		brokenStairsMapping[stairNum] = true
		if i+1 == brokenStairsCount {
			continue
		}
		if stairNum+1 == brokenStairs[i+1] {
			fmt.Println(0)
			return
		}
	}

	dp := make([]int, n+1)
	for i := 0; i <= n; i++ {
		if brokenStairsMapping[i] {
			continue
		}
		if i < 2 {
			dp[i] = 1
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
		}
	}
	fmt.Println(dp[n])
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 5504
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	int a[n];
	int b[n+1];
	
	rep(i,0,n){
		cin >> a[i];
		if(i == 0 )
			b[i] = abs(0-a[i]);
		else
			b[i] = abs(a[i-1] - a[i]);
	}
	b[n] = abs(a[n-1]);
	
	long sum = 0;
	rep(i,0,n+1)
		sum += b[i];
	
	rep(i,0,n){
		long ans;
		if(i == 0 )
			ans = sum - b[0] - b[1] + abs(a[1]);
		else if( i < n - 1 )
			ans = sum - b[i] - b[i+1] + abs(a[i-1]-a[i+1]);
		else
			ans = sum - b[i] - b[i+1] + abs(a[n-2]);
		P(ans);
	}	
	
	ret 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<int> Array;
typedef vector<Array> Matrix;
int minimum_steiner_tree(const vector<int>& T, const Matrix &g) {
  const int n = g.size();
  const int numT = T.size();
  if (numT <= 1) return 0;

  Matrix d(g); // all-pair shortest
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        d[i][j] = min( d[i][j], d[i][k] + d[k][j] );

  int OPT[(1 << numT)][n];
  for (int S = 0; S < (1 << numT); ++S)
    for (int x = 0; x < n; ++x)
      OPT[S][x] = INF;

  for (int p = 0; p < numT; ++p) // trivial case
    for (int q = 0; q < n; ++q)
      OPT[1 << p][q] = d[T[p]][q];

  for (int S = 1; S < (1 << numT); ++S) { // DP step
    if (!(S & (S-1))) continue;
    for (int p = 0; p < n; ++p)
      for (int E = 0; E < S; ++E)
        if ((E | S) == S)
          OPT[S][p] = min( OPT[S][p], OPT[E][p] + OPT[S-E][p] );
    for (int p = 0; p < n; ++p)
      for (int q = 0; q < n; ++q)
        OPT[S][p] = min( OPT[S][p], OPT[S][q] + d[p][q] );
  }
  int ans = INF;
  for (int S = 0; S < (1 << numT); ++S)
    for (int q = 0; q < n; ++q)
      ans = min(ans, OPT[S][q] + OPT[((1 << numT)-1)-S][q]);
  return ans;
}

int main(){
  int H, W;
  while(cin >> H >> W && H){
    int a[16][16];
    REP(y, H) REP(x, W) cin >> a[y][x];
    int N = W * H;
    Matrix d(N, Array(N, INF));
    REP(y, H) REP(x, W){
      REP(y2, H) REP(x2, W){
        int diff = abs(y2 - y) + abs(x2 - x);
        int u = y * W + x;
        int v = y2 * W + x2;
        if(diff <= 1) d[u][v] = diff;
      }
    }
    vector<int> T;
    REP(y, H) REP(x, W) if(a[y][x] == 1) T.push_back(y * W + x);
    int ans = N - (minimum_steiner_tree(T, d) + 1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1420
# Problem 1 - 最大公約数

def gcd(a, b):
    if a<b:
        tmp = a
        a = b
        b = tmp
    while b>0:
        r = a % b
        a = b
        b = r
    return a

# input
a, b = map(int, input().split())

# output
print(gcd(a, b))



Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    long long a, b, k;
    cin >> a >> b >> k;
    int i = 0;
    for (;;) {
        if (i == k) {
            break;
        }
        if (a % 2 == 1) {
            --a;
        }
        b += a / 2;
        a /= 2;
        if (++i == k) {
            break;
        }
        if (b % 2 == 1) {
            --b;
        }
        a += b / 2;
        b /= 2;
        if (++i == k) {
            break;
        }
    }
    cout << a << " " << b;
    return 0;
}

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

public class Main {

    private static int MOD = 1_000_000_007;

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


    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        long[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
        long first = 0;
        if (n[0] % 2L == 1L) {
            first = n[0];
            n[0]++;
        }
        long last = 0;
        if (n[1] % 2L == 0L) {
            last = n[1];
            n[1]--;
        }
        long msb = (((n[1] + 1 - n[0]) / 2)  % 2 == 1) ? 1 : 0;
        System.out.println(first ^ last ^ msb);
    }

}


Measured memory_bytes: 28620
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main implements Runnable {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;


	static int[][][] undirectedGraph(int n, int[] v1, int[] v2, int[] cost) {
		int[] cnt = new int[n];
		for (int i : v1) cnt[i]++;
		for (int i : v2) cnt[i]++;

		int[][][] g = new int[n][][];
		for (int i=0; i<n; i++) g[i] = new int[cnt[i]][2];
		for (int i=0; i<v1.length; i++) {
			int s = v1[i];
			int t = v2[i];

			g[s][--cnt[s]][0] = t;
			g[s][cnt[s]][1] = cost[i];

			g[t][--cnt[t]][0] = s;
			g[t][cnt[t]][1] = cost[i];
		}

		return g;
	}

	static int[] height(int[][][] g) {
		int n = g.length;

		int[][][] dp = new int[n][][];
		for (int i=0; i<n; i++) {
			dp[i] = new int[g[i].length][2];
			for (int j=0; j<g[i].length; j++) {
				dp[i][j][1] = -1;
			}
		}
		for (int i=0; i<n; i++)
			for (int j=0; j<g[i].length; j++)
				if (dp[i][j][1] < 0)
					dp[i][j][1] = dfs(g, dp, i, j);

		int[] res = new int[n];
		for (int i=0; i<n; i++)
			for (int j=0; j<g[i].length; j++)
				res[i] = Math.max(res[i], dp[i][j][1]);

		return res;
	}

	static int dfs(int[][][] g, int[][][] dp, int src, int idx) {
		if (dp[src][idx][1] >= 0) return dp[src][idx][1];
		dp[src][idx][1] = g[src][idx][1];
		int dst = g[src][idx][0];
		for (int k=0; k<g[dst].length; k++) {
			int next = g[dst][k][0];
			if (next == src) continue;
			dp[src][idx][1] = Math.max(dp[src][idx][1], dfs(g, dp, dst, k) + g[src][idx][1]);
		}
		return dp[src][idx][1];
	}

	public void run() {
		int n = in.nextInt();
		int[] s = new int[n-1];
		int[] t = new int[n-1];
		int[] w = new int[n-1];
		for (int i=0; i<n-1; i++) {
			s[i] = in.nextInt();
			t[i] = in.nextInt();
			w[i] = in.nextInt();
		}
		int[][][] g = undirectedGraph(n, s, t, w);
		int[] h = height(g);
		for (int i=0; i<n; i++) {
			out.println(h[i]);
		}

		out.flush();
		in.close();
		out.close();
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 61748
def ABC_77_A():
    C1= input()
    C2 =input()
    
    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':

    ABC_77_A()

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

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

const ull mod = (ull)1e9 + 7;

int main(void)
{
	int n;
	cin >> n;
	vector<pair<string, ll>> m(n);
	rep(i, n) {
		cin >> m[i].first >> m[i].second;
	}
	string tar;
	cin >> tar;
	bool b = false;
	ll sum = 0;
	rep(i, n) {
		if (b) {
			sum += m[i].second;
		}
		if (tar == m[i].first) {
			b = true;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,Y; cin>>N>>Y;
    REP(i,N+1) {
        REP(j,N+1) {
            int k = N-i-j;
            if (k>=0 && k*1000+j*5000+i*10000==Y) {
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end

s,t=get
a,b=get_i
u=gets.chomp
a-=1 if s==u
b-=1 if t==u
puts "#{a} #{b}"

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] > rank[y]){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

int main(){
	ll n,m; cin >> n >> m;
	vector<tapu> edges(m);
	rep(i,m){
		ll u,v,d; cin >> u >> v >> d;
		edges[i] = tie(d,u,v);
	}
	sort(all(edges));
	UnionFind uf(n);
	ll ans = 0;
	rep(i,m){
		ll u,v,d;
		tie(d,u,v) = edges[i];
		if(uf.same(u,v)) continue;
		uf.unite(u,v);
		ans += d;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 5476
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func nextInt64() int64 {
	stdInScanner.Scan()
	i, _ := strconv.ParseInt(stdInScanner.Text(), 10, 64)
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt64()

	answer := int64(0)
	for i := int64(1); i <= N; i++ {
		if i%3 == 0 && i%5 == 0 {
			continue
		} else if i%3 == 0 {
			continue
		} else if i%5 == 0 {
			continue
		} else {
			answer += i
		}
	}

	fmt.Println(answer)
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
long double dp[305][305][305];
int a[4];
int n;
void bfs(int one, int two, int three){
    if(one == 0 && two == 0 && three == 0) return;
    if(one < 0 || two < 0 || three < 0) return;
    if(dp[one][two][three] != 0) return;
    //cout << "called " << one << " " << two << " " << three << endl;
    //cout << one << " " << two << " " << three << endl;
    bfs(one, two + 1, three - 1);
    bfs(one + 1, two - 1, three);
    bfs(one - 1, two, three);
    if(dp[one][two][three] != 0) return;
    int total = one + two + three;
    dp[one][two][three] = 0;
    if(three > 0) dp[one][two][three] += dp[one][two + 1][three - 1] * (long double)three / (long double)total;
    //cout << "three" << endl;
    if(two > 0) dp[one][two][three] += dp[one + 1][two - 1][three] * (long double)two / (long double)total;
    //cout << "two" << endl;
    if(one > 0) dp[one][two][three] += dp[one - 1][two][three] * (long double)one / (long double)total;
    dp[one][two][three] += (long double)n / (long double)total;
    //cout << "Calculated " << one << " " << two << " " << three << " " << endl << dp[one][two][three] << endl;
    return;
}
int main() {
    cout.precision(10);
    cin >> n;
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        a[in]++;
    }
    bfs(a[1], a[2], a[3]);
    cout << dp[a[1]][a[2]][a[3]] << endl;
    return 0;
}


Measured memory_bytes: 436480