akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
    int N, Y;
    cin >> N >> Y;
    int n10 = -1, n5 = -1, n1 = -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) {
                n10 = i;
                n5 = j;
                n1 = k;
            }
        }
    }
    cout << n10 << " " << n5 << " " << n1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const long long mod = 998244353;

int dist[2005][2005];
int ans[2005];

signed main() {
	int n, x, y; cin >> n >> x >> y;
	rep(i, n)rep(j, n)dist[i][j] = abs(i - j);
	x--; y--;
	rep(i, n) {
		rep(j, n) {
			dist[i][j] = min(dist[i][j], dist[i][x] + dist[y][j] + 1);
		}
	}
	swap(x, y);
	rep(i, n) {
		rep(j, n) {
			dist[i][j] = min(dist[i][j], dist[i][x] + dist[y][j] + 1);
		}
	}
	rep(i, n)rep(j, i)ans[dist[i][j]]++;
	rep(i, n - 1)cout << ans[i + 1] << endl;
}

Measured memory_bytes: 31616
S = input()
slen = len(S)

N = 1 << (slen-1)

ans = 0
for i in range(N):
    eq = ''
    for j in range(slen):

        if i & 1<<j:
            eq += S[j:j+1] + '+'
        else:
            eq += S[j:j+1]

    ans += eval(eq)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int n;
  cin>>n;

  string s;
  cin>>s;

  //赤を左に寄せる
  //左からと右から
  int64_t left=0,right=n-1;

  int64_t cnt=0;
  while(left<right){


    while(s.at(left)=='R'){
      left++;
      if(left==n-1)
        break;
    }

    while(s.at(right)=='W'){
      right--;
      if(left==0)
        break;
    }

    #if 0
    cout<<"---------------"<<endl;
    cout<<s<<endl;
    cout<<"left="<<left<<endl;
    cout<<"right="<<right<<endl;
    cout<<"cnt="<<cnt<<endl;
    cout<<"---------------"<<endl;
    #endif

    if(s.at(left)=='W' && s.at(right)=='R' && left<right){
      char wk=s.at(left);
      s.at(left)=s.at(right);
      s.at(right)=wk;
      cnt++;
    }
  }

  cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 3736
while(True):
    n, r = map(int, input().split())
    if n == 0 and r == 0: exit()

    ope = [list(map(int, input().split())) for _ in range(r)]
    d = [n-i for i in range(n)]

    for i in range(r):
        tv = d[ope[i][0]-1:ope[i][0]-1+ope[i][1]]
        to = d[:ope[i][0]-1] + d[ope[i][0]-1+ope[i][1]:]
        d = tv + to
    print(d[0])



Measured memory_bytes: 5620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (map.containsKey(x)) {
                map.put(x, map.get(x) + 1);
            } else {
                map.put(x, 1);
            }
        }
        for (int i = 0; i < m; i++) {
            int count = sc.nextInt();
            int value = sc.nextInt();
            while (count > 0 && value > map.firstKey()) {
                int x = map.firstKey();
                int y = map.get(x);
                if (y <= count) {
                    if (map.containsKey(value)) {
                        map.put(value, y + map.get(value));
                    } else {
                        map.put(value, y);
                    }
                    count -= y;
                    map.remove(x);
                } else {
                    if (map.containsKey(value)) {
                        map.put(value, map.get(value) + count);
                    } else {
                        map.put(value, count);
                    }
                    map.put(x, y - count);
                    count = 0;
                }
            }
        }
        long ans = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            ans += (long)entry.getKey() * entry.getValue();
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 76260
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    string s,t;
    int k;
    cin >> s >> k;
    vector<string> m(0);
    set<string> check;
    rep0(i, s.size()){
        rep1(j, min(k,(int)(s.size() - i))){
            t = s.substr(i,j);
            if(check.find(t) == check.end()){
                check.insert(t);
                m.push_back(t);
            }
        }
    }
    sort(all(m));
    pf(m[k - 1])
    return 0;
}


Measured memory_bytes: 1792
import Numeric

mink :: Int -> Int -> [Int] -> [Int] -> Double
mink p n xs ys = fromIntegral (foldr step 0 (zip xs ys)) ** (1 / fromIntegral p)
  where step (x, y) sum = sum + (abs (x - y)) ^ p

cheby n xs ys = maximum $ map (\t -> abs (fst t - snd t)) (zip xs ys)

main = do
  n <- readLn :: IO Int
  xs <- fmap (map read . words) getLine :: IO [Int]
  ys <- fmap (map read . words) getLine :: IO [Int]
  putStrLn $ show $ mink 1 n xs ys
  putStrLn $ show $ mink 2 n xs ys
  putStrLn $ show $ mink 3 n xs ys
  putStrLn $ show $ cheby n xs ys

Measured memory_bytes: 4352
fn main(){
    let n: u64 = read();
    let ans: u64 = (1..).take_while(|i| i * i <= n)
        .filter(|i| n % i == 0).map(|i| i + n / i - 2).min().unwrap();
    
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn=2e5+10;
int a[maxn];


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum^=a[i];
    }
    vector<ll>ans;
    for(int i=1;i<=n;i++)
    {
        ll x=sum^a[i];
        ans.pb(x);
    }
    for(auto &v:ans)
        cout<<v<<" ";
    cout<<'\n';


}


Measured memory_bytes: 6032
import math
K=int(input())
k=K+1
ans=0
for a in range(1,k):
    for b in range(a,k):
        for c in range(b,k):
            m=math.gcd(a,b)
            o=math.gcd(m,c)
            if a==b and b==c:
                n=o
            elif a==b or b==c:
                n=o*3
            else:
                n=o*6
                
            ans+=n

print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

const ll MOD = 998244353;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(auto & e: A) cin >> e;

    // Rに注目したとき
    // dp[i][j] := i番目までみたとき、Rの合計がjとなる場合の数
    vector<vector<ll>> dp(N+1, vector<ll>(300*300+1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 300 * 300 + 1; j++) {
            dp[i+1][j] += 2 * dp[i][j]; // BとGでそれぞれあるので*2
            dp[i+1][j] %= MOD;
            if(j + A[i] < 300 * 300 + 1) {
                dp[i+1][j+A[i]] += dp[i][j];
                dp[i+1][j+A[i]] %= MOD;
            }
        }
    }

    // Rに注目したとき
    // dp[i][j] := i番目まで見たとき、Rの合計がjかつGの合計が0となる場合の数
    vector<vector<ll>> dp2(N+1, vector<ll>(300*300+1, 0));
    dp2[0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 300 * 300 + 1; j++) {
            dp2[i+1][j] += dp2[i][j]; // G=0なので自動的にBに振られる
            dp2[i+1][j] %= MOD;
            if(j + A[i] < 300 * 300 + 1) {
                dp2[i+1][j+A[i]] += dp2[i][j];
                dp2[i+1][j+A[i]] %= MOD;
            }
        }
    }

    ll sum = 0;
    for(const auto &e : A) {
        sum += e;
    }

    // 三角形の条件を満たさないのはR >= sum/2 or B >= sum/2 or C >= sum/2のとき
    ll ans = 0;
    for(int i = 0; i <= sum; i++) {
        if(i * 2 >= sum) {
            ans += dp[N][i];
            ans %= MOD;
        }
    }

    ans *= 3; // sum/2以上がそれぞれR,G,Bのばあい
    ans %= MOD;

    // R >= sum/2 かつ G >= sum/2 かつ B = 0などが重複しているため、引く
    if(sum % 2 == 0) {
        ans += 3 * MOD - 3 * dp2[N][sum/2]; // R = 0, G = 0, B = 0それぞれあるので*3
        ans %= MOD;
    }

    // 全体の場合の数から条件を満たさないものを引く
    cout << (mod_pow(3, N, MOD) + MOD - ans) % MOD << endl;

    return 0;
}

Measured memory_bytes: 424512
using System;

class ABC_141_B
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();

        bool isEasy = true;

        for (int i = 0; i < S.Length; i++)
        {
            char c = S[i];

            if (i % 2 == 0 && c == 'L') isEasy = false;
            if (i % 2 == 1 && c == 'R') isEasy = false;
        }

        if (isEasy)
        {
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n, m;
        cin >> n >> m;
        if (!n) return 0;

        vector<vector<pair<P, int>>> edges(n);
        for (int i = 0; i < m; ++i) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u;
            --v;
            edges[u].push_back(make_pair(P(d, c), v));
            edges[v].push_back(make_pair(P(d, c), u));
        }
        vector<int> dist(n, M);
        dist[0] = 0;
        vector<bool> checked(n);
        priority_queue<pair<P, int>, vector<pair<P, int>>, greater<pair<P, int>>> q;
        q.push(make_pair(P(0, 0), 0));
        int ans = 0;
        while (!q.empty()) {
            auto p = q.top();
            q.pop();
            if (checked[p.second]) continue;
            checked[p.second] = true;
            ans += p.first.second;
            for (auto& e : edges[p.second]) {
                if (dist[e.second] >= dist[p.second] + e.first.first) {
                    dist[e.second] = dist[p.second] + e.first.first;
                    q.push(make_pair(P(dist[e.second], e.first.second), e.second));
                }
            }
        }
        cout << ans << "\n";
    }
}



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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int a[n], count = 0;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		for(int j = i+1; j < n; j++)
			for(int k = j+1; k < n; k++)
			{
				if(a[i] == a[j] or a[j] == a[k] or a[i] == a[k])
					continue;
				vector<int> v = {a[i], a[j], a[k]};
				sort(v.begin(), v.end());
				if(v[0]+v[1] > v[2])
					count++;
			}
	cout << count;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ans = 0; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) for(int k = j + 1; k < n; k++)
		if(a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
			ans += a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i];
	cout << ans;

	return 0;
}

Measured memory_bytes: 3660
n = int(input())
p = list(map(int, input().split()))

flag = 0
for i in range(n):
    for j in range(i+1, n):
        p[i], p[j] = p[j], p[i]
        for k in range(n):
            for l in range(k+1, n):
                if p[k] > p[l]:
                    flag = 1
                    break
        if flag == 0:
            print("YES")
            exit()
        p[i], p[j] = p[j], p[i]
        flag = 0

flag = 0
for i in range(n):
    for j in range(i+1, n):
        if p[i] > p[j]:
            flag = 1
if flag:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3064
from heapq import heappushpop
import sys
X, Y, Z = map(int, sys.stdin.readline().split())
N = X+Y+Z
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
ABC.sort(key = lambda x: x[0] - x[1], reverse = True)

GB = [None]*N
Q = [a - c for a, _, c in ABC[:X]]
Q.sort()
gs = sum(a for a, _, _ in ABC[:X])
GB[X-1] = gs
for i, (a, b, c) in enumerate(ABC[X:X+Z], X):
    gs += - heappushpop(Q, a - c) + a
    GB[i] = gs

SB = [None]*N
Q = [b - c for _, b, c in ABC[X+Z:]]
Q.sort()
ss = sum(b for _, b, _ in ABC[X+Z:])
SB[-Y-1] = ss
for i, (a, b, c) in enumerate(ABC[X+Z-1:X-1:-1], 1):
    i = -Y - i
    ss += - heappushpop(Q, b - c) + b
    SB[i-1] = ss
print(max(i + j for i, j in zip(GB[X-1:X+Z], SB[X-1:X+Z])))

Measured memory_bytes: 39248
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] nums = new int[10];
		String s;
		
		while (sc.hasNext()) {
			
			s = sc.next();
			for (int i=0; i<10; i++) {
				nums[i] = Character.getNumericValue(s.charAt(i));
			}
			
			for (int i=0; i<9; i++) {
				for (int j=0; j<9-i; j++) {
					nums[j] = (nums[j]+nums[j+1])%10;
				}
			}
			
			out.println(nums[0]);
			
		}
	}
}


Measured memory_bytes: 26012
#include <bits/stdc++.h>
#include<set>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back

int main()
{
    ll n,k,d,a;
    set<int> s;
    cin>>n>>k;
    int c=0;
    while(k--)
    {
      cin>>d;
      for(int i=0;i<d;i++){
        cin>>a;
        s.insert(a);
      }
    }
    c+=s.size();
    cout<<n-c;
    return 0;
   }



Measured memory_bytes: 3628
H,W = [int(x) for x in input().split()]
A = [[x for x in input()] for _ in range(H)]
#%%
maps = [[-1]*W for _ in range(H)]
mv=[[1,0],[-1,0],[0,1],[0,-1]]
cnt = 0
li=[]
que = []
for h,i in enumerate(A):
    for w,j in enumerate(i):
        if(j=='#'):
            maps[h][w]=0
            que.append([h,w])
while(True):
    next_que=[]
    while(que):
        x = que.pop()
        now = maps[x[0]][x[1]]
        for i in mv:
            if(0<=x[0]+i[0]<H and 0<=x[1]+i[1]<W):
                if(maps[x[0]+i[0]][x[1]+i[1]]==-1):
                    maps[x[0]+i[0]][x[1]+i[1]]=now+1
                    next_que.append([x[0]+i[0],x[1]+i[1]])
    if(len(next_que)==0):
        break
    else:
        cnt += 1
        que=next_que
print(cnt)


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

int main()
{
    long long K;
    cin >> K;
    queue<long long> q;
    for (long long i = 1; i <= 9; ++i) q.push(i);

    long long cnt = 0;

    long long x;
    while(cnt <= K)
    {
        // 昇順で queue に格納されているので,K回目に取り出した数が求める答え
        x = q.front();
        ++cnt;
        if (cnt >= K) break;
        q.pop();

        int r = x % 10;
        // 10 * x + (r - 1), 10 * x + r , 10 * x + (r + 1) が Lunlun 数の候補
        // r = 0, 9 の場合は端を除外

        if (r == 0)
        {
            q.push(10 * x);
            q.push(10 * x + 1);
        }
        else if (r == 9)
        {
            q.push(10 * x + 8);
            q.push(10 * x + 9);
        }
        else
        {
            q.push(10 * x + r - 1);
            q.push(10 * x + r);
            q.push(10 * x + r + 1);
        }  
    }
    printf("%lld\n", x);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a,n,t=0;
	cin >> n;
	rep(i, n) {
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			t++;
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

vector <int> v[100005];
vector <int> dp(100005,0);
vector <bool> visto(100005,false);

void DFS(int n)
{
	visto[n]=true;
	for(auto u : v[n])
	{
		if(!visto[u]) DFS(u);
		dp[n]=max(dp[n],dp[u]+1);
	}
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	int n, m;
	cin >> n >> m;
	forn(i,m)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
	}
	forn(i,n+1)
	{
		if(visto[i]==false) DFS(i);
	}
	int ans = 0;
	forn(i,n+1) ans = max(ans,dp[i]);
	cout << ans << endl;
    return 0;
}


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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	reverse(b.begin(), b.end());
	int start = -1, fin = -1;
	for (int i = 0; i < n; ++i) {
		if (b[i] == a[i]) {
			if (start == -1) start = i;
			fin = i;
		}
	}
	bool bad = 0;
	if (start != -1) {
		for (int i = 0, j = start; j <= fin; ++i) {
			if (i == start) i = fin + 1;
			if (i == n) {
				break;
			}
			if (a[i] != b[j] && b[i] != b[j]) {
				swap(b[i], b[j]);
				j++;
			}
		}
		for (int i = 0; i < n; ++i) 
			bad |= (a[i] == b[i]);
	}
	if (bad) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < n; ++i) {
			if (i) cout << " ";
			cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

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


int main(){
    int n,m,s;
    cin>>n>>m>>s;
    int is[501][501]={0};
    int l,r;
    for(int i=0;i<m;i++){
        cin>>l>>r;
        is[l][r]++;
    }
    int p[100005],q[100005];
    for(int i=0;i<s;i++){
        cin>>p[i]>>q[i];
    }
    int dp[501][501]={0};
    for(int j=0;j<=n;j++){
        dp[j][j]=is[j][j];
        for(int i=j-1;i>=0;i--){
            dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]+is[i][j];
        }
    }
    for(int i=0;i<s;i++){
        cout<<dp[p[i]][q[i]]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(){
	int a,b,c;

	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7)
	cout<<"YES"<<endl;
	else if(a==5&&b==7&&c==5)
	cout<<"YES"<<endl;
	else if(a==7&&b==5&&c==5)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll dp[101000][3];

int main(){
    ll n, k, r, s, p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string t;   cin >> t;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < k; i++){
        if(t[i] == 'r'){
            dp[i][0] = p;
        }
        else if(t[i] == 's'){
            dp[i][1] = r;
        }
        else{
            dp[i][2] = s;
        }

        for(int j = i+k; j < n; j += k){
            if(t[j] == 'r'){
                dp[j][0] = max(dp[j-k][1], dp[j-k][2]) + p;
                dp[j][1] = max(dp[j-k][0], dp[j-k][2]);
                dp[j][2] = max(dp[j-k][0], dp[j-k][1]);
            }
            else if(t[j] == 's'){
                dp[j][0] = max(dp[j-k][1], dp[j-k][2]);
                dp[j][1] = max(dp[j-k][0], dp[j-k][2]) + r;
                dp[j][2] = max(dp[j-k][0], dp[j-k][1]);
            }
            else{
                dp[j][0] = max(dp[j-k][1], dp[j-k][2]);
                dp[j][1] = max(dp[j-k][0], dp[j-k][2]);
                dp[j][2] = max(dp[j-k][0], dp[j-k][1]) + s;
            }
        }
    }

    ll res = 0;
    for(int i = n-1; i >= n - k; i--){
        res += max(dp[i][0], max(dp[i][1], dp[i][2]));
    }
    cout << res << endl;


    return 0;
}


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

using namespace std;

int main()
{
    int n,x,t;
    cin >> n >> x >> t ;

    if(n%x == 0)
        cout << t * (n/x) << endl;
    else
        cout << t * (n/x +1) << endl;

   return 0;
}

Measured memory_bytes: 3632
#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;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define foreach(v, c) for(__typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define revforeach(v, c) for(__typeof( (c).rbegin()) v = (c).rbegin();  v != (c).rend(); ++v)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

typedef long long int slong;
typedef pair<int, int> pii;
typedef pair<slong, slong> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

#ifdef VSP4 
    #include "debug.h"    
#else
    #define debug(args...)                  // Just strip off all debug tokens
#endif

const int MOD = 1000000007;
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

const int MAXN = 3e6;
const int SQRTN = 550;
const int LOGN = 60;
const int INT_INFINITY = 1001001001;
const int LIMIT = 1e6;

const slong LONG_INFINITY = 1001001001001001001ll;
const slong LONG_LIMIT = 200100100100101ll;

int n;
int arr[MAXN+5];

int main()
{
	#ifdef VSP4
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cout.tie(0);
	cin.tie(0);
	
	int t, i, j, d, u, v;
	
	{
		cint(n);
		
		for (i = 1; i <= 3*n; i++)
		{
			cint(arr[i]);
		}
		
		sort(arr + 1, arr + 3*n + 1);
		
		i = 1;
		j = 3*n;
		
		int start = 1;
		int last = 3*n;
		
		slong ans = 0;
		
		for (i = 1; i <= n; i++)
		{
			start++;
			last--;
			ans += arr[last--];
		}
		
		cout << ans;
		
	}
	
	return 0;
}


Measured memory_bytes: 1408
n, k = map(int,input().split())
x = (n-2)*(n-1)//2

if k > x:
    print(-1)
    exit()

ans = []
for i in range(2, n+1):
    ans.append([1, i])
i = 2
j = 3
while k < x:
    ans.append([i, j])
    if j < n:
        j += 1
    else :
        i += 1
        j = i+1
    x -= 1 

print(len(ans))
for i in range(len(ans)):
    b = [str(i) for i in ans[i]]
    print(' '.join(b))

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

int main(){
    string n; cin>>n;
    int a=n[0]-'0';

    int cnt=0;
    for(int i=1;i<n.length();i++){
        if(n[i]=='9') cnt++;
    }
    if(cnt==n.length()-1) cout<<a+9*(n.length()-1)<<endl;
    else cout<<a-1+9*(n.length()-1)<<endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def z_to_xor(a):
	if a % 2 == 1:
		return ((a + 1) // 2 % 2)
	else:
		return ((a // 2 % 2) ^ a)

print(z_to_xor(A - 1) ^ z_to_xor(B))


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

using namespace std;

int main() {
    long a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << "0" << endl;
        return 0;
    }
    long ans = 1;
    b -= a;
    while (b > 0) {
        b -= (a-1);
        ++ans;
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, X;
  cin >> N >> A;
  X = N % 500;
  if (X <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewMe)
{
  StNode*  poParnt = nullptr;
  StNode** ppoNode = &rpoRoot;

  while (*ppoNode)
  {
    poParnt = *ppoNode;
    if (poNewMe->m_nKey < poParnt->m_nKey)
      ppoNode = &poParnt->m_poLeft;
    else
      ppoNode = &poParnt->m_poRigt;
  }

  poNewMe->m_poParnt = poParnt;
  *ppoNode = poNewMe;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnDelete(StNode*& rpoRoot, StNode* poDelMe)
{
  StNode** ppoPrToMe;
  if (poDelMe == rpoRoot)
    ppoPrToMe = &rpoRoot;
  else
    if (poDelMe->m_nKey < poDelMe->m_poParnt->m_nKey)
      ppoPrToMe = &poDelMe->m_poParnt->m_poLeft;
    else
      ppoPrToMe = &poDelMe->m_poParnt->m_poRigt;

  int nDegr = 0;
  StNode* poMeToCd;
  if (poDelMe->m_poLeft)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poLeft;
  }
  if (poDelMe->m_poRigt)
  {
    ++nDegr;
    poMeToCd = poDelMe->m_poRigt;
  }

  if (!nDegr)
  {
    *ppoPrToMe = nullptr;
    delete poDelMe;
  }
  else if (nDegr == 1)
  {
    *ppoPrToMe = poMeToCd;
    poMeToCd->m_poParnt = poDelMe->m_poParnt; 
    delete poDelMe;
  }
  else if (nDegr == 2)
  {
    StNode* poNext = poDelMe->m_poRigt;
    while (poNext->m_poLeft)
      poNext = poNext->m_poLeft;

    poDelMe->m_nKey = poNext->m_nKey;
    fnDelete(rpoRoot, poNext);
  }
}

void fnInOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (!poNode)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewMe = new StNode(nNo);
      fnInsert(rpoRoot, poNewMe);
    }
    else if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    else if (sCmd[0] == 'd')
    {
      int nNo;
      cin >> nNo;
      StNode* poDelMe;
      if (poDelMe = fnFind(rpoRoot, nNo))
        fnDelete(rpoRoot, poDelMe);
      else;
    }
    else if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
    else;
  }
}

void fnPstOrder(StNode* poNode)
{
  if (!poNode)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
  return 0;
}

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

int main() {
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long A, B;
		cin >> A >> B;
		if (A == B) {
			cout << A * 2 - 2 << endl;
		}
		else {
			long long L = 1, R = 1LL << 31;
			while (R - L > 1) {
				long long MID = (L + R) / 2;
				long long MAX = (MID + 1) / 2 * (MID + 1 - (MID + 1) / 2);
				if (MAX < A * B) L = MID;
				else R = MID;
			}
			cout << L - 1 << endl;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))

def binary_search(S, key):
    left = 0
    right = N
    while left < right:
        mid = (left + right) // 2
        if S[mid] < key:
            left = mid + 1
        elif S[mid] > key:
            right = mid
        else:
            return True
    return False
cnt = 0
for t in T:
    if binary_search(S, t):
        cnt += 1
print(cnt)


Measured memory_bytes: 16708
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    int maxx=0;
    int minn=100000;
    int x;
    cin>>x;
    int a[x] ;

    for(int i=0;i<x;i++){

     cin>>a[i];
     maxx = max(maxx,a[i]);
     minn = min(minn,a[i]);

    }
    cout<<maxx-minn<<endl;;
    return 0 ;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
using namespace std;
typedef struct pair<int,int> P;
int A,B,C,D,E,F;
int main() {
	cin>>A>>B>>C>>D>>E>>F;

	int M=A;
	if(B<M)M=B;
	if(C<M)M=C;
	if(D<M)M=D;
	int R=A+B+C+D-M;
	int L=0;
	if(E<F){
		L=F;
	}else{
		L=E;
	}

	cout<<R+L<<endl;
	return 0;
}

Measured memory_bytes: 3072
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: u32, x: u64
    }

    println!("{}", calc(n, x));
}

fn level(n: u32) -> u64 {
    2u64.pow(n+2) - 3
}

fn calc(n: u32, x: u64) -> u64 {
    if n == 0 && x == 1 {1}
    else if x <= 1 {0}
    else if x <= 1 + level(n-1) {calc(n-1, x-1)}
    else if x <= 1 + level(n-1) + 1 {calc(n-1,level(n-1)) + 1}
    else if x <= 1 + level(n-1) + 1 + level(n-1) {
        calc(n-1,level(n-1)) + 1 + calc(n-1, x - 2 - level(n-1))
    } else {calc(n-1,level(n-1))*2 + 1}
}


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

int main() {
  vector<string> c(3);
  for( int i = 0; i < 3; i++ ) cin >> c.at(i);
  
  string ans;
  ans.push_back(c.at(0).at(0));
  ans.push_back(c.at(1).at(1));
  ans.push_back(c.at(2).at(2));
  cout << ans << endl;
      
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
using namespace std;
using ll=long long;
typedef pair<int,int> P;

const int nmax=100001;
P ab[nmax];


int main(){
    ll N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++) cin>>ab[i].second>>ab[i].first;
    sort(ab,ab+M);
    ll bt=ab[0].first;
    ll ct=1;
    for(int i=1;i<M;i++){
        if(bt<=ab[i].second){
            ct++;
            bt=ab[i].first;
        }
    }
    cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int n;cin>>n;
  vi v(n);
  map<int,int> m;
  for(int i=0;i<n;++i){
    cin>>v[i];
    m[v[i]]++;
  }
  sort(all(v));
  vi memo(v[n-1]+1);
  int ans = 0;
  for(int i=0;i<n;i++){
    if(memo[v[i]] == 1) continue;
    memo[v[i]] = 1; 
    if(m[v[i]] == 1)
      ans++;
    for(int j=v[i];j<=v[n-1];j+=v[i]){
      memo[j] = 1;
    }
  }
  cout<<ans<<endl;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


Measured memory_bytes: 17144
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
string S, T;
int A[MAX_N], B[MAX_N];

void solve() {
	cin >> S >> T;
	N = sz(S); M = sz(T);
	rep(i, 0, N) A[i + 1] = A[i] + (S[i] == 'A' ? 1 : 2);
	rep(i, 0, M) B[i + 1] = B[i] + (T[i] == 'A' ? 1 : 2);
	int Q; cin >> Q;
	while(Q--) {
		int a, b, c, d; 
		cin >> a >> b >> c >> d; a--; c--;
		cout << ((A[b] - A[a]) % 3 == (B[d] - B[c]) % 3 ? "YES\n" : "NO\n");
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      char c; cin >> c;
      if(i == j) cout << c;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(a: int, b: int, c: int, d: int):
    l = [a*c, a*d, b*c, b*d]
    print(max(l))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    solve(a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

const double eps = 1e-8;

typedef complex<double> point;
typedef vector<point> polygon;
struct circle
{
	point p;
	double r;
	circle(const point &p, double r) : p(p), r(r) {}
};

int n;
point  p[10];
double r[10];

point unit(const point &v) { return v/abs(v); }

bool containCP(const circle& c, const point& p)
{
	return abs(p - c.p) <= c.r + eps;
}

polygon crosspointCC(const circle &c1, const circle &c2)
{
	point  v = unit(c2.p - c1.p);
	double d = abs(c1.p - c2.p);
	double x = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
	double y = c1.r*c1.r - x*x;

	polygon ret;
	if(y<0) return ret;
	if(y<eps)
	{
		ret.push_back(c1.p + v*point(c1.r, 0));
		return ret;
	}
	y = sqrt(y);
	ret.push_back(c1.p + v*point(x, y));
	ret.push_back(c1.p + v*point(x,-y));
	return ret;
}

bool check(double z)
{
	double tr[10];
	for(int i=0; i<n; i++)
	{
		if(z > r[i]) return false;
		tr[i] = sqrt(r[i]*r[i] - z*z);
	}

	vector<point> cp;

	for(int i=0; i<n; i++)
	{
		cp.push_back( p[i] );
		for(int j=i+1; j<n; j++)
		{
			polygon g = crosspointCC( circle(p[i],tr[i]), circle(p[j],tr[j]) );
			for(int k=0; k<g.size(); k++)
			{
				cp.push_back( g[k] );
			}
		}
	}

	vector<int> cnt(cp.size(), 0);
	for(int i=0; i<n; i++)
	{
		for(int k=0; k<cp.size(); k++)
		{
			if(containCP(circle(p[i],tr[i]), cp[k])) cnt[k]++;
		}
	}

	for(int k=0; k<cp.size(); k++)
	{
		if(cnt[k]==n) return true;
	}	

	return false;
}

int main()
{
	while(cin >> n, n)
	{
		for(int i=0; i<n; i++)
		{
			double x,y;
			cin >> x >> y >> r[i];
			p[i] = point(x,y);
		}

		double l=0, h=300;
		while(h-l > eps)
		{
			double z = (l+h) / 2.0;
			if(check(z)) l=z; else h=z;
		}
		printf("%.7lf\n", (l+h)/2.0);
	}
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
vector<int> v[100005];
int ans=0;
int cnt[100005];
int dfs(int x,int k){
  //  printf("%d %d\n",x,sum);
  //  vector<int> v;
    int Max=0;
    for(auto it:v[x]){
        int y=dfs(it,k);
        Max=max(Max,y);
        if(x==1&&y==0)ans--;
    }
    if(Max+1==k&&x!=1){
        ans++;
     //   printf("%d\n",x);
        return 0;
    }
    return Max+1;
    
}
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int p[100005];
    for(int i = 1;i<=n;i++)
        scanf("%d",&p[i]);
    for(int i = 2;i<=n;i++){
        v[p[i]].pb(i);
    }
    if(p[1]!=1)ans++;
    dfs(1,k);
    //for(int i = 1;i<10;i++)
     //   printf("%d ",cnt[i]);
    printf("%d\n",ans);
}


Measured memory_bytes: 12416
n = int(input())

memo = dict()
def prime_factorize(n):
    a = []
    original_n = n
    while n % 2 == 0:
        a.append(2)
        n //= 2
        if n in memo:
            n_ = a + memo[n]
            memo[original_n] = n_
            return n_
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
            if n in memo:
                n_ = a + memo[n]
                memo[original_n] = n_
                return n_
        else:
            f += 2
    if n != 1:
        a.append(n)
    memo.update({original_n: a})
    return a

answer = 0
memo = dict()

import collections
for i in range(n-1):
    num = i+1
    if num == 1:
        answer += 1
        continue

    primes = prime_factorize(num)
    col = collections.Counter(primes)
    temp = 1
    for k, v in col.items():
        temp *= (v+1)

    answer += temp

print(answer)

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////




int countFreq(string &pat, string &txt)
{
    int M = pat.length();
    int N = txt.length();
    int res = 0;

    /* A loop to slide pat[] one by one */
    for (int i = 0; i <= N - M; i++)
    {
        /* For current index i, check for
           pattern match */
        int j;
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;

        // if pat[0...M-1] = txt[i, i+1, ...i+M-1]
        if (j == M)
        {
           res++;
           j = 0;
        }
    }
    return res;
}

int main()
{
    FASTIO;

    ll n;

    string st;

    cin >> n;


    cin >> st;


    string pat = "ABC";

    cout << countFreq(pat,st) << endl;





    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = [0 for _ in range(10 ** 6 + 1)]
    for a in A:
        counter[a] += 1
    searched = [0 for _ in range(10 ** 6 + 1)]
    ans = 0
    for i in range(1, 10 ** 6 + 1):
        if counter[i] == 0:
            continue
        if searched[i] == 0 and counter[i] == 1:
            ans += 1
        for j in range(1, ((10 ** 6) // i) + 1):
            searched[i * j] = 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 36752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = int(j); i < (int)(n); i++)
#define repll(i, j, n) for (ll i = ll(j); i < (ll)(n); i++)
#define repback(i, n, k) for (int i=int(n); i >= (int)(k); --i)
typedef long long ll;

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
//aからできるだけ引いて正方形を小さくしておく,b<0になるとfalse
ll lcm(ll a, ll b){return a/gcd(a, b)*b;}

ll f(ll x, int c, int d){
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c, d);
    return res;
}

int main() {
    //input
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b, c, d) - f(a-1, c, d);
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int n;
  cin >> n;
  if(n==25){
  cout << "Christmas"<< endl;
  }
  if(n==24){
  cout << "Christmas Eve"<< endl;
  }
  if(n==23){
  cout << "Christmas Eve Eve"<< endl;
  }
  if(n==22){
  cout << "Christmas Eve Eve Eve"<< endl;
  }
}

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

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = a.back();
	rep(i, n - 1) ans = gcd(ans, a[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640