akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    ll p=1000000007;
    vector <ll> A(n+1,0);
    for (int i=3;i<=n;i++) {
		ll x=1;
		for (int j=0;j<=i-3;j++) {x+=A[j];}
		x=x%p;
		A[i]=x;
		//cout<<i<<" "<<A[i]<<endl;
		}
	cout<<A[n]<<endl;
    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

signed main(){
    int N;
    cin>>N;
    ll a[60];
    for(int i=1;i<=N;i++) cin>>a[i];

    bool flag=true;
    ll count=0;
    while(flag){
        flag=false;
        for(int i=1;i<=N;i++){
            if(a[i]<N) continue;
            flag=true;
            ll t=a[i]/N;
            count+=t;
            a[i]-=N*t;
            for(int j=1;j<=N;j++){
                if(i==j) continue;
                a[j]+=t;
            }
        }
    }
    cout<<count<<endl;
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        
        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadIntArray(3);
            var r = Min(a[1] / a[0], a[2]);

            Console.WriteLine(r);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[105];
int main() {
	int N, K, i, j;
	scanf("%d %d", &N, &K);
	scanf("%s", in + 1);

	for (i = 1; i <= N; i++) {
		if (i == K) printf("%c", in[i] - 'A' + 'a');
		else printf("%c", in[i]);
	}
	return !printf("\n");
}

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

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

if b-a == 0:
    print(a)
    exit()
if b-a == 1:
    print(a ^ b)
    exit()

list_ = []
ans = 0
if a % 2 != 0:
    list_.append(a)
    a += 1

if b % 2 == 0:
    list_.append(b)
    b -= 1

num = ((b+1)-a)//2
if num % 2 == 0:
    ans = 0
else:
    ans = 1


for i in list_:
    ans = ans ^ i
print(ans)


Measured memory_bytes: 3064
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x) std::sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

struct vertex
{
	int next;
	int cost;
	bool visit = false;
};

itn main() {
	std::ios::sync_with_stdio(false);

	string a, b, c;

	cin >> a >> b >> c;

	cout << a[0] << b[1] << c[2];

	return 0;
}


Measured memory_bytes: 256
// clang-format off
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using G = vector<vector<ll>>;
#define G(i, j) i, vector<ll>(j)
#define Gv(i, j, k) i, vector<ll>(j, k)
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(std::vector<long long> x) {
  rep1(i, 5) {
    if (x[i - 1] == 0) {
      END(i);
    }
  }
}

// clang-format off
int main() {
  std::vector<long long> x(5);
  for(int i = 0 ; i < 5 ; i++){
    scanf("%lld",&x[i]);
  }
  solve(std::move(x));
  return 0;
}


Measured memory_bytes: 3672
n=int(input())
a=list(map(int,input().split()))
if n%2==0: b=[n-2*i for i in range(n//2)]+[1+2*i for i in range(n//2)]
else: b=[n-2*i for i in range(n//2+1)]+[2*i for i in range(1,n//2+1)]
for i in b:
    print(a[i-1],end=' ')

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  rep(i, a) cout << b; cout << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const int MAX_N = 100;
int W[MAX_N];
int s[MAX_N];

int main(void){
    int N;
    cin >> N;

    int answer = MAX_N * 100;

    rep(i, N){
        cin >> W[i];        
    }

    s[0] = W[0];

    For(i, 1, N){
        s[i] = s[i - 1] + W[i];
    }

    rep(i, N - 1){
        answer = min(answer, abs(s[N - 1] - 2 * s[i]));
    }
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


while True:
    N,M = inpl()
    if N == 0:
        break
    hh = [inp() for _ in range(N)]
    ww = [inp() for _ in range(M)]
    cnts = defaultdict(int)


    rhh = hh[:]
    for i in range(1,N):
        rhh[i] += rhh[i-1]
    rhh.append(0)

    for i in range(N+1):
        for j in range(i+1,N+1):
            tmp = rhh[j-1] - rhh[i-1]
            cnts[tmp] += 1

    rww = ww[:]
    for i in range(1,M):
        rww[i] += rww[i-1]
    rww.append(0)

    ans = 0
    for i in range(M+1):
        for j in range(i+1,M+1):
            tmp = rww[j-1] - rww[i-1]
            ans += cnts[tmp]

    print(ans)



Measured memory_bytes: 60100
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a,b,c,x,y=n1()

ans=[]
ans.append(a*x+b*y)
if x>y:
    ans.append(a*(x-y)+2*c*y)
else:
    ans.append(2*c*x+b*(y-x))
ans.append(2*c*max(x,y))
print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1e17;
#define all(v) v.begin(), v.end()

int main(){
  ll N,ans=0;
  cin >> N;
  map<ll,ll> A;
  rep(i,N){
    ll a;
    cin >> a;
    A[a-1]=i;
  }
  set<ll> B;
  rep(i,N){
    if(i==0){
      ans+=(A.at(i)+1)*(N-A.at(i))*(i+1);
      B.insert(A.at(i));
    }else{
      auto a=B.lower_bound(A.at(i));
      if(a==B.begin()){
        ans+=(A.at(i)+1)*(*a-A.at(i))*(i+1);
        B.insert(A.at(i));
      }else if(a==B.end()){
        a--;
        ans+=(A.at(i)-*a)*(N-A.at(i))*(i+1);
        B.insert(A.at(i));
      }else{
        auto b=a;
        b--;
        ans+=(A.at(i)-*b)*(*a-A.at(i))*(i+1);
        B.insert(A.at(i));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 25452
class Die
  attr_reader :top, :bottom, :front, :back, :left, :right
  def initialize(list)
    @top, @front, @right, @left, @back, @bottom = list
    roll(:clockwise) if @left == "Red" || @right == "Red"
    until @top == "Red"
      roll(:front)
    end
    front = (@bottom != "Cyan") ? "Cyan" : "Green"
    4.times do
      break if @front == front
      roll(:clockwise)
    end
  end
  def roll(direction)
    case direction
      when :front
        @front, @top, @back, @bottom = [@front, @top, @back, @bottom].rotate(1)
      when :clockwise
        @front, @right, @back, @left = [@front, @right, @back, @left].rotate(1)
    end
  end
  def eql?(other)
    [@top, @bottom, @front, @back, @left, @right] == [other.top, other.bottom, other.front, other.back, other.left, other.right]
  end
  def hash
    [@top, @bottom, @front, @back, @left, @right].hash
  end
end

until (n = gets.to_i).zero?
  dice = n.times.map{Die.new(gets.split)}
  p n - dice.uniq.size
end

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

public class Main {

    static boolean[][] adj;
    static int[] p;
    static int switches, bulbs, res = 0;

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        switches = Integer.parseInt(st.nextToken());
        bulbs = Integer.parseInt(st.nextToken());

        adj = new boolean[11][11];
        p = new int[11];

        for (int i = 1; i <= bulbs; i++) {
            st = new StringTokenizer(in.readLine());
            int k = Integer.parseInt(st.nextToken());

            for (int j = 0; j < k; j++) {
                int s = Integer.parseInt(st.nextToken());
                adj[s][i] = true;
            }
        }

        st = new StringTokenizer(in.readLine());
        for (int i = 1; i <= bulbs; i++) {
            p[i] = Integer.parseInt(st.nextToken());
        }

        recur(0, new int[switches]);

        System.out.println(res);
    }

    static void recur(int depth, int[] arr) {
        if (depth == switches) {
            int[] add = new int[bulbs+1];
            for (int i = 0; i < switches; i++) {
                if (arr[i] == 1) {
                    for (int j = 1; j <= bulbs; j++) {
                        if (adj[i+1][j]) {
                            add[j]++;
                        }
                    }
                }
            }

            boolean ok = true;
            for (int i = 1; i <= bulbs; i++) {
                if (p[i]%2 != add[i]%2) {
                    ok = false;
                }
            }

            if (ok) {
                res++;
            }
            return;
        }
        recur(depth+1, Arrays.copyOf(arr, switches));
        int[] copy = Arrays.copyOf(arr, switches);
        copy[depth] = 1;
        recur(depth+1, copy);
    }
}
/*
2 3
2 1 2
1 1
1 2
0 0 1


 */

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll memo[200];

ll fib(ll n) {
  if (n == 0 || n == 1) return 1;
  if (memo[n]!=0) return memo[n];
  return memo[n] = (fib(n-1)+fib(n-2))%mod;
}

int main() {
  for (ll i = 0; i < 200; i++) {
    memo[i] = 0;
  }
  ll H, W, K; cin >> H >> W >> K; K--;
  if (W == 1) {cout << 1 << endl; return 0;}
  
  ll dp[W][101];
  for (ll i = 0; i < W; i++) {
    dp[i][0] = 0;
  }
  dp[K][0] = 1;
  for (ll j = 1; j <= 100; j++) {
    dp[0][j] = (dp[0][j-1]*fib(W-1)%mod + dp[1][j-1]*fib(W-2)%mod) %mod;
    dp[W-1][j] = (dp[W-1][j-1]*fib(W-1)%mod + dp[W-2][j-1]*fib(W-2)%mod) %mod;
    for (ll i = 1; i < W-1; i++) {
      dp[i][j] = (dp[i][j-1]*fib(i)%mod)*fib(W-i-1)%mod;
      dp[i][j] = (dp[i][j]+(dp[i+1][j-1]*fib(i)%mod)*fib(W-i-2)%mod)%mod;
      dp[i][j] = (dp[i][j]+(dp[i-1][j-1]*fib(i-1)%mod)*fib(W-i-1)%mod)%mod;
    }
  }
  cout << dp[0][H] << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
e = s.count("E")
w = n - e
ans = 10**9
if s[0] == "W":
    cnt = e
else:
    cnt = e-1
num = cnt
#print("Num =",num)
for i in range(n-1):
    if s[i] == s[i+1] and s[i] == "E":
        cnt -= 1
    elif s[i] == s[i+1]:
        cnt += 1
    #print(i,cnt)
    ans = min(ans,cnt,num)
    ans = max(ans,0)
print(max(ans,0))

Measured memory_bytes: 68268
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define ran 101111

int k;
int d[ran];
int q[ran*50], l, r;
bool in_q[ran];

void pb(int rem, int val) {
	if (!in_q[rem]) {
		q[r++] = rem;
		in_q[rem] = true;
	}
	d[rem]=val;
}

int main() {
	scanf("%d", &k);
	
	memset(d, -1, sizeof d);
	
	l=r=0;
	for(int i=1;i<min(k, 10);i++) {
		pb(i, i);
	}
	while(l<r) {
		int rem = q[l++], val = d[rem];
		in_q[rem] = false;
		for(int i=0;i<10;i++) {
			int nxt_rem = (rem*10+i)%k;
			int nxt_val = val + i;
			if (d[nxt_rem] == -1 || d[nxt_rem] > nxt_val) pb(nxt_rem, nxt_val);
		}
	}
	
	printf("%d\n", d[0]);
	
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define N 110
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)  for(int i = n - 1; i >= 0; --i)
#define forr1(i, n) for(int i = n; i >= 1; --i)
#define form(l, r, i)   for(int i = l; i <= r; ++i)
#define forv(r, l, i)   for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
  
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modw = 1e9 + 9;
  
using namespace std;

lld a[N];

int main()
{
    barnarnar
    ll m, n;
    cin >> n >> m;
    lld s = 0;
    forn(i, n)	cin >> a[i], s += a[i];
    s /= (4 * m);
    sort(a, a + n);
    reverse(a, a + n);
    forn(i, m)
    {
    	if(a[i] < s)
    	{
    		cout << "No";
    		r0;
		}
	}
	cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int N;
  cin >> N;
  string s;
  cin >> s;
  string ans="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i, s.size()){
  rep(j, 26){
    
  if(s[i]==ans[j])
    cout << ans[j+N];
  }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
void solve()
{
	int n,m;
	int a[1010];
	cin>>n>>m;
	int sum=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=1;i<=min(m,n);i++)
		sum+=a[i];
	cout<<sum<<endl;
}
int main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3624
import sys
s=0
S=str(input())
while len(S)>=0:
  if s==len(S):
    print("YES")
    sys.exit()
  if S[s:s+5]=="dream":
    if len(S)==s+5:
      print("YES")
      sys.exit()
    elif S[s+5]=="d" or S[s+5:s+8]=="era":
      s+=5
    elif S[s+5:s+8]=="erd" or S[s+5:s+8]=="ere":
      s+=7
    elif S[s+5:s+7]=="er" and len(S)==s+7:
      print("YES")
      sys.exit()
    else: 
      print("NO")
      sys.exit()
  elif S[s:s+5]=="erase":
    if len(S)==s+5:
      print("YES")
      sys.exit()
    elif S[s+5]=="d" or S[s+5]=="e":
      s+=5
    elif S[s+5]=="r":
      s+=6
    else: 
      print("NO")
      sys.exit()
  else: 
    print("NO")
    sys.exit()

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	ll x; cin >> x;
	for(int i = -1000; i < 1000; i++){
		for(int j = -1000; j < 1000; j++){
			ll a = pow(i, 5);
			ll b = pow(j,5);
			if((a-b)==x){
				cout << i << " " << j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int sq_cnt(int a){
    int cnt = 0;
    while(a%2==0){
        a /= 2;
        cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    vi a(n);
    int ans = 0;
    rep(i, n){
        cin >> a.at(i);
        ans += sq_cnt(a.at(i));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
ll Min, N, K, Ans;

int main()
{
	scanf ("%lld", &N);
	while (N--)
	{
		scanf ("%lld", &K);
		if (K >= Min) Min = K;
		else Ans += Min - K;
	}
	printf ("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int check(int a[3]){
	if(a[2] >= a[1]+a[0]) return -1;
	int x = a[2]*a[2]-a[1]*a[1]-a[0]*a[0];
	if(x > 0) return 2;
	if(x < 0) return 1;
	return 0;
}

int main(){
	int a[3];
	int cnt[3] = {};
	while(1){
		rep(i, 3) cin >> a[i];
		sort(a, a+3);
		if(check(a) == -1) break;
		cnt[check(a)]++;
	}
	cout << cnt[0]+cnt[1]+cnt[2];
	rep(i, 3){
		cout << ' ' << cnt[i];
	}
	cout << endl;

    return 0;
}

Measured memory_bytes: 1180
S = gets.chomp
N = S.length

ans = S.to_i
(1...N).each do |i| 
  patterns = [*1...N].combination(i).to_a
  patterns.each do |p|
    s = String.new(S)
    r = p.reverse
    r.each do |k|
      s.insert(k,?+)
    end
    ans += eval s
  end
end

puts ans

Measured memory_bytes: 2044
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] X=new int[N];
		for(int i=0;i<N;++i) {
			X[i]=sc.nextInt();
		}
		long ans=Long.MAX_VALUE/3;
		for(int p=0;p<=200;++p) {
			long cur=0;
			for(int x:X) {
				cur+=(x-p)*(x-p);
			}
			ans=Math.min(ans, cur);
		}
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
#define N 100'000
int C[N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> denoms = {1};
    for(int i = 6; i <= N; i *= 6) {
        denoms.push_back(i);
    }
    for(int j = 9; j <= N; j *= 9) {
        denoms.push_back(j);
    }
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        if(i == 1) {
            C[i] = 1;
        } else {
            C[i] = i;
            for(int d : denoms) {
                if(i - d >= 0) {
                    C[i] = min(C[i], C[i - d] + 1);
                }
            }
        }
    }
    cout << C[n] << endl;
    return 0;
}


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

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int ans=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(v[j]<v[minj]){
        minj=j;
      }
    }
    if(v[i]!=v[minj])swap(v[i],v[minj]),ans++;
  }
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<v[i];
  }
  cout<<endl<<ans<<endl;
}



Measured memory_bytes: 3120
#include<iostream>

int calc_free(int N, int M);

int main(void){
    int N, M;
    
    std::cin >> N >> M;
    std::cout << calc_free(N,M) << std::endl;
    
    return 0;
}

int calc_free(int N, int M) {
    int i, a;
    int A = 0;
    
    for(i=0; i < M; i++) {
        std::cin >> a;
        N -= a;
        if(N < 0) {
            return -1;
        }
    }
    
    return N;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int a[2000000];
int main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i];
    int target=1;
    rep(i,n){
        if(target == a[i])target++;
    }
  if(target == 1){cout<<-1<<endl;return 0;}
    cout << n-target+1 <<endl;
}

Measured memory_bytes: 1024
//C++
//#pragma comment(linker, "/STACK:102400000,102400000")
//G++
//#define OPENSTACK
#define ONLINE_JUDGE
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cctype>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int MOD = 998244353;
const int N = 1e6 + 10, M = N;//刻意开大会消耗时间.


int main()
{
    #ifdef OPENSTACK
    int size = 64 << 20; // 64MB
    char *p = (char*)malloc(size) + size;
    #if (defined _WIN64) or (defined __unix)
        __asm__("movq %0, %%rsp\n" :: "r"(p));
    #else
        __asm__("movl %0, %%esp\n" :: "r"(p));
    #endif
    #endif
    #ifndef ONLINE_JUDGE
        freopen("../put/a.input","r",stdin);
        freopen("../put/a.output","w",stdout);
    #endif
    clock_t c1 = clock();
    //coding here......

    string n;
    cin >> n;
    int res = 0;
    for(auto c : n) res += (c - '0');
    if(res % 9 == 0) puts("Yes");
    else puts("No");

    //finish here......
    #ifndef ONLINE_JUDGE
        std::cerr << "Time:" << clock() - c1 << "ms" << std::endl;
    #endif
    #ifdef OPENSTACK
        exit(0);
    #else
        return 0;
    #endif
}

Measured memory_bytes: 3728
fun abc121a(args: Array<String>) {
    val (H, W) = args[0].split(" ").map { it.toInt() }
    val (h, w) = args[1].split(" ").map { it.toInt() }
    println(H * W - h * W - w * H + h * w)
}

fun main(args: Array<String>) {
    abc121a(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

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

int n,y,r;

int main()
{
	scanf("%d/%d/%d",&n,&y,&r);
	cout<<2018<<'/';
	if(y/10==0) cout<<0<<y<<'/'; else cout<<y<<'/';
	if(r/10==0) cout<<0<<r; else cout<<r;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+100;
vector < int > a,b;
bool cmp(int x,int y){
	return x>y;
}
void solve(){
	cin >> n;
	for (int i=0;i<n;i++){
		int u,v;cin >> u >> v;
		a.push_back(u),b.push_back(v);
	}
	a.push_back(0),b.push_back(0);
//	for (int i=0;i<n+1;i++) cout << a[i] << ' ';
//	cout << endl;
//	cout << (*a.begin()) << ' ' << (*a.end()) << endl;
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end());
//	for (int i=0;i<n+1;i++) cout << a[i] << ' ';
//	cout << endl;
	long long ans=0;
	for (int i=0;i<=n;i++){
		if (a[i]>b[i]){
			ans+=(a[i]-b[i])*2;
		}
	}
	cout << ans;
}
int main(){
	solve();
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int n;
int dir[100000];

int f[100000];

int calc(int k) {
    memset(f, 0, sizeof(f));
    int res = 0;
    int sum = 0;
    for(int i=0;i+k<=n;i++){
        if((dir[i]+sum)%2 != 0){
            res++;
            f[i] = 1;
        }
        sum += f[i];
        if(i-k+1 >= 0){
            sum -= f[i-k+1];
        }
    }

    for(int i=n-k+1;i<k;i++){
        if((dir[i]+sum)%2 != 0){
            return -1;
        }
        if(i-k+1>=0){
            sum -= f[i-k+1];
        }
    }
    return res;
}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    n = s.size();
    for(int i=0;i<n;i++){
        dir[i] = s[i]-'0';
    }
    int l = 0;
    int r = n+1;
    while(r-l>1){
        int mid = (l+r)/2;
        if(calc(mid) >= 0){
            l = mid;
        }else{
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

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

        if ((a - b) % 2 == 0) {
            System.out.println((Math.abs(a) + Math.abs(b)) / 2);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


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

int main(){

    long long n;
    cin >> n;

    vector<long long> time(5);
    for(int i = 0; i < 5; i++){
        cin >> time[i];
    }
    
    long long bottle =  *min_element(time.begin(), time.end());
    if(n % bottle == 0){
        bottle = n / bottle;
    }
    else{
        bottle = n / bottle + 1;
    }

    cout << 4 + bottle << endl;


}

Measured memory_bytes: 256
#include <cstdio>
#define SIZE 33554432
char Key[128];
int Hash;
char* c;
#define HASH(A) c = A; Hash = 1; while(*c){ Hash <<= 2; Hash += Key[*c]; ++c;}
int main()
{
    Key['A'] = 0;
    Key['C'] = 1;
    Key['G'] = 2;
    Key['T'] = 3;
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d\n", &n);
    char str[21];
    for(int i = 0; i < n; ++i){
        std::gets(str);
        if(str[0] == 'i'){
            HASH(str+7)
            dic[Hash] = true;
        }else{
            HASH(str+5)
            std::puts((dic[Hash] ? "yes" : "no"));
        }
    }
    return 0;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>
using namespace std;
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
//const double PI = acos(-1) ;
db PI=3.1415926;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     pf("Case %d: %lld\n",z,x)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)


using namespace std;
ll n,m,y,x,h,e,l,o;
//int p,n,arr[2100000],ans;


int main()
{
	CIN;ll ans=0;
	cin>>n;
	vector<ll>v1,v2,v3;
	for0(i,n)
	{
		cin>>x;
		v1.pb(x);
	}
	for0(i,n)
	{
		cin>>x;
		v2.pb(x);
	}
	for0(i,n)
	{
		cin>>x;
		v3.pb(x);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	sort(v3.begin(),v3.end());

	for0(i,n)
	{
		h=v2[i];
		x=lower_bound(v1.begin(),v1.end(),h)-v1.begin();
		y=upper_bound(v3.begin(),v3.end(),h)-v3.begin();
		ans+=x*(n-y);
	}
	pf("%lld\n",ans);

	
	
	

}

Measured memory_bytes: 6380
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll lca(ll x, ll y) { return x/__gcd(x, y)*y; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) a[i] /= 2;
  int num = a[0], cnt = 0;
  while (num%2 == 0) {
    num /= 2;
    cnt++;
  }
  for (int i = 1; i < n; i++) {
    int cnt2 = 0;
    num = a[i];
    while (num%2 == 0) {
      num /= 2;
      cnt2++;
    }
    if (cnt2 != cnt) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll l = 1;
  rep(i, n) l = lca(l, a[i]);
  int ans = (m/l+1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W = [int(x) for x in input().split()]
    A = [input().strip() for _ in range(H)]

    q = collections.deque()

    q.append((0, 0))
    v = set()
    v.add((0, 0))

    while q:
        c = q.popleft()

        cnt = 0
        for nj, ni in [[0, 1], [1, 0], [-1, 0], [0, -1]]:
            if 0 <= nj + c[0] < H and 0 <= ni + c[1] < W:
                if (nj + c[0], ni + c[1]) in v or A[nj + c[0]][ni + c[1]] == '.':
                    continue
                cnt += 1
                if nj < 0 or ni < 0:
                    print("Impossible")
                    return
                q.append((nj + c[0], ni + c[1]))
                v.add((nj + c[0], ni + c[1]))

        if cnt > 1:
            print("Impossible")
            return

    print("Possible")



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			var a = cin.ArrayInt(3);
			bool ok = false;
            for (int i = 0; i < 3; i++)
            {
				if (a.Sum() - a[i] == a[i]) ok = true;
            }
            if (ok) Console.WriteLine("Yes");
            else Console.WriteLine("No");

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13268
import sys
n = int(input())
a = list(map(int, input().split()))

s = sum(a) / 2
i = 0
c = 0
while (True):
    c += a[i]
    if c > s:
        d = c - a[i]
        break
    i += 1
    

x = c - s
y = s - d
ans = min(x, y) * 2
print(int(ans))


        


        


    







        



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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

ll mpow(ll a,ll b){
    ll res=1;
    a%=mod;
    while(b){
    	if(b%2) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res;
}

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

void solve(){
	//code
	int n,x;
	cin>>n>>x;
	if(n*500>=x) cout<<"Yes";
	else cout<<"No";
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>

using namespace std;
int kai(int);

int main(){
    int N;
    scanf("%d",&N);
    int x[N];
    int y[N];
    for(int i=0;i<N;i++){
        scanf("%d",&x[i]);
        scanf("%d",&y[i]);
    }
    vector<int> P;
    for(int i=1;i<=N;i++){
        P.push_back(i);
    }
    int kai_N = kai(N);
    double sum = 0;
    for(int i=0;i<kai_N;i++){
        double tmp=0;
        for(int j=1;j<N;j++){
            tmp+=sqrt(pow(x[P[j]-1]-x[P[j-1]-1],2)+pow(y[P[j]-1]-y[P[j-1]-1],2));
        }
        sum += tmp/(double)kai_N;
        next_permutation(P.begin(),P.end());
    }
    cout<<setprecision(12)<<sum<<"\n";
}

int kai(int N){
    int sum=1;
    for(int i=1;i<=N;i++){
        sum *=i;
    }
    return sum;
}


Measured memory_bytes: 256
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        if xp != yp:
            if self.table[xp] <= self.table[yp]:
                self.table[xp] += self.table[yp]
                self.table[yp] = xp
            else:
                self.table[yp] += self.table[xp]
                self.table[xp] = yp

n, m = map(int, input().split())
clue = Unionfind(n)
for _ in range(m):
    x, y, _ = map(int, input().split())
    clue.union(x-1, y-1)
roots = set()
for i in range(n):
    roots.add(clue.find(i))
print(len(roots))

Measured memory_bytes: 12832
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 //#define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


void solve()
{
  
  string n;
  cin >> n ;
  int c=0;
  

  for(int i=0;i<sz(n);i++)
  {
    c+= (int)(n[i]-'0');
    c%=9;
  }

  cout<<(c?"No":"Yes");

}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 3772
#include <iostream>

using namespace std;
long long dp[200000][5];
long long cost[200000][5];
int main() {
    int L;
    long long A[200000];

    cin >> L;
    for (int i=0; i<L; i++) cin >> A[i];
    for (int i=0; i<L; i++) {
        cost[i][0] = A[i];
        cost[i][1] = (A[i] == 0) ? 2 : A[i]%2;
        cost[i][2] = (A[i]+1)%2;
        cost[i][3] = (A[i] == 0) ? 2 : A[i]%2;
        cost[i][4] = A[i];
    }
        

    for (int i=0; i<L; i++) {
        if (i == 0) {
            dp[0][0] = cost[0][0];
            dp[0][1] = cost[0][1];
            dp[0][2] = cost[0][2];
            dp[0][3] = cost[0][3];
            dp[0][4] = cost[0][4];
        } else {
            dp[i][0] = dp[i-1][0] + cost[i][0];
            dp[i][1] = dp[i-1][0] + cost[i][1];
            dp[i][2] = dp[i-1][0] + cost[i][2];
            dp[i][3] = dp[i-1][0] + cost[i][3];
            dp[i][4] = dp[i-1][0] + cost[i][4];
            for (int j=1; j<5; j++) {
                for (int k=j; k<5; k++) {
                    if (dp[i][k] > dp[i-1][j] + cost[i][k])
                        dp[i][k] = dp[i-1][j] + cost[i][k];
                }
            }
        }
    }
        
    long long mincost = -1;
    for (int i=0; i<5; i++) {
        if (mincost == -1 || mincost > dp[L-1][i]) mincost = dp[L-1][i];
    }
    cout << mincost << endl;
    return 0;
}



Measured memory_bytes: 17408
a=[[0]*3 for i in range(3)]
wk=[[0]*3 for i in range(3)]
a[0]=input().split()
a[1]=input().split()
a[2]=input().split()
n=int(input())
chk=False
for i in range(n):
  chk=False
  b=input()
  for j in range(3):
    if chk:
      break
    for k in range(3):
      if a[j][k]==b:
        wk[j][k]=1
        chk=True
        break
if [wk[0][0],wk[0][1],wk[0][2]]==[1,1,1]:
  print("Yes")
elif [wk[1][0],wk[1][1],wk[1][2]]==[1,1,1]:
  print("Yes")
elif [wk[2][0],wk[2][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][2],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][1],wk[1][1],wk[2][1]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][0],wk[2][0]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][1],wk[2][0]]==[1,1,1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n;
long long x, sum = 0, a[100010], b[100010];
int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (i == 0)b[i] = min(x, a[i]);
		else b[i] = min(a[i], x - b[i - 1]);
		sum += a[i] - b[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String str = stdIn.next();
			if(str.equals("0"))
			{
				break;
			}
			int pointA = 0;
			int pointB = 0;
			for(int i = 1; i < str.length(); ++i)
			{
				if(str.charAt(i) == 'A')
				{
					++pointA;
				}
				else
				{
					++pointB;
				}
			}
			if(pointA > pointB)
			{
				++pointA;
			}
			else
			{
				++pointB;
			}
			System.out.println(pointA + " " + pointB);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){ int t=a; a=b; b=t; }
  if(a>c){ int t=a; a=c; c=t; }
  if(b>c){ int t=b; b=c; c=t; }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 3010 , mod = 1e9+7 , inv2 = (mod + 1) / 2;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , Q;
int a[N] , F[N][N] , G[N][N];

inline int add(int a , int b) { return a + b >= mod ? a - mod + b : a + b; }
inline int mul(int a , int b) { return (LL)a * b % mod; }

int main()
{
	n = read(); Q = read();
	for(int i = 1 ; i <= n ; ++i) a[i] = read();
	for(int i = 1 ; i <= n ; ++i) for(int j = 1 ; j <= n ; ++j) F[i][j] = a[i] > a[j];
	int p1 , p2 , res = 1;
	while(Q--)
	{
		p1 = read(); p2 = read();
		for(int i = 1 ; i <= n ; ++i) if(i != p1 && i != p2)
		{
			G[i][p1] = G[i][p2] = mul(inv2 , add(F[i][p1] , F[i][p2]));
			G[p1][i] = G[p2][i] = mul(inv2 , add(F[p1][i] , F[p2][i]));
		}
		for(int i = 1 ; i <= n ; ++i) if(i != p1 && i != p2) F[i][p1] = G[i][p1] , F[i][p2] = G[i][p2] , F[p1][i] = G[p1][i] , F[p2][i] = G[p2][i];
		F[p1][p2] = F[p2][p1] = mul(inv2 , add(F[p1][p2] , F[p2][p1]));
		res = mul(res , 2);
	}
	int ans = 0;
	for(int i = 1 ; i <= n ; ++i) for(int j = i + 1 ; j <= n ; ++j) ans = add(ans , F[i][j]);
	cout << mul(res , ans) << '\n';
	return 0;
}

Measured memory_bytes: 70912