akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <iomanip>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string N;
    cin >> N;
    cout << character_count(N, '2') << endl;
}


Measured memory_bytes: 256
INPUT=input()
IN=INPUT.split(" ")
#N=int(IN[0])
number=int(IN[0])
#N
A=int(IN[1])
B=int(IN[2])

GOUKEI=0
kazu=0

while kazu<=number:
    X=list(map(int,list(str(kazu))))
    #X = list(map(int, n))
   
    #print(X)
    if A<=sum(X)<=B:
        GOUKEI+=kazu
        #print("add",kazu)
    kazu+=1
print(GOUKEI)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) begin(x),end(x)
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M;
    cin >> N >> M;
 
    vector<int> e( M );
    for( auto &x : e )
    {
        cin >> x;
    }
 
    reverse( ALL( e ) );
	
    //move
    vector<int>  flag( N + 1 );
    REP( i, M )
    {
        if( !flag[ e[ i ] ] )
        {
            cout << e[ i ] << endl;
            flag[ e[ i ] ] = 1;
        }
    }
 
    //not move
    REP2( i, 1, N + 1 )
    {
        if( !flag[ i ] )
        {
            cout << i << endl;
        }        
    }
    return 0;
}

Measured memory_bytes: 4152
#include<iostream>
using namespace std;
int main(){

	int h, m, s;
	cin >>s;
	h = s / 3600;
	s -= h * 3600;
	m = s / 60;
	s -= m * 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>

using namespace std;

// n の k 乗を mod で割った余りを計算
long long power_mod(long long n, long long k, long long mod) {
    long long result = 1;
    // k を右シフトしつつ n を 2 乗していく
    while (k > 0) {
        // k の最下ビットが 1 なら、今の n を答えに掛ける
        if ((k & 1) == 1) result = (result * n) % mod;
        n = n * n % mod;
        k >>= 1;
    }
    return result;
}

// 階乗・組み合わせの mod 逆数
class FactorialMod {
    // 逆元を計算
    void calc_inverse() {
        inverse[0] = 0;
        inverse[1] = 1;
        for (int i = 2; i <= max_num; i++) {
            inverse[i] = mod - ((mod / i) * inverse[mod % i] % mod);
        }
    }

    // i! を mod で割った余りと逆元を計算
    void calc_factorial_inverse() {
        factorial[0] = factorial_inverse[0] = 1;
        for (int i = 1; i <= max_num; i++) {
            factorial[i] = (factorial[i - 1] * i) % mod;
            factorial_inverse[i] = (factorial_inverse[i - 1] * inverse[i]) % mod;
        }
    }

  public:
    int max_num;                         // 扱う最大の値
    int mod;                             // mod の法（素数）
    vector<long long> inverse;           // 逆元
    vector<long long> factorial;         // 階乗
    vector<long long> factorial_inverse; // 階乗の逆元

    FactorialMod(int _max_num, int _mod) {
        max_num = _max_num;
        mod = _mod;
        inverse = vector<long long>(max_num + 1);
        factorial = vector<long long>(max_num + 1);
        factorial_inverse = vector<long long>(max_num + 1);
        calc_inverse();
        calc_factorial_inverse();
    }

    // nCk を mod で割った余りを計算
    long long combination_mod(int n, int k) {
        if (n < 0 || k < 0 || n > max_num || k > max_num || k > n) return 0;
        return (((factorial[n] * factorial_inverse[k]) % mod) * factorial_inverse[n - k]) % mod;
    }

    // nHk を mod で割った余りを計算
    long long multi_choose_mod(int n, int k) {
        return combination_mod(n + k - 1, k);
    }
};

const int MOD = 1000000007;

int main(void) {
    int n, k;
    cin >> n >> k;
    FactorialMod factorial_mod(1000, MOD);
    cout << factorial_mod.combination_mod(k, n) << endl;
    return 0;
}


Measured memory_bytes: 3128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, int> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-4;
const LL INF = 1e7 - 1;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const int MAXN = 100001;
const int MAXK = 101;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	VLL a(n);
	FOR(i, 0, n)
		cin >> a[i];

	int odd = 0, even = 0;
	FOR(i, 0, n)
		if (a[i] & 1)
			++odd;
		else
			++even;

	if (odd & 1)
		cout << "NO";
	else
		cout << "YES";

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace std;

double l;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> l;
	cout << fixed << setprecision(6) << (l / 3) * (l / 3) * (l / 3) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool compare(string a, string b)
    {
        return (a+b < b+a);
    }
int main()
{
    int x,l;
    cin>>x>>l;
    string s[111];
    for (int i=0;i<x;i++){
        cin>>s[i];
    }
    
    sort(s, s+x, compare);

    for (int i = 0; i < x; i++){
             cout<<s[i];

    }
    cout<<endl;
    
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cout << #x << " " << x << endl

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

    ll n,m;
    cin >> n >> m;

    vector<ll> v(n);

    for(ll i=0 ; i<n ; ++i) cin >> v[i];

    ll sum = accumulate(v.begin() , v.end() , 0LL);

    if(sum > n) cout << -1 ;
    else cout << n-sum ;    
    return 0;
} 

Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
bool zs(int n)
{
	for(int i=2;i*i<=n;++i)
		if(n%i==0)
			return false;
	return true;
}
bool hw(int n)
{
	int m=0,k=n;
	while(k!=0)
	{
		m=m*10+k%10;
		k/=10;
	}
	if(m==n)
		return true;
	return false;
}
int main()
{
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define dbg(x) cout << #x << " = " << (x) << endl;
const ll MOD = 1000000007;
const ll INF = 1e18;

int h, w;
char m[1001][1001];
int ways[1001][1001];

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("F:\\Scripts\\input", "r", stdin);
    // freopen("F:\\Scripts\\output", "w", stdout);
    // #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    for(int i = 0;i < h;i++) for (int j = 0;j < w;j++) cin >> m[i][j];
    for(int i = 0;i < h;i++) if (m[i][0] == '#') break; else ways[i][0] = 1;
    for(int i = 0;i < w;i++) if (m[0][i] == '#') break; else ways[0][i] = 1;
    for(int i = 1;i < h;i++)
        for(int j = 1;j < w;j++) if (m[i][j] != '#')
            ways[i][j] = (1LL * ways[i-1][j] + 1LL * ways[i][j-1])%MOD;
    cout << ways[h-1][w-1];
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    vector<ll> v;
    v.push_back(0);
    if (s[0] == '0')
        v.push_back(0);

    ll seq = 1;
    rep(i, s.size() - 1) {
        if (s[i] == s[i + 1])
            seq++;
        else
            v.push_back(seq), seq = 1;
    }
    v.push_back(seq);

    rep(i, v.size()) { v[i + 1] += v[i]; }

    ll ans = 0;
    for (int i = 0; i < v.size(); i += 2) {
        int right = i + 2 * K + 1;
        if (right >= v.size())
            right = v.size() - 1;
        ans = max(ans, v[right] - v[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4460
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;


signed main()
{   
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i],a[i]--;

    int cur=0;
    for(int i=1;i<=N;i++){
        cur=a[cur];
        if(cur+1==2){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
 
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

vector<ll> primes(ll x) {
	vector<ll> ret;
	for (ll i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			ret.push_back(i);
			while (x % i == 0) {
				x /= i;
			}
		}
	}
	if (x != 1) ret.push_back(x);
	return ret;
}

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

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

	ll g = gcd(a, b);
	auto ret = primes(g);

	out(sz(ret) + 1);

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int u, v;
using Graph = vector<vector<int>>;
ll dist_u[110000];
ll dist_v[110000];

int main () {
  cin >> N >> u >> v;

  Graph G(N+1);

  Rep(i, N-1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> que;
  que.push(v);

  int cur = 0;
  rep(i, N) {
    dist_v[i] = -1;
  }

  while(!que.empty()) {
    queue<int> new_q;

    int n = que.size();

    Rep(i, n) {
      int tmp = que.front(); que.pop();
      if (dist_v[tmp] == -1) {
        dist_v[tmp] = cur;
        for (auto nv: G[tmp]) {
          new_q.push(nv);
        }
      }
    }

    que = new_q;
    cur++;
  }

  que.push(u);

  cur = 0;
  rep(i, N) {
    dist_u[i] = -1;
  }

  while(!que.empty()) {
    queue<int> new_q;

    int n = que.size();

    Rep(i, n) {
      int tmp = que.front(); que.pop();
      if (dist_u[tmp] == -1) {
        dist_u[tmp] = cur;
        for (auto nv: G[tmp]) {
          new_q.push(nv);
        }
      }
    }

    que = new_q;
    cur++;
  }

  vector<ll> dist(110000);

  ll ans = 0;

  rep(i, N) {
    dist[i] = dist_v[i] - dist_u[i];

    //cout << dist_u[i] << " " << dist[i] << "\n";

    if (dist[i] <= 0) {
      continue;
    } else {
      bool flg = false;

      for (auto nv: G[i]) {
        if (dist[nv] > 0) flg = true;
      }

      ans = max(ans, dist_u[i] + dist[i] - 1);
    }
  } 

  cout << ans << "\n";

}


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

int main(){
    int n,odd=0;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
        if(a[i]%2) odd++;
    } 
    int even = n-odd;
    if(odd%2){
        if((odd/2+even)%2==0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else{
        if(odd/2+even%2) cout << "YES" << endl;
        else cout << "NO " << endl;
    }
}

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

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        char[] s = in.nextToken().toCharArray();
        long[][] dp = new long[s.length + 1][13];
        dp[0][0] = 1;
        final long modL = 1000000007;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '?') {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 13; k++) {
                        final int mod = (k * 10 + j) % 13;
                        dp[i + 1][mod] = (dp[i + 1][mod] + dp[i][k]) % modL;
                    }
                }
            } else {
                for (int j = 0; j < 13; j++) {
                    final int mod = (j * 10 + (s[i] - '0')) % 13;
                    dp[i + 1][mod] = (dp[i + 1][mod] + dp[i][j]) % modL;
                }
            }
        }
        System.out.println(dp[s.length][5]);
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 37588
import collections
N, K = map(int, input().split())
lists=[]
for i in range(K):
    d1=int(input())
    A1=list(map(str,input().split()))
    lists.append(A1)
a=[e for row in lists for e in row]
c = collections.Counter(a)
num=len(c)
print(N-num)

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

#define int long long
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
 
using namespace std;

typedef long long ll; 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
 
const  int mxN = 1e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;
 	
signed main(){
	int n;
	cin >> n;
	int y = n;
	vi v(n + 1, 0);
	n--;
	while(n--) {
		int a; cin >> a;
		v[a]++;
	}
	for(int i = 1 ; i <= y; i++) cout << v[i] << " ";
	
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	



Measured memory_bytes: 4844
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include<bits/stdc++.h>
#include <math.h>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;


int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    const double PI=4*atan(1);
    double ht=30*h+m/2,hm=6*m;
    double t=min(abs(ht-hm),360-abs(ht-hm));
    //double t=abs(h*30-6*m);
    t=(3.14159265358979323846/180.0)*t;
    double ans=sqrt(a*a+b*b-2*a*b*cos(t));

    cout<<setprecision(10)<<ans<<"\n";
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

const int ALPHA = 26;

int main(){
	string input;
	while(cin && getline(cin, input)){
		string cand[ALPHA];
		for(int i=0; i<ALPHA; i++){
			cand[i] = "";
			for(int n=0; n<input.size(); n++){
				if('a'<=input[n]&&input[n]<='z'){
					cand[i] += (input[n]-'a'+i)%ALPHA + 'a';
				} else {
					cand[i] += input[n];
				}
			}
			if(cand[i].find("the") != string::npos
				|| cand[i].find("this") != string::npos
				|| cand[i].find("that") != string::npos){
				cout<<cand[i]<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		sc.close();
		String S = "";
		if(N.charAt(N.length()-1) == '2' ||
				N.charAt(N.length()-1) == '4' ||
				N.charAt(N.length()-1) == '5' ||
				N.charAt(N.length()-1) == '7' ||
				N.charAt(N.length()-1) == '9') {
			S = "hon";
		}else if(N.charAt(N.length()-1) == '0' ||
				N.charAt(N.length()-1) == '1' ||
				N.charAt(N.length()-1) == '6' ||
				N.charAt(N.length()-1) == '8') {
			S = "pon";
		}else {
			S = "bon";
		}

		System.out.println(S);
	}

}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof(v))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r) {int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int n, m, x, y, z, w, h;
str s, t;
double a;

signed main(){
    incant();
    while(cin >> n){
        double res = 0, cnt = 0;
        bool flag = true;
        rep(i, n){
            cin >> a >> s;
            if(s == "JPY"){
                res += a;
            }else{
                res += 380000.0 * a;
            }
        }
        print(res);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

int main(){
    std::string s;
    std::cin >> s;

    std::map<std::string, int> day = {
        {"SUN", 0},
        {"MON", 1},
        {"TUE", 2},
        {"WED", 3},
        {"THU", 4},
        {"FRI", 5},
        {"SAT", 6}
    };

    std::cout << 7 - day[s] << std::endl;

    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	int a = 0, b = 0, c = 0, d = 0;
	for (int i = 0; i < 10; i++){
		cin >> a;
		if (a>b){
			d = c;
			c = b;
			b = a;
		}
		else if (a > c){
			d = c;
			c = a;
		}
		else if (a > d){
			d = a;
		}
	}
	cout << b << endl << c << endl << d<< endl;
	return 0;
}

Measured memory_bytes: 3076
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

vector<ll> ar[sz];
bool vis[sz];

void dfs(ll node)
{
    vis[node]=true;
    for(ll child:ar[node])
    {
        if(!vis[child])
            dfs(child);
    }
}

int main()
{
    IOS;
    

    ll n,m;
    cin>>n>>m;

    rep(i,0,m)
    {
        ll a,b;
        cin>>a>>b;
        ar[a].pb(b);
        ar[b].pb(a);
    }
    // cout<<"hi\n";
    ll cc=0;
    rep(i,1,n+1)
    {
        if(!vis[i])
        {
            // cout<<i<<"<-\n";
            dfs(i);
            cc++;
        }
    }
    cout<<cc-1<<endl;
}

Measured memory_bytes: 10444
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

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

int main(void){
   int N,A,B;
   cin>>N>>A>>B;
   if((B-A)%2==0){
      cout<<"Alice"<<endl;
   }else if((B-A)%2==1){
      cout<<"Borys"<<endl;
   }else if(A==B){
      cout<<"Draw"<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll read()     
{
    ll 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;
}

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

}

Measured memory_bytes: 3132
N, M = map(int, input().split())

import math
if M >= 2:
    m = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
else:
    m = 0
if N >= 2:
    n = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))
else:
    n = 0
print(m + n)

Measured memory_bytes: 9120
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

a=list(map(str, [0,1,2,3,4,5,6,7,8,9]))
n,k=map(int, input().split())
d=list(map(str, input().split()))
for item in d:
    a.remove(item)
#print(a)

from collections import deque

q=deque()
q.extend(a)
for i in range(len(a)):
    if int(a[i])>=n:
        print(a[i])
        sys.exit()

while True:
    qq=q.popleft()
    #print(q)
    for item in a:
        qqq=qq+item
        #print(qqq[::-1])
        if int(qqq[::-1])>=n:
            print(qqq[::-1])
            sys.exit()
        q.append(qqq[::-1])


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


bool inside(int i, int j, int h, int w) {
	return (i >= 0 && i < h && j >= 0 && j < w);
	}

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int n,k,d;
	cin>>n>>k;
	vector<bool> arr(n+1);
	for(int i = 0; i < k; i++) {
		cin>>d;
		for(int j = 0; j < d; j++) {
			int x;
			cin>>x;
			arr[x] = true;
		}
	}

	int count = -1;
	for(auto it : arr) {
		if(it == false)
			count++;
	}
	cout<<count;

	return 0;		
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
int dp[301][301][301];
int main()
{
    int i,j;
    string a;
    int k1;
    cin>>a;
    cin>>k1;
    int n=a.size();

            int k;
    for(k=0;k<=k1;k++)
  {

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n-i+1;j++)
        {
            int o=j+i-1;
            dp[j][o][k]=max(dp[j][o][k],dp[j][o][k-1]);

            if(i==1)
               dp[j][o][k]=1;
               else
               {

                  if(a[j-1]==a[o-1])
                  {

                      dp[j][o][k]=max(dp[j][o][k],dp[j+1][o-1][k]+2);
                  }
                  else{

                    if(k!=0)
                         dp[j][o][k]=max(dp[j][o][k],dp[j+1][o-1][k-1]+2);

                     dp[j][o][k]=max(dp[j][o][k],dp[j+1][o][k]);
                      dp[j][o][k]=max(dp[j][o][k],dp[j][o-1][k]);



                  }



               }



        }


        }




    }






  int ans=0;
  for(k=0;k<=k1;k++)
    for(i=1;i<=n;i++)
    for(j=i;j<=n;j++)

        ans=max(ans,dp[i][j][k]);


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




Measured memory_bytes: 106368
/**
 * Created by hiroqn on 13/10/07.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function matrix(n, m, init) {
  var arr = [], i, j;
  for (i = 0; i < n; i++) {
    arr[i] = [];
    for (j = 0; j < m; j++) {
      arr[i][j] = init;
    }
  }
  return arr;
}

function solve(melody, phraseList) {
  var n = phraseList.length,
      dp = matrix(n + 1, melody + 1, 0),
      i, j, k,
      s, l, p,
      max;
  for (i = 0; i < n; i++) {
    s = phraseList[i][0];
    l = phraseList[i][1];
    p = phraseList[i][2];
    for (j = 0; j <= melody; j++) {
      if (s <= j) {
//        console.log(i,j)
        max = 0;
        for(k=l > j ? 0: j - l;k <= j - s; k++){
          if(max < dp[i + 1][k]){
            max = dp[i + 1][k];
          }
        }
        dp[i + 1][j] = Math.max(dp[i][j], max + p);
//        range = dp[i + 1].slice(l > j ? 0: j - l, j - s + 1);
//        dp[i + 1][j] = Math.max(dp[i][j], Math.max.apply(null, max) + p);
      } else {
        dp[i + 1][j] = dp[i][j];
      }

    }
  }
//  console.log(dp);dp[n][melody]
  return dp;
}
function main() {

  var n = input.shift() - 0,
      phraseList = [];
  for (i = 0; i < n; i++) {
    phraseList.push(input.shift().split(' ').map(Number));
  }
//  n = phraseList.length;
//  phraseList.sort(function (a, b) {
//    return a[2] - b[2];
//  });
//  console.log(phraseList)
  var m = input.shift() - 0,
      melodyList = [],
      melody,
      ans = [],
      i, j, k,
      max,
      dp,
      flag = true;
  for (i = 0; i < m; i++) {
    melodyList.push(input.shift() - 0);
  }
  dp = solve(393, phraseList);
  for (i = 0; i < m; i++) {
    melody = melodyList[i];
//    console.log(max)
    if (dp[n][melody] === 0) {
      flag = false;
    } else {
      ans.push(dp[n][melody]);
    }
  }
  if(!flag){
    console.log(-1);
    return;
  }
  ans.forEach(function(i){console.log(i)});

}

Measured memory_bytes: 12524
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    let nums: Vec<u64> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (n, d) = (nums[0], nums[1]);
    let range = 2 * d + 1;

    println!("{}", n / range + (n % range > 0) as u64);
}


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

int main() {
  int k, s;
  int ans = 0;
  cin >> k >> s;
  for (int i = 0; i<= k; i++){
    for (int j = 0; j <= k; j++){
      if(i + j > s || s - i - j > k ) continue;
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int K, X;

int main(){
    cin >> K >> X;
    cout << (K*500 >= X ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string s;
  cin>>s;
  int j = 0;
    if(s.at(0) == '1'){
      j++;
    }
    if(s.at(1) == '1'){
      j++;
    }
    if(s.at(2) == '1'){
      j++;
    }
  cout<<j<<endl;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=4e5+5;
const ll mod=1e9+7;
char a[w];
int main()
{
    int i,j;
    scanf("%s",a);
    int len=strlen(a);
    int flag=0;
    for(i=0;i<len;i++)
    {
        if(a[i]=='h')
            flag++;
        else if(a[i]=='i')
        {
            if(flag==1)
                flag=0;
            else
                flag=100;
        }
        else
            flag=100;
    }
    if(flag)
        puts("No");
    else
        puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int all_xored = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		all_xored ^= a[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (i != 0)
			cout << " ";
		cout << (all_xored ^ a[i]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define N 3005
#define MOD 998244353
int n,m,ans,a[N],s[N],dp[N][N];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
	{
		for(int j=a[i];j<=m;++j) {dp[i][j]=s[j-a[i]];if(j==a[i]) dp[i][j]=(dp[i][j]+i)%MOD;}
		for(int j=a[i];j<=m;++j) s[j]=(s[j]+dp[i][j])%MOD;
	}
	for(int i=1;i<=n;++i) ans=(ans+1ll*dp[i][m]*(n-i+1)%MOD)%MOD;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int h,w;
    cin >> h >> w;
    vector<vector<int>> cost(10,vector<int>(10,inf));
    rep(i,10){
        rep(j,10) cin >> cost[i][j];
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }
    ll sum = 0;
    rep(i,h) rep(j,w){
        int x;
        cin >> x;
        if(x==-1) continue;
        sum += cost[x][1];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string N;
   int K;
   cin >> N >> K;
   int size = N.size();
   int dp[size+1][K+1][2];
   memset(dp, 0, sizeof(dp));
   int cnt=0;
   dp[0][0][0]=1;
   for(int i=0;i<size;i++){
      int d = N[i]-'0';
      if(d!=0) cnt++;
      for(int j=0;j<=K;j++){
         //cout << i << j << 0 << ":" << dp[i][j][0]<<endl;
         //cout << i << j << 1 << ":" << dp[i][j][1]<<endl;
         if(d==0){
            // case 0
            dp[i+1][j][0]+=dp[i][j][0];
            dp[i+1][j][1]+=dp[i][j][1];
            // case 1-9
            if(j!=K) dp[i+1][j+1][1]+=9*dp[i][j][1];
         }
         else{
            // case 0
            dp[i+1][j][1]+=dp[i][j][1]+dp[i][j][0];
            // case 1-d
            if(j!=K) {
               dp[i+1][j+1][1]+=(d-1)*(dp[i][j][0]+dp[i][j][1]);
               // case d
               dp[i+1][j+1][0]+=dp[i][j][0];
               dp[i+1][j+1][1]+=dp[i][j][1];
               // case d+1-9
               dp[i+1][j+1][1]+=(9-d)*dp[i][j][1];
            }
         }
      }
   }
   int ans=dp[size][K][1];
   if(cnt==K) ans++;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
s = input();
t = input();
def rotate(s):
    s = s[len(s)-1:len(s)]+s[0:len(s)-2]+s[len(s)-2:len(s)-1]
    #print(s)
    return s
if len(s) == 1:
    if s==t:
        print('Yes')
    else:
        print('No')
else:
    flag = 0
    #print(len(s))
    for i in range(len(s)):
        s = rotate(s)
        if s==t:
            print('Yes')
            flag =1
            break
    if flag ==0:
        print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int n, i, x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    x = i;
    if (x % 3 == 0) {
      printf(" %d", x);
    } else {
      while (x > 0) {
        if (x % 10 == 3) {
          printf(" %d", i);
          break;
        }
        x /= 10;
      }
    }
  }
  putchar('\n');
}


Measured memory_bytes: 2040
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] S = new int[N];
		int[] T = new int[M];
		for(int i = 0; i < N; i++)
			S[i] = sc.nextInt();
		for(int i = 0; i < M; i++)
			T[i] = sc.nextInt();
		long[][] dp = new long[N+1][M+1];
		int mod = 1000_000_007;
		for(int i = 1; i <= N; i++) {
			for(int j = 1;  j <= M; j++) {
				if(S[i-1] == T[j-1])
					dp[i][j] = dp[i-1][j] + dp[i][j-1] + 1;
				else
					dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + mod;
				dp[i][j] %= mod;
			}
		}
		System.out.println(dp[N][M] + 1);
	}

}


Measured memory_bytes: 80936
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n+1);
    rep(i,n) cin >> a.at(i);
    a.at(n) = 0;
    int64_t sum = abs(a.at(0));
    rep(i,n-1){
        sum += abs(a.at(i+1) - a.at(i));
    }
    sum += abs(a.at(n-1));
    vi res(n);
    if((a.at(1) - a.at(0) >= 0 && a.at(0) >= 0) ||
       (a.at(1) - a.at(0) <= 0 && a.at(0) <= 0)){
        res.at(0) = sum;
    }else{
        res.at(0) = sum - (abs(a.at(1) - a.at(0)) + abs(a.at(0)))
        + abs(a.at(1));
    }
    for(int i=1; i<n; i++){
        if((a.at(i+1) - a.at(i) >= 0 && a.at(i) - a.at(i-1) >= 0) ||
           (a.at(i+1) - a.at(i) <= 0 && a.at(i) - a.at(i-1) <= 0)){
            res.at(i) = sum;
        }else{
            res.at(i) = sum - (abs(a.at(i+1) - a.at(i)) + abs(a.at(i) - a.at(i-1)))
            + abs(a.at(i+1) - a.at(i-1));
        }
    }
    rep(i,n) cout << res.at(i) << endl;
}


Measured memory_bytes: 2816
import sys
input = sys.stdin.readline

def main():
    x, y, z, K = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)
    B = sorted(list(map(int, input().split())), reverse=True)
    C = sorted(list(map(int, input().split())), reverse=True)

    ind = []
    for i in range(x):
        for j in range(y):
            if (i+1)*(j+1) <= K:
                for k in range(z):
                    if (i+1)*(j+1)*(k+1) <= K:
                        ind.append(A[i]+B[j]+C[k])
                    else:
                        break
            else:
                break
    ind = sorted(ind, reverse=True)
    for i in range(K):
        print(ind[i])

if __name__ == "__main__":
    main()

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

int main() {
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,-1));
  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      x--;
      vec[i][x]=y;
    }
  }
  int ans=0;
  rep(bit,1<<n){
    vector<int> d(n);
    rep(j,n)if(bit&(1<<j))d[j]=1;//正直者か不親切な人か
    bool ok=true;
    rep(j,n)if(d[j]){
      rep(k,n){
        if(vec[j][k]==-1)continue;//相手の証言なし
        if(vec[j][k]!=d[k])ok=false;//相手の証言が矛盾していたら
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(bit));//bitの1の個数
  }
  cout<<ans<<endl;
}


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

#define INF INT_MAX
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;
	int aa = 0;
	for(int i =0;i < n;i++){
		if(s[i] == 'R')aa++;
	}
	if(aa > (n-aa))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int table[12][12]={0};

void dropink(int x,int y, int s){
	switch (s){
		case 3:
			if(x-2>=0)
				table[x-2][y]++;
			if(y-2>=0)
				table[x][y-2]++;
			if(x+2<=11)
				table[x+2][y]++;
			if(y+2<=11)
				table[x][y+2]++;
		case 2:
			table[x+1][y+1]++;
			table[x-1][y+1]++;
			table[x+1][y-1]++;
			table[x-1][y-1]++;
		case 1:
			table[x][y]++;
			table[x+1][y]++;
			table[x][y+1]++;
			table[x-1][y]++;
			table[x][y-1]++;
	}
	return ;
}

int main(){
	int x,y,s;
	char tem;
	while( cin >> x >> tem >> y >> tem >> s ,!cin.eof())
		dropink(x+1,y+1,s);
	int NUM=0,MAX=0;
	for(int y=1;y<=10;y++){
		for(int x=1;x<=10;x++){
			if(table[x][y])
				MAX=max(MAX,table[x][y]);
			else
				NUM++;
		}
	}
	cout << NUM << endl << MAX << endl;
	return 0;
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;

template<typename T, typename U>
using mapv = map<T,vector<U>>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

#define MOD097 1000000007

///// For Debug

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// 提出時はコメントアウト
// #define LOCAL
#define DEBUG_

#ifndef LOCAL
#undef DEBUG_
#endif

#ifdef DEBUG_

#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)

#endif

//////////

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    string N;
    cin>>N;

    vecl hon = {2,4,5,7,9};
    vecl pon = {0,1,6,8};

    string ans;
    ll n = N[N.length()-1] - '0';

    if (count(ALL(hon),n))
        ans = "hon";
    else if (count(ALL(pon),n))
        ans = "pon";
    else
       ans = "bon"; 

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3624
import sys
msg = sys.stdin.readlines()
n = int(msg[0])
a = list(map(int,msg[1].split()))
tot = 0
b = [0 for i in range(n+1)]
for i in range(n+1):
  b[i] = (1<<i)-2*tot;
  tot = 2*tot+a[i];
  if tot > (1<<i):
    print(-1)
    exit(0)
nb = 0
crt = 0;
for i in range(n,-1,-1):
  crt = min(crt+a[i],b[i])
  nb += crt;
print(nb)

Measured memory_bytes: 671508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String Date1 = "2019/04/30";
		String Date2;
		String ans = "Heisei";
		Scanner sc = new Scanner(System.in);

		Date2 = sc.nextLine();

		if(Date1.compareTo(Date2) < 0) {
			ans = "TBD";
		}

		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 21460