akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e5+5;

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

    ll a, b;
    cin >> a >> b;

    cout << 6 - (a+b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int dsn,i,j;
	int x,y,w,h,n;
	int cx,cy,cc;
	scanf("%d",&dsn);
	for(i = 0; i < dsn; i++){
		cc = 0;
		scanf("%d%d%d%d",&x,&y,&w,&h);
		scanf("%d",&n);
		for(j = 0; j < n; j++){
			scanf("%d%d",&cx,&cy);
			if(
				x <= cx && cx <= x + w &&
				y <= cy && cy <= y + h
			){
				cc++;
			}	
		}
		printf("%d\n",cc);
	}

	return 0;
}

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

#define fi first
#define se second

const int N = 200200;
const int mod = 1e9 + 7;

using namespace std;

string s;
int a[N];
int t[N];

void upd(int x)
{
        while(x < N){
                t[x] += 1;
                x += x & -x;
        }
}

int get(int x)
{
        int res = 0;
        while(x > 0){
                res += t[x];
                x -= x & -x;
        }
        return res;
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> s;
        vector < int > c(26, 0);
        for(int i = 0; i < s.size(); i++){
                c[s[i] - 'a'] += 1;
        }
        int shit = 0;
        for(int i = 0; i < 26; i++) shit += c[i] % 2;
        if(shit > 1){
                cout << -1 << "\n";
                return 0;
        }

        vector < int > A, B;
        int m = -1, n = s.size();
        for(int i = 0; i < n; i++){
                int x = s[i] - 'a';
                c[x] -= 2;
                if(c[x] == -1){
                        m = i;
                } else{
                        if(c[x] >= 0){
                                A.push_back(i);
                        } else{
                                B.push_back(i);
                        }
                }
        }
        int cnt = 1;
        for(int x: A){
                a[x + 1] = (cnt++);
        }
        if(m != -1){
                a[m + 1] = (cnt++);
        }
        for(int x: B){
                a[x + 1] = (cnt++);
        }

        long long res = 0;
        for(int i = 1; i <= n; i++){
                upd(a[i]);
                res += i - get(a[i]);
        }

        for(int i = 0; i < N; i++){
                t[i] = 0;
        }
        vector < vector < int > > v(26);
        for(int i = 0; i < A.size(); i++){
                v[s[A[i]] - 'a'].push_back(i + 1);
        }
        for(int i = 0; i < B.size(); i++){
                int x = s[B[i]] - 'a';
                a[i] = v[x].back();
                v[x].pop_back();

                res += get(a[i]);
                upd(a[i]);
        }

        cout << res << "\n";
}


Measured memory_bytes: 6728
import math
import time
from collections import deque
from collections import defaultdict
from copy import deepcopy
import heapq

mod = 10 ** 9 + 7
t = time.time()



def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret


def conbination(n, r, mod):
    if n < r:
        return 0

    if r == 0 or n == 0:
        return 1

    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    #print(f"conbination {n}, {r} = {ret}")
    return ret

def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod

def main():
    H, W, K = iip()

    chocos = []
    for i in range(H):
        chocos.append(input())


    result = 9999
    for i in range(2**(H-1)):
        hbin = bin(i)[2:].zfill(H-1)

        lines = []
        cur = []
        for i in range(H):
            cur.append(i)
            if i <= H-2 and hbin[i] == "1":
                lines.append(cur)
                cur = []
        lines.append(cur)
        cnum = cracknum(lines, W, K, chocos) + hbin.count("1")
        result = min(result, cnum)

    print(result)

def cracknum(lines, W, K, chocos):
    volumes = [0 for i in lines]
    result = 0
    for x in range(W):
        crack = False
        for line, y_list in enumerate(lines):
            for y in y_list:
                if chocos[y][x] == "1":
                    volumes[line] += 1
                    #print(y, x)
                    #print(volumes)
                    if volumes[line] > K:
                        crack = True
                        #print("crack")
                        break
            if crack:
                break

        if crack:
            result += 1
            volumes = [0 for i in lines]
            for line, y_list in enumerate(lines):
                for y in y_list:
                    if chocos[y][x] == "1":
                        volumes[line] += 1
                        if volumes[line] > K:
                            return 9999
    #print(result)
    return result





main()

Measured memory_bytes: 45784
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, y) = get!(usize, usize);
    let mut n = x;
    let mut c = 0;
    while n <= y {
        n *= 2;
        c += 1;
    }
    println!("{}", c);
}

Measured memory_bytes: 2124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(isPrime(Integer.parseInt(br.readLine())))cnt++;
        }
        System.out.println(cnt);
    }
    public static boolean isPrime(int x){
        if(x == 2)return true; // 2
        else if(x % 2 == 0)return false;
        else if(x <= 7)return true; // 3,5,7
        else if(x % 3 == 0)return false;

        for(int i=5; i*i<=x; i+=6){
            if(x % i == 0)return false;
            if(x % (i + 2) == 0)return false;
        }
        return true;
    }
}

Measured memory_bytes: 22676
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll h, w, d; cin >> h >> w >> d;
    vvi a(h+1, vi(w+1, 0));
    vector<pair<ll, ll>> idx(h*w+1);

    // 1-based-indexで入力処理
    repf(i, h){
        repf(j, w){
            cin >> a[i][j];
            idx[a[i][j]] = make_pair(i, j);
        }
    }

    // d個の巡回グループを作成
    vvi cycle(d+1, vi(0));
    for(ll i=1; i<=d; i++){
        // 最小値から順に消費魔力の累積和を計算
        ll sum = 0;
        cycle[i].push_back(sum);
        ll preIdx = i;
        ll nextIdx = i+d;
        // 制約より、h*wを超えることはない
        while(nextIdx<=h*w){
            // 消費魔力の計算
            sum += abs(idx[nextIdx].first-idx[preIdx].first)+abs(idx[nextIdx].second-idx[preIdx].second);
            // 累積和を追加
            cycle[i].push_back(sum);
            // 添字の更新
            preIdx = nextIdx;
            nextIdx += d;
        }
    }
    
    // q個の実技試験
    ll q; cin >> q;
    rep(i, q){
        ll l, r; cin >> l >> r;
        ll index = (l%d);
        if(index == 0) index += d;
        ll cycSrt = ((l-index)/d);
        ll cycEnd = ((r-index)/d);
        cout << cycle[index][cycEnd] - cycle[index][cycSrt] << endl;
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;
constexpr ll mod = 1e9 + 7;
const ld eps = 1e-9, pi = acos(-1.0);

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ld a, b, x;
  cin >> a >> b >> x;
  x /= a;
  ld lb = 90, ub = 0;
  while (lb - ub > eps) {
    ld mid = (lb + ub) / 2;
    ld sh = mid / 180 * pi;
    bool f = true;
    if (tan(sh) > a / b) {
      if (a * b - 0.5 * a * a / tan(sh) + eps < x) f = false;
    } else {
      if (0.5 * b * b * tan(sh) + eps < x) f = false;
    }
    if (f)
      lb = mid;
    else
      ub = mid;
  }
  cout << fixed << setprecision(10) << 90 - lb << endl;
}


Measured memory_bytes: 512
from heapq import heapify, heappop, heappush


K, T, *A = map(int, open(0).read().split())
pq = [(-a, i) for i, a in enumerate(A)]
heapify(pq)

ans = 0
prev = -1
for _ in range(K):
    v, k = heappop(pq)
    if v == 0:
        heappush(pq, (v, k))
        ans += 1
    elif k != prev:
        prev = k
        heappush(pq, (v + 1, k))
    elif len(pq) > 1 and pq[0][0] < 0:
        v_nx, k_nx = heappop(pq)
        prev = k_nx
        heappush(pq, (v_nx + 1, k_nx))
        heappush(pq, (v, k))
    else:
        ans += 1
        heappush(pq, (v + 1, k))
print(ans)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

struct union_find {
	vector<int> uf;

	union_find(int n):uf(n, -1) {}

	int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if(x == y) return;

		if(uf[x] > uf[y]) {
			swap(x, y);
		}

		uf[x] += uf[y];
		uf[y] = x;
	}

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

constexpr int MAX_V = 1000;
int memo[MAX_V + 1][MAX_V + 1][2];

bool dfs(int odd, int even, bool can_pass) {
	dump(odd, even, can_pass); 
	if(odd + even == 1) return true;

	int &res = memo[odd][even][can_pass];
	if(res != -1) return res;

	if((can_pass && !dfs(odd, even, false)) || (odd >= 2 && !dfs(odd - 2, even + 1, can_pass))
	   || ((even >= 2 || (even >= 1 && odd >= 1)) && !dfs(odd, even - 1, !can_pass))) {
		return res = true;
	}
	else {
		res = false;
	}

	return res;
}

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

	int n;
	cin >> n;

	vector<string> a(n);
	for(auto &e : a) cin >> e;

	union_find uf(n);
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			if(a[i][j] == 'Y') {
				uf.unite(i, j);
			}
		}
	}

	int odd = 0;
	int even = 0;
	int cnt = 0;

	int tmp = 0;
	for(int i = 0; i < n; ++i) {
		if(uf.uf[i] < 0) {
			++(-uf.uf[i] & 1 ? odd : even);
			++tmp;
		}
		
		for(int j = i + 1; j < n; ++j) {
			if(a[i][j] == 'N' && uf.same(i, j)) {
				++cnt;
			}
		}
	}

	dump(tmp);
	dump(odd, even, cnt);
	memset(memo, -1, sizeof(memo));
	cout << (dfs(odd, even, cnt & 1) ? "Taro" : "Hanako") << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 10100
object Main extends App {
  import scala.io.StdIn._
  val s = readLine()
  val res = s.zipWithIndex.map { x =>
    if(x._2 % 2 == 0) {
      "RUD".contains(x._1)
    } else {
      "LUD".contains(x._1)
    }
  }
  println( if (res.contains(false)) "No" else "Yes")
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  f64 t, x;
  cin >> t >> x;
  cout << t / x << endl;
  return 0;
}


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

int n,m,ai;
ll ans=0;
priority_queue<int> pq;
int main(){
    cin>>n>>m;
    rep(i,n){
        cin>>ai;
        pq.push(ai);
    }
    rep(i,m)if(!pq.empty()){
        ai=pq.top();pq.pop();
        ai/=2;
        if(ai!=0) pq.push(ai);
    }
    while(!pq.empty()){
        ai=pq.top();pq.pop();
        ans+=ai;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N, M;
  cin>>N>>M;
  map<int, int> amap;
  bool aru[N];
  for(int i=0;i<N;++i) {
    amap[i] = 1;
    aru[i] = false;
  }
  aru[0] = true;
  int x, y;
  for(int i=0;i<M;++i) {
    cin>>x>>y;
    x--;
    y--;
    if(aru[x]) aru[y] = true; 
    if(amap[x]==1) {
      aru[x] = false;
    }
    amap[x]--;
    amap[y]++;
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(aru[i]) ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 8268
import sys

s = input().rstrip()
n = len(s)

r_s = ''
for c in reversed(s):
    r_s = r_s + c

if s != r_s:
    print('No')
    sys.exit()

top = ''
for i in range(int((n - 1)/2)):
    top = top + s[i]

r_top = ''
for c in reversed(top):
    r_top = r_top + c

if top != r_top:
    print('No')
    sys.exit()

last = ''
for i in range(int((n + 3)/2) - 1, n):
    last = last + s[i]

r_last = ''
for c in reversed(last):
    r_last = r_last + c

if r_last != last:
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int h,a;
    cin >> h >> a;
    int cnt =0;
    while(h>0){
        h -= a;
        cnt ++ ;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n; 
    int A[n+1];
    REP(i,n) scanf("%lld",&A[i]);
    sort(A,A+n);
    A[n] = -1;

    int res = 0;
    int Sum = 0;
    REP(i,n) Sum += A[i];
    REPR(i,n-1){
        if( Sum * 2 >= A[i +1] ){
            res ++;
        }
        else break;
        Sum -= A[i];
    }

    cout << res << endl;

}


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

int main(){
    int n;
    cin >> n;
    vector<int> w(n+4,0);
    int s1=0,s2=0;
    for(int i=0;i<n;i++){
        cin >> w.at(i);
        s1 += w.at(i);
    }
    int s=10000000;
    //sort(w.begin(),w.end());
    for(int i=0;i<n;i++){
        s2 += w.at(i);
        s1 -= w.at(i);
        s = min(s,abs(s1-s2));
    }
    cout << s << endl;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> a(n), sum(n-k+1);
    rep(i,n) cin >> a[i];
    ll tmp = 1;
    rep(i,k) tmp *= a[i];
    sum[0] = tmp;

    // for(int i = k; i < n; i++)
    // {
    //     ll t = sum[i-k];
    //     t = t * a[i] / a[i-k];
    //     sum[i-k+1] = t;
    // }

    rep(i,n-k)
    {
        if(a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
       // cout << sum[i+1] << ">" <<  sum[i] << " ";
        // if(sum[i+1] > sum[i]) cout << "Yes" << endl;
        // else cout << "No" << endl;
    }
}


Measured memory_bytes: 6196
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

long long euclidean_gcd(long long a, long long b)
{
	if (a < b)
		return euclidean_gcd(b, a);
	long long r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n, 0);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int r = 0;
	int last = -1;

	for (int i = 0, m = 1; i < n; i++)
	{
		if (a[i] == m)
		{
			m++;
			last = i;
		}
		else
			r++;
	}

	if (last == -1)
		r = -1;

	printf("%d", r);

	return 0;
}

Measured memory_bytes: 1024
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    T = readline().strip()

    for i in range(len(S)):
        if S[i:] + S[:i] == T:
            print('Yes')
            return

    print('No')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8976
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	char x;
	cin >> x;
	if (x >= 97) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int i,j,k,n,m;
void read(int &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
void read(ll &x){
	char c;x=0;do c=getchar();while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);
}
string s;
int S;
int ans[100010],y;
int main() {
	int tr=1;
	cin>>s;
	n=s.size();
	s[n]='R';
	for(i=1;i<=n+1;i++){
		if(tr==1){
			if(s[i-1]=='L')
				ans[i-1]+=(S+1)/2,ans[i]+=S/2,tr=0,S=1,y=i;
			else S++;
		}else{
			if(s[i-1]=='R')
				ans[y]+=(S+1)/2,ans[y-1]+=S/2,tr=1,S=1;
			else S++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<ans[i];
		if(i!=n)cout<<' ';
		else cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	bool isHamming[1000010] = {};
	isHamming[1] = true;
	rep(i, 1, 1000010 / 2) {
		if (isHamming[i])isHamming[i * 2] = true;
	}
	rep(i, 1, 1000010 / 3) {
		if (isHamming[i])isHamming[i * 3] = true;
	}
	rep(i, 1, 1000010 / 5) {
		if (isHamming[i])isHamming[i * 5] = true;
	}
	for (int m, n; cin >> m >> n&&m;) {
		int cnt = 0;
		rep(i, m, n + 1)if (isHamming[i])cnt++;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 4032
n,k,q = map(int,input().split())
plus = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    a -= 1
    plus[a] += 1
for i in range(n):
    if k-(q-plus[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4604
from collections import Counter

N = int(input())
numbers = [int(i) for i in input().split()]
Q = int(input())

counted = Counter(numbers)
sum_n = sum(numbers)

for _ in range(Q):
    b, c = [int(i) for i in input().split()]
    sum_n = sum_n - ((b-c) * counted[b])
    counted[c] += counted[b]
    counted[b] -= counted[b]
    print(sum_n)


Measured memory_bytes: 23996
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int sz = 0;
    for (int i = 0; i + 1 < s.size(); i++) {
        if (s[i] != s[i + 1]) sz++;
    }
    cout << sz;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MAX 5000
#define MOD 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	long long x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	long long tozero = x/d;
	if(tozero>=k)
		cout<<x-d*k<<endl;
	else
	{
		k -= tozero;
		if(k&1)
			cout<<abs(x-d*++tozero)<<endl;
		else
			cout<<x-d*tozero<<endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9

int main(){
    ll n;
    cin>>n;
    int a[n+1];
    ll sum = 0;
    for(ll i=1;i<n+1;i++){
        cin>>a[i];
        sum += a[i];
     }
    int tt[n+1];
    ll cnt=0;
    ll aa = n/2+1;

    for(ll i=aa;i<=n;i++){
        tt[i] = a[i];
        if(tt[i]==1)cnt++;
    }


    for(ll i=aa-1;i>0;i--){
        int tmp=a[i];
        for(ll j=i;j<=n;j+=i){
            if(j==i){
                continue;
            }
            else{
                tmp^=tt[j];
               // cout<<"tt i j:"<<tt[j]<<" "<<i<<" "<<j<<endl;
            }
        }
        tt[i]=tmp;
        cnt+=tmp;
    }
    int anst[n+1];
    memset(anst,0,sizeof(anst));
    int x=1;
    for(ll i=1;i<=n;i++){
        if(tt[i]==1){
            anst[x]=i;x++;
        }
    }
    cout<<cnt<<endl;
    for(ll i=1;i<=cnt;i++){
        if(i==cnt)cout<<anst[i]<<endl;
        else cout<<anst[i]<<" ";
    }
}

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

const int MAX_N = int(2e5) + 10;
const int INF = 0x3f3f3f3f;

int dp[MAX_N][2];
char s[MAX_N];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 0; i <= n; ++i) {
		dp[i][0] = dp[i][1] = -INF;
	}
	dp[0][0] = 0;
	dp[1][0] = 1;
	for (int i = 2; i <= n; ++i) {
		dp[i][0] = std::max(dp[i][0], dp[i - 1][1] + 1);
		if (s[i] != s[i - 1])
			dp[i][0] = std::max(dp[i][0], dp[i - 1][0] + 1);
		dp[i][1] = std::max(dp[i][1], dp[i - 2][0] + 1);
		if (i >= 4 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3]))
			dp[i][1] = std::max(dp[i][1], dp[i - 2][1] + 1);
	}
	printf("%d\n", std::max(dp[n][0], dp[n][1]));
}

Measured memory_bytes: 5472
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long>A(N), count(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		count[A[i] - 1]++;
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += count[i] * (count[i] - 1) / 2;
	}
	for (int i = 0; i < N; i++) {
		long long tmp = ans - count[A[i] - 1] * (count[A[i] - 1] - 1) / 2;
		tmp += (count[A[i] - 1] - 1)*(count[A[i] - 1] - 2) / 2;
		cout << tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


void insertionSort(int A[], int N)
{
	int v, j;
	
	for (int i=1; i<N; i++)
	{
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A, N);
	}
}


int main()
{
	int N, A[100];
	
	cin >> N;
	REP(N) cin >> A[i];
	
	trace(A, N);
	insertionSort(A, N);
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int ans = 0;
    repall (c, s)
        if (c == '+')
            ans++;
        else
            ans--;
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_SIZE 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100000

vector<int> G[SIZE];
int N;
bool visited[SIZE];
int visited_order[SIZE],parent[SIZE],lowest[SIZE],number;


void dfs(int current_node,int pre_node){
	visited_order[current_node] = lowest[current_node] = number;
	number++;

	visited[current_node] = true;

	int next;

	for(int i = 0; i < G[current_node].size(); i++){
		next = G[current_node][i];
		if(!visited[next]){
			parent[next] = current_node;
			dfs(next,current_node);
			lowest[current_node] = min(lowest[current_node],lowest[next]);
		}else if(visited[next] == true && next != pre_node){
			lowest[current_node] = min(lowest[current_node],visited_order[next]);
		}
	}
}

void art_points(){


	for(int i = 0; i < N; i++)visited[i] = false;

	number = 1;
	dfs(0,-1);

	int tmp_parent,root_num = 0;

	vector<int> V;

	for(int i = 1; i < N; i++){
		tmp_parent = parent[i];
		if(tmp_parent == 0){
			root_num++;
		}else if(visited_order[tmp_parent] <= lowest[i]){
			V.push_back(tmp_parent);
		}
	}
	if(root_num >= 2){
		V.push_back(0);
	}
	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(int i = 0; i < V.size(); i++){
		printf("%d\n",V[i]);
	}
}


int main(){
	int E;

	scanf("%d %d",&N,&E);

	int from,to;

	for(int i = 0; i < E; i++){
		scanf("%d %d",&from,&to);
		G[from].push_back(to);
		G[to].push_back(from);
	}

	art_points();

	return 0;
}



Measured memory_bytes: 6840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i,m) {
        int k;
        cin >> k;
        rep(j,k) {
            int a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];
    int ans = 0;
    rep(is,1<<n) {
        bool ok = true;
        rep(i,m) {
            int cnt = 0;
            for (int x : s[i]) {
                if (is>>x&1) cnt++;
            }
            cnt %= 2;
            if (cnt != p[i]) ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){
  int X, A, B; cin >> X >> A >> B;
  if(abs(X-A) > abs(X-B)) cout << 'B' << endl;
  else cout << 'A' << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var q = ToInt32(ReadLine());
        var ar2 = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(ar);
        var res = 0;
        for(var i = 0; i < q; i++)
        {
            var left = 0;
            var right = num-1;
            while (right > left)
            {
                var mid = (right + left) / 2;
                if (ar[mid] == ar2[i]) { left = mid; break; }
                else if (ar[mid] > ar2[i]) right = mid;
                else left = mid + 1;
            }
            if (ar[left] == ar2[i]) res++;
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 27508
n = int(input())
S = list(input())
#print(S[0:3])
if n%2 != 0:
  print("No")
elif n%2 == 0:
  a = 0
  for i in range(int(n/2)):
    if S[i] == S[i+int((n/2))]:
      a += 1
  if a == n/2:
    print("Yes")
  else:
    print("No")

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

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

if ( a*b % 2 == 0){
     cout << "Even" << endl;
}
else {
     cout << "Odd" << endl;
}  


// ここにプログラムを追記
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}


int main(){
	ll n, c;
	cin >> n >> c;
	vector<ll> lx(n+1), lv(n+1), rx(n+1), rv(n+1);
	lx[0] = 0, lv[0] = 0, rx[0] = 0, rv[0] = 0;
	for (int i = 1; i <= n; i++){
		cin >> lx[i] >> lv[i];
		rx[n+1-i] = c - lx[i];
		rv[n+1-i] = lv[i];
	}
	vector<ll> slv(n+1), srv(n+1);
	slv[0] = 0, srv[0] = 0;

	for (int i = 1; i <= n; i++){
		slv[i] = slv[i-1] + lv[i];
		srv[i] = srv[i-1] + rv[i];		
	}

	vector<ll> lrmax(n+1), rlmax(n+1);
	lrmax[0] = 0, rlmax[0] = 0;
	ll lrtmp = 0, rltmp = 0;
	for (int i = 1; i <= n; i++){
		if (lrtmp < slv[i] - 2*lx[i]){
			lrtmp = slv[i] - 2*lx[i];
		}
		lrmax[i] = lrtmp;
		if (rltmp < srv[i] - 2*rx[i]){
			rltmp = srv[i] - 2*rx[i];
		}
		rlmax[i] = rltmp;
	}

	ll ans = 0;
	for (int i = 0; i <= n; i++){
		int j = n - i;
		ans = llmax(ans, slv[i] + rlmax[j] - lx[i]);
		ans = llmax(ans, srv[i] + lrmax[j] - rx[i]);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9580
#小さいCから変更
n = int(input())
c = list(map(int, input().split( )))

c.sort()
#print(c)
#i　bit目が違うようなs,tは 2**(2*n-2)*2通り
#一致bitと不同bitを反転させた対について考える
sm = 0
for i in range(n):
    sm += ((n-i)+1)*c[i]
    #print((2*(n-i)-1)*c[i])

mod = 10**9+7
sm *= pow(2,2*n-2,mod)
sm%=mod
print(sm)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d);
  cout << d[n/2] - d[n/2-1] << endl;
}



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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

// struct edge { int to, cost; };
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

struct UnionFind {
  int N;
  vector<int> par,ranc;

  UnionFind(int N) : N(N),par(N),ranc(N) { REP(i,N) par[i]=i,ranc[i]=0; }

  int root(int s) {
    if (par[s]==s) return s;
    else return root(par[s]);
  }

  bool same(int x, int y) { return root(x)==root(y); }

  bool connected() {
    int base = root(0);
    REP(i,N) if (root(i)!=base) return false;
    return true;
  }

  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x==y) return;
    if (ranc[x]>ranc[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (ranc[x]==ranc[y]) ranc[y]++;
    }
  }
};

int main() {
  int N;cin>>N;
  vector<tuple<int,int,int>> xtowns;
  vector<tuple<int,int,int>> ytowns;
  REP(i,N) {
    int x,y;cin>>x>>y;
    xtowns.push_back(make_tuple(x,y,i));
    ytowns.push_back(make_tuple(y,x,i));
  }

  struct edge { int cost,from,to; };
  auto comp = [](edge a, edge b) { return a.cost > b.cost; };
  priority_queue<edge, vector<edge>, decltype(comp)> pq(comp);
  // xの順に並び替えた上で、edgeを追加
  sort(ALL(xtowns));
  FOR(i,1,N) {
    int x1,y1,idx1;
    tie(x1,y1,idx1) = xtowns[i-1];
    int x2,y2,idx2;
    tie(x2,y2,idx2) = xtowns[i];
    edge e = {abs(x2-x1),idx1,idx2};
    pq.push(e);
  }
  // yの順に並び替えた上で、edgeを追加
  sort(ALL(ytowns));
  FOR(i,1,N) {
    int x1,y1,idx1;
    tie(y1,x1,idx1) = ytowns[i-1];
    int x2,y2,idx2;
    tie(y2,x2,idx2) = ytowns[i];
    pq.push({abs(y2-y1),idx1,idx2});
  }

  // 全てのrootが同じになればいい
  // 辿った道が全て埋まるまで追加
  UnionFind uf(N);
  int ans = 0;
  while (true) {
    edge e = pq.top();pq.pop();
    if (uf.root(e.from) == uf.root(e.to)) continue;
    uf.merge(e.from,e.to);
    ans += e.cost;
    if (uf.connected()) break;
  }
  OUT(ans);

  return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}



Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), d  = sc.nextInt();
        int res = 0;
        int[][] X = new int[n][d];
        for(int i = 0; i < n; i++) Arrays.setAll(X[i], j -> Integer.parseInt(sc.next()));
        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                int sum = 0;
                for(int k = 0; k < d; k++) sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                if(Math.sqrt(sum) == (int)Math.sqrt(sum)) res++;
            }
        }
        System.out.println(res);
    }
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,abs(n%k-k))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){
    return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}
/*aのb進数時の桁数*/
ll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}    

int main(void){
    ll n,k;
    scanf("%lld%lld",&n,&k);
    // ll [n];
    // for(i=0;i<n;i++){
    //     scanf("%lld",&[i]);
    // }
    
    printf("%lld\n",digits(n,k));
    return 0;
}


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

using namespace std;

int main() {
    char c;
    cin>>c;
    if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	unsigned long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           998244353
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) 
    { 
        if (y & 1) 
        res = res*x; 
        y = y>>1; 
        x = x*x;  
    } 
    return res; 
}

signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,x,k,i,j,c=0,ans=0;
		cin>>n>>x>>k;
		if(n==1)
		{
			cout<<x<<u;
			C
		}
		map<ll,ll>m;
		ans+=x;
		ll last=x;
		vi v(100001);
		m[x]=c;
		v[c++]=ans;
		ll now;
		ll flag=0;
		while(c<n)
		{
			now=(last*last)%k;
			if(m[now])
			{
			    flag=1;
			    break;
			}
			else
			m[now]=c;
			last=now;
			ans+=now;
			v[c++]=ans;
		}
		ll rem=n-c;
		if(flag==1 && rem>0)
		{
    		ll between=c-m[now];
    		ll r=rem/between;
    		ans+=(r*(v[c-1]-v[m[now]-1]));
    		ll temp=rem%between;
    		ll ind=m[now]-1;
    		ans+=(v[ind+temp]-v[ind]);
		}
		cout<<ans<<u;
		
	}
	return 0;
} 

Measured memory_bytes: 7144
#include <stdio.h>
#include <math.h>


int main(void){

int h1,h2,m1,m2,k;

scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);

int before,after,time;


before = h1*60+m1;
after = h2*60+m2;

time = after-before-k;

printf("%d\n",time);

return 0;

}


Measured memory_bytes: 1732
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

    ans = INF
    for k in range(100001):
        yen = 2 * c * k + max(0, x-k) * a + max(0, y-k) * b
        ans = min(ans, yen)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL n,lm=1LL*mod*mod;
    cin>>n;
    vl a(n+1);
    vl b(n+1,1);
    FOR(i,0,n+1){
        cin>>a[i];
    }
    if(a[0]>0){
        b[0]=0;
    }
    if(a[0]>1||a[1]>2||a[2]>4){
        cout<<-1<<endl;
        return 0;
    }
    FOR(i,1,n+1){
        b[i]=b[i-1]*2;
        b[i]-=a[i];
        if(b[i]<0){
            cout<<-1<<endl;
            return 0;
        }
        if(b[i]>=lm)b[i]=lm;
        //cerr<<b[i]<<endl;
    }
    LL ans=0,nd=0;
    FORD(i,n+1,0){
        //cerr<<i<<" a[i]:"<<a[i]<<" b[i]:"<<b[i]<<" nd:"<<nd<<" ans:"<<ans<<endl;
        if(nd<=b[i]){
            nd+=a[i];
        }else if((nd+1)/2>b[i]){
            cout<<-1<<endl;
            return 0;
        }else{
            nd=b[i]+a[i];
        }
        ans+=nd;
    }
    cout<<ans<<endl;


    
}


Measured memory_bytes: 4840
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  (function(array) {
    console.log(array.sort(function(a,b){
        return a - b;
    }).join(' '));
  }(inputs.split('\n')[0].split(' ').map(Number))); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644