akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];
            var S = new int[M][];
            for (int i = 0; i < M; i++)
            {
                S[i] = Console.ReadLine().Split().Skip(1).Select(int.Parse).ToArray();
            }
            var P = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var switches = new bool[N];

            Console.WriteLine(Count(0, N, switches, M, S, P));
        }

        static int Count(int i, int N, bool[] switches, int M, int[][] S, int[] P)
        {
            if (i == N) return Judge(switches, M, S, P) ? 1 : 0;

            switches[i] = true;
            var trueCnt = Count(i + 1, N, switches, M, S, P);

            switches[i] = false;
            var falseCnt = Count(i + 1, N, switches, M, S, P);

            return trueCnt + falseCnt;
        }

        static bool Judge(bool[] switches, int M, int[][] S, int[] P)
        {
            return Enumerable.Range(0, M).All(i => Judge(switches, S[i], P[i]));
        }

        static bool Judge(bool[] switches, int[] s, int p)
        {
            var cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (switches[s[i] - 1]) cnt++;
            }
            return cnt % 2 == p;
        }
    }
}


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

int main() {
  //定義一覧
  int A; //A以上の整数
  int B; //B以上の整数
  
  int tmp0 = 0; //整数の置き場
  int tmp1 = 0; //整数の置き場
  int tmp2 = 0; //整数の置き場
  int tmp3 = 0; //整数の置き場
  int tmp4 = 0; //整数の置き場
  
  int tmp = 0; //回文数の個数
  
  //入力
  cin >> A >> B;
  //繰り返し
  for(int i = A; i < (B + 1); i++){
    //桁それぞれの整数を算出
    tmp4 = i;
    tmp4 = tmp4 / 10000;
    
    tmp3 = i % 10000;
    tmp3 /= 1000;
    
    tmp2 = i % 1000;
    tmp2 /= 100;
    
    tmp1 = i % 100;
    tmp1 /= 10;
    
    tmp0 = i % 10;
    tmp0 /= 1;
    
    //cout << tmp4 << tmp3 << tmp2 << tmp1 << tmp0 << endl;
    
    if((tmp4 == tmp0) && (tmp3 == tmp1)){
      tmp += 1;
    }
  }
  
  //出力
  cout << tmp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;

int main(){
    LL N, T;
    cin >> N >> T;
    vector<LL>  a(N);
    for(int i = 0;i < N;i++)    cin >> a[i];
    vector<LL>  mina(N), maxa(N);
    set<P> st;
    mina[0] = a[0], maxa[N-1] = a[N-1];
    for(int i = 1;i < N;i++)    mina[i] = min(mina[i-1], a[i]);
    for(int i = N-2;i >= 0;i--) maxa[i] = max(maxa[i+1], a[i]);
    map<LL, LL>  p;
    LL m = 0;
    for(int i = 0;i < N-1;i++)  m = max(m, maxa[i+1]-mina[i]);
    for(int i = 0;i < N-1;i++){
        if(maxa[i+1]-mina[i] == m){
            if(a[i] == mina[i]){
                p[maxa[i+1]]++;
                st.insert(P(a[i], a[i]+m));
            }
            if(a[i+1] == maxa[i+1])    p[mina[i]]++;
        }
    }
    LL ans = 0;
    for(auto& iter : st){
        ans += min(p[iter.first], p[iter.second]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12032
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-30 13:03:34
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       int(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

int n , ans;
vector<int> vec;
string s;

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

	cin >> s;
	n = SZ(s);
	for(int i = n - 1 ; i >= 0 ; i--){
		vec.push_back(s[i] - 48);
	}
	int ptr = SZ(vec) - 1;
	while(1){
		int prv = 0;
		/*for(int i = SZ(vec) - 1 ; i >= 0 ; i--)	cout << vec[i];
		cout << endl;*/
		//vector<int> res;
		//cout << SZ(vec) << sep << ptr << endl;
		ptr = min(ptr , SZ(vec) - 1);
		while(ptr > 0 && vec[ptr - 1] >= vec[ptr]){
			ptr--;
		}
		while(SZ(vec) && (vec.back() < vec[ptr] || ptr == 0)){
		//	res.push_back(vec.back());
			vec.pop_back();
		}
		if(SZ(vec)){
		//	res.push_back(vec.back());
			vec.pop_back();
		}
		/*int x = res.back();
		res.pop_back();
		res.push_back(x - 1);
		for(int i = 0 ; i < SZ(vec) ; i++)	res.push_back(9);
		//reverse(all(res));
		for(int i : res)	cout << i;
		cout << endl;
		cout << "=============" << endl;*/
		ans++;
		if(SZ(vec) == 0)	return cout << ans << endl , 0;
		int rem = 1;
		for(int i = 0 ; i < SZ(vec) ; i++){
			if(rem == 0)	break;
			vec[i] += rem;
			rem = vec[i] / 10;
			vec[i] %= 10;
		}
	}

    return 0;
}
/*

*/


Measured memory_bytes: 5924
def cmd():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [10000] * N
    DP[0] = 0

    if K > N:
        K = N

    for k in range(1,K):
        tmp = []
        for s in range(k):
            tmp.append(DP[s] + abs(h[k]-h[s]))
            DP[k] = min(tmp)

    for i in range(N-K):
        tmp = []
        for j in range(K):
            tmp.append(DP[i+j] + abs(h[i+K] - h[i+j]))
            DP[i+K] = min(tmp)
            
    print(DP[N-1])

if __name__ == "__main__":
    cmd()


Measured memory_bytes: 52832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<string> nvec(n);
  for (int i = 0; i < n; i++) {
    cin >> nvec[i];
  }
  
  int m;
  cin >> m;
  vector<string> mvec(m);
  for (int i = 0; i < m; i++) {
    cin >> mvec[i];
  }
  
  int ans = 0;

  for(int i = 0; i < nvec.size(); i++){
  	int count = 0;
    for(int j = 0; j < nvec.size(); j++){
    	if(nvec[i] == nvec[j]) count++;
    }
    for(int j = 0; j < mvec.size(); j++){
    	if(nvec[i] == mvec[j]) count--;
    }
    if(count > ans) ans = count;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const long long mod=1000*1000*1000+7;
const int zr=2001;
int C[2*zr+5][2*zr+5],dp[2*zr+5][2*zr+5],cat[2*zr+5][2*zr+5];
long long ans,inv2;
int n,i,j,a,b;
int main()
{
   // freopen("data.in","r",stdin);
    cin>>n;
    for(i=0;i<=2*zr;i++)
        C[i][0]=C[0][i]=1;
    for(i=1;i<=2*zr;i++)
        for(j=1;j<=2*zr;j++)
           C[i][j]=(C[i-1][j]+C[i][j-1])%mod;
    for(i=1;i<=n;i++)
    {
        cin>>a>>b;
        ans=(ans-C[2*a][2*b])%mod;
        cat[zr-a][zr-b]++;
        cat[zr+a][zr+b]++;
    }
    for(i=1;i<=2*zr;i++)
        for(j=1;j<=2*zr;j++)
    {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        if(i<zr&&j<zr) dp[i][j]=(dp[i][j]+cat[i][j])%mod;
        else ans=(1LL*ans+1LL*cat[i][j]*dp[i][j])%mod;
    }
    inv2=(mod+1)/2;
    ans=(1LL*ans*inv2)%mod;
    cout<<ans;
    return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    int n;
    cin >> n;

    REPN(i, 1, 10) {
        if(n % i == 0){
            if(1 <= n/i && n/i <= 9) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
class LoopString < Array
  def initialize(s)
    self.replace(s.chomp.split(''))
    @place = Hash.new {|h,k| h[k] = [] }
    self.each_with_index do |ch, idx|
      @place[ch] << idx
    end
    @place.default = nil
  end
  def index(ch, p1)
    return -1 unless @place[ch]
    p2 = p1 % self.length
    p3 = @place[ch].bsearch {|p4| p4 >= p2 }
    (p3 == nil) ? (p1 - p2 + self.length + @place[ch][0]) : (p1 - p2 + p3)
  end
  def bubun(t)
    t.chomp.split('').reduce(0) do |pos, ch|
      p2 = self.index(ch, pos)
      return -1 if p2 < 0
      p2 + 1
    end
  end
  def to_s
    @str
  end
end

puts LoopString.new(ARGF.gets).bubun(ARGF.gets)


Measured memory_bytes: 15292
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int A[3];
	for (int i = 0; i < 3; ++i)
	{
		cin>>A[i];
	}
	sort(A, A+3);
	if(A[0] == 5 && A[1] == 5 && A[2] == 7)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;

    vi a(n), b(n), c(n);
    fo(i,n) cin>>a[i]>>b[i]>>c[i];

    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 7920
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;cin >> s;
  sort(s.begin(),s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    long sum = 0;
    sort(v.begin(),v.end());
    for(int i=0;i<k;i++)
    {
        sum = sum+v[i];
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3664
import numpy as np

import math

n = int(input())

a = []

sum = 0

for i in range(n):
    a.append(np.array(list(map(int,input().split()))))

for i in range(n):
    for s in range(i,n):
        sum += np.linalg.norm(a[s] - a[i]) * math.factorial(n-1) * 2

print(sum/math.factorial(n))


Measured memory_bytes: 12588
import java.util.*;

public class Main {

	void run() {
		Scanner cin = new Scanner(System.in);
		int T = cin.nextInt();
		while (T-- > 0) {
			int[][] MAP = new int[5][5];
			for (int i = 0; i < 5; i++) {
				for (int j = 0; j < 5; j++) {
					MAP[i][j] = cin.nextInt();
				}
			}
			int ans = 0;
			for (int x1 = 0; x1 < 5; x1++) {
				for (int x2 = x1 + 1; x2 <= 5; x2++) {
					for (int y1 = 0; y1 < 5; y1++) {
						for (int y2 = y1 + 1; y2 <= 5; y2++) {
							Boolean check = true;
							for(int x=x1;x<x2;x++){
								for(int y=y1;y<y2;y++){
									if(MAP[x][y]==0)check=false;
								}
							}
							if(check){
								ans=Math.max(ans, (x2-x1)*(y2-y1));
							}
						}
					}
				}
			}
			System.out.println(ans);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδ?ソツッツドツ・ツスツタツブ
		new Main().run();
	}

}

Measured memory_bytes: 12000
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <vector> 
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 105;

bool vis[MAXN][MAXN][MAXN];

int a[MAXN];

bool check (int A, int B, int C) {
	if ((a[A] != a[B] && a[B] != a[C] && a[A] != a[C]) && (a[A] + a[B] > a[C]) && (a[A] + a[C] > a[B]) && (a[B] + a[C] > a[A])) return 1;
	else return 0;
}

int main () {
	int n, ans = 0;
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (check (i, j, k)) {
					//printf ("%d %d %d :    %d %d %d\n", i, j, k, a[i], a[j], a[k]);
					ans ++;
				}
			}
		}
	}
	printf ("%d", ans);
	return 0;
}

Measured memory_bytes: 3248
#include <iostream>
using namespace std;
int main(void){
    int i,a,b,n,m;
    cin>>n>>m;
    int ans[n];
    for(i=0;i<n;i++){
        ans[i]=0;
    }
    for(i=0;i<m;i++){
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }
    for(i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string W;
    cin >> W;
    string field;
    int ans = 0;
    while(true) {
        cin >> field;
        if(field == "END_OF_TEXT") break;
        transform(field.begin(), field.end(), field.begin(), ::tolower);
        if(field == W) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3204
from functools import *
from collections import *
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
 
M = 10**9+7

@lru_cache(maxsize=None)
def mod_inv(x):
  if x == 1:
    return 1
  return M // x * -mod_inv(M%x) % M

@lru_cache(maxsize=None)
def calc_subtree(v):
  ret = 1
  size = 1
  for child in Edge[v]:
    Edge[child].remove(v)
    r, s = calc_subtree(child)
    ret = ret * r % M
    size += s
  ret = ret * size % M
  return ret, size

ans = {}
def set_ans(v, a):
  ans[v] = a
  for child in Edge[v]:
    n = calc_subtree(child)[1]
    set_ans(child, ans[v] * n * mod_inv(N-n) % M)

N = int(input())
Edge = defaultdict(set)
fact = N
for i in range(1, N):
  fact = fact * i % M
  a, b = map(int, input().split())
  Edge[a].add(b)
  Edge[b].add(a)

set_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)
for i in range(1, N+1):
  print(ans[i])



Measured memory_bytes: 152288
#include<cstdio>
char s[15];
int main() {
    scanf("%s",s);
    int cnt=(s[0]=='R')||(s[1]=='R')||(s[2]=='R');
    for(register int i=1;i<3;++i) {
        if(s[i]==s[i-1]&&s[i]=='R') ++cnt;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	for(ll digit = 0; digit <= 60; digit++){
		ll c0 = 0, c1 = 0;
		for(int i = 0; i < n; i++){
			if(1LL & (a[i] >> digit)) c1++;
			else c0++;
		}
		ans += (((c0 * c1)%MOD) * ((1ll << digit)%MOD));
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5648
#include <stdio.h>
#include <stdlib.h>

void insert(int _value);
void delete(int _value);
void deleteFirst(void);
void deleteLast(void);

struct Node{

  struct Node* next;
  struct Node* prev;
  int value;

};

struct Node* head;
struct Node* tail;
main(){

  int i;
  int n;
  int tmpValue;
  char str[20];
  struct Node* node;

  head = (struct Node*)malloc(sizeof(struct Node));
  tail = (struct Node*)malloc(sizeof(struct Node));
  head->next = tail;
  head->prev = NULL;
  tail->next=NULL;
  tail->prev=head;
  head->value = 0;
  tail->value=0;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",str);
    if(!strcmp(str,"insert")){
      scanf("%d",&tmpValue);
      insert(tmpValue);
    }else if(!strcmp(str,"deleteFirst")){
      deleteFirst();
    }else if(!strcmp(str,"deleteLast")){
      deleteLast();
    }else if(!strcmp(str,"delete")){
      scanf("%d",&tmpValue);
      delete(tmpValue);
    }
  }

  for(node=head->next; node != tail; node=node->next){
    printf("%d",node->value);
    if(node->next!=tail){
      printf(" ");
    }
  }
  printf("\n");

  return 0;

}

void insert(int _value){

  struct Node* newNode;
  struct Node* tmpNode;

  newNode = (struct Node*)malloc(sizeof(struct Node));

  tmpNode = head->next;
  if(tmpNode != NULL){
    tmpNode->prev = newNode;
  }
  head->next = newNode;
  newNode->next = tmpNode;
  newNode->prev = head;

  newNode->value = _value;

}

void delete(int _value){

  struct Node* node;
  struct Node* tmpNode;
  for(node=head->next; node != NULL; node=node->next){
    if(node->value == _value){
      tmpNode = node->prev;
      if(tmpNode != NULL){
	tmpNode->next = node->next;
      }
      if(node->next != NULL){
	node->next->prev = tmpNode;
      }
      break;
    }
  }

}

void deleteFirst(){

  struct Node* node;
  node=head->next;

  if(head != NULL){
    head->next= node->next;
  }
  if(node->next != NULL){
    node->next->prev = head;
  }
  free(node);

}

void deleteLast(){

  struct Node* tmpNode;

  tmpNode=tail->prev;
  tail->prev=tmpNode->prev;
  tmpNode->prev->next=tail;

  free(tmpNode);

}

Measured memory_bytes: 15000
# 標準入力
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
data = []
for _ in range(m):
    data.append( list(map(int, input().split())) )

ans_list = [1 for _ in range(n)]

for d in data:
    # 初期化
    d_0 = d[0] - 1
    d_1 = d[1] - 1

    if h_list[d_0] == h_list[d_1]:
        ans_list[d_0] = 0
        ans_list[d_1] = 0

    if h_list[d_0] > h_list[d_1]:
        ans_list[d_1] = 0

    if h_list[d_1] > h_list[d_0]:
        ans_list[d_0] = 0

# print(*ans_list)
print(ans_list.count(1))


Measured memory_bytes: 31932
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int a, b;
    cin >> a >> b;
    int ans = (a > b) ? a-- : b--;
    ans += (a > b) ? a : b;
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int x[n], maxX = -1;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    if (x[i] > maxX) maxX = x[i];
  }

  int sum, minSum = INT_MAX;
  for (int i = 1; i <= maxX; i++) {
    sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (x[j] - i) * (x[j] - i);
    }
    if (sum < minSum) minSum = sum;
  }
  cout << minSum << endl;

  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++)

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

  double h_angle = 0, m_angle = 0, angle;
  h_angle += (double)h / 12 * 360;
  h_angle += (double)m / 60 * 30;
  m_angle += (double)m / 60 * 360;

  if (h_angle > m_angle) angle = h_angle - m_angle;
  else angle = m_angle - h_angle;

  if (angle > 180) angle = 360 - angle;

  double ans;
  ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle * M_PI / 180)));

  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4232
// ARC076 F Exhausted?

#include <bits/stdc++.h>
using namespace std;

// ******************************************************************
// Segment Tree with Lazy Propagation
// Increment modification on range, queries for maximum / minimum on range.
// ******************************************************************
template<typename T>
class SegTreeLazy{
    size_t n;
    int h;
    vector<T> data;
    vector<T> lazy;
    const T identity_element = -2e9;  // for max
    //const T identity_element = 2e9;  // for min
    static T combine(T L, T R){
        return max(L, R);
        // return min(L, R);
    }
    void apply(size_t i, T v){
        data[i] += v;
        if (i < n) lazy[i] += v;
    }
    void build(size_t i){      // update all the parents of node i.
        while (i > 1) i >>= 1, data[i] = combine(data[i*2], data[i*2+1]) + lazy[i];
    }
    void push(size_t p){       // propagates the changes from the root to node p.
        for (int s = h; s > 0; --s){
            size_t i = p >> s;
            if (lazy[i] != 0){
                apply(i*2, lazy[i]);
                apply(i*2+1, lazy[i]);
                lazy[i] = 0;
            }
        }
    }
    int calc_h(size_t nn){
        int hh = 1;
        for (; nn > 1; ++hh, nn >>= 1);
        return hh;
    }
public:
    SegTreeLazy(size_t _n): n(_n), h(calc_h(n)), data(vector<T>(2 * n, 0)), lazy(vector<T>(n, 0)){}
    SegTreeLazy(const vector<T> &src): n(src.size()), h(calc_h(n)), data(vector<T>(2 * n, 0)), lazy(vector<T>(n, 0)){
        for (int i = 0; i != n; ++i) data[n + i] = src[i];
        for (int i = n - 1; i != 0; --i) data[i] = combine(data[i*2], data[i*2+1]);
    }
    void inc(size_t L, size_t R, T v){  // add v to range [L, R)
        L += n;
        R += n;
        size_t L0 = L;
        size_t R0 = R;
        for (; L < R; L >>= 1, R >>= 1){
            if (L & 1) apply(L++, v);
            if (R & 1) apply(--R, v);
        }
        build(L0);
        build(R0 - 1);
    }
    T query(size_t L, size_t R){
        L += n;
        R += n;
        push(L);
        push(R - 1);
        T ret = identity_element;
        for (; L < R; L >>= 1, R >>= 1){
            if (L & 1) ret = combine(ret, data[L++]);
            if (R & 1) ret = combine(data[--R], ret);
        }
        return ret;
    }
};



int solve(int N, int M, const vector<vector<int>> & Rs){
    vector<int> initial_values(M + 2, 0);
    for (int i = 0; i <= M + 1; ++i) initial_values[i] = i - M - 1;
    SegTreeLazy<int> seg(initial_values);
    int ans = 0;
    for (int L = 0; L <= M; ++L){
        for (auto R : Rs[L]){
            seg.inc(0, R + 1, 1);
        }
        ans = max(ans, seg.query(0, M + 2) - L);
    }
    ans = max(ans, N - M);
    return ans;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<int>> Rs(M + 1, vector<int>());
    for (int i = 0; i != N; ++i) {
        int L, R;
        cin >> L >> R;
        Rs[L].push_back(R);
    }
    cout << solve(N, M, Rs) << endl;
    return 0;
}

Measured memory_bytes: 11648
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

// global parameters here:

void solve() {
	string num;
	cin >> num;
	FOR(i, 0, (int)num.length()-1) {
		if(num[i]==num[i+1]) {cout << "Bad" << endl; return;}
	}
	cout << "Good" << endl;
}

//#undef int
signed main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t; cin >> t;
//  while(t--)
//  {
//	  cout << aa << ", " << bb << endl;
		solve();
//  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


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

namespace PracticeOOP
{
    class Program
    {
        static void Main(string[] args)
        {
            string word1 = Console.ReadLine();
            string word2 = Console.ReadLine();

            if (Compare(word1, word2))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        public static bool Compare(string word1, string word2)
        {
            int length = word2.Length - 1;
       
            if (word1.Length == word2.Length)
            {
                for (int i = 0; i < word2.Length; i++)
                {
                    if (word1[i] == word2[length--])
                    {

                    }
                    else
                    {
                        return false;
                    }
                }
            }
            else
            {
                return false;
            }

            return true;
        }


    }//end program class


}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}

ll dp[100001][3], a[100001][3];
void solve()
{
  //code begins from here//
  ll n;
  cin>>n;
  lop(i,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
  dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
  lop1(i,n-1)
  {
      lop(j,3)
      {
          for(int k=0;k<3;k++)
          {
             if(k!=j) maxn(dp[i][j],dp[i-1][k]+a[i][j]);
          }
      }
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    if( n == m ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<long long>> dp(n+1,vector<long long>(n+1,0));
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j){
                dp[i][j] = a[i];
            }else{
                dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 70784
use proconio::input;
fn main() {
    input!(a: i32, b: i32);
    let mut temp_a = String::new();
    let mut temp_b = String::new();
    for _ in 0..b {
        temp_a.push_str(&a.to_string());
    }
    for _ in 0..a {
        temp_b.push_str(&b.to_string());
    }
    println!("{}", if temp_a < temp_b { temp_a } else { temp_b });
}

Measured memory_bytes: 2132
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[,] length = new long[n,n];
    long[,] cost = new long[n,n];
    for(int i = 0; i < n; i++)
    {
      for(int j = 0; j < n; j++)
      {
        cost[i,j] = long.MaxValue;
      }
    }
    for(int i = 0; i < n; i++)
    {
      length[i,i] = nums[i];
      cost[i,i] = 0;
    }

    for(int l = 2; l <= n; l++)//区間の長さ
    {
      for(int i = 0; i < n+1-l; i++)//左端
      {
        for(int j = 1; j < l; j++)//左側の区間の長さ
        {
          length[i,i+l-1] = length[i,i+j-1] + length[i+j,i+l-1];
          cost[i,i+l-1] = Math.Min(cost[i,i+l-1], cost[i,i+j-1] + cost[i+j,i+l-1] + length[i,i+l-1]);
          //Console.WriteLine(i+" "+(i+l-1)+" "+cost[i,i+l-1]);
        }
      }
    }
    
		Console.WriteLine(cost[0,n-1]);
	}
}

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

const int MAX = 1e7;
const int MOD = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int X,Y; cin >> X >> Y;
    if( (X+Y)%3!=0  || 2*X<Y  || 2*Y<X){
        cout << 0;
        return 0;
    }
    int a=(2*Y-X)/3;
    int b=(2*X-Y)/3;
    
    // 前処理
    COMinit();
    
    // 計算例
    cout << COM(a+b,a) << endl;
}

Measured memory_bytes: 234624
n=int(input())
ac=0
tle=0
wa=0
re=0
for i in range(n):
  a=input()
  if a=='AC':
    ac=ac+1
  elif a=='TLE':
    tle=tle+1
  elif a=='WA':
    wa=wa+1
  else:
    re=re+1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))

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

using namespace std;

#define rep(i,k,n) for(int i = k; i < n; i++)

int main(void){
    int n; cin >> n;
    int max = 0;
    int second_max = 0;
    vector<int> v(n);

    rep(i,0,n){
        cin >> v[i];
        if(max <= v[i]){
            second_max = max;
            max = v[i];
        }else if(second_max <= v[i]){
            second_max = v[i];
        }
    }

    rep(i,0,n){
        if(v[i] < max){
            cout << max <<endl;
        }else{
            cout << second_max << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    ll n,k;
    cin >> n >> k;
    ll res = min(n%k,abs(n%k-k));
    cout << res << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        sss: [Chars; 3]
    };
    println!(
        "{}",
        sss.iter()
            .map(|s| s[0].to_uppercase().to_string())
            .collect::<String>()
    );
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int h,w; cin>>h>>w;
string a[h];
rep(i,h) cin>>a[i];
map<int,bool> H,W;
rep(i,h){
    bool flag = true;
    rep(j,w){
        if(a[i][j] == '#') flag = false;
    }
    if(flag){
        H[i] = true;
    }
}
rep(i,w){
    bool flag = true;
    rep(j,h){
        if(a[j][i] == '#') flag = false;
    }
    if(flag){
        W[i] = true;
    }
}

rep(i,h){if(H[i]) continue;
    rep(j,w){
        if(W[j]) continue;
        cout<<a[i][j];
    }
    cout<<endl;
}

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << "\n";
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
char a[3];
int n=700;
int main()
{
  for(int i=0;i<3;i++)
    {
      cin>>a[i];
      if(a[i]=='o')
        n+=100; 
	}
  cout<<n;
  return 0;
}


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

int N;
int a[100];

signed main()
{
	cin >> N;
	rep(i,N) cin >> a[i];
	sort(a, a + N);

	int ans = 9999999999999;
	for (int i=a[0]; i<=a[N-1]; i++)
	{
		int temp = 0;
		for (int j=0; j<N; j++)
		{
			temp += pow(a[j] - i, 2);
		}
		ans = min(ans, temp);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
def d_partition(N, M):
    def divisor_list(n):
        # n の正の約数のリスト
        ret = []
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.append(k)
                if k != n // k:
                    ret.append(n // k)
        return sorted(ret)
    # N = 1なら、a_1 = M とする他なく、これがGCD
    return max([d for d in divisor_list(M) if d <= M // N]) if N >= 2 else M

N, M = [int(i) for i in input().split()]
print(d_partition(N, M))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3005, mod = 1e9 + 7;
int N, M, Right[maxn], s[maxn];
long long dp[maxn][maxn];
char str[maxn];
inline int S(int L, int R){return (s[R] - s[L - 1]);}

int main()
{
	scanf("%d%d", &N, &M);
	scanf("%s", str + 1);
	for(int i = 1; i <= N + 1; ++i) s[i] = s[i - 1] + (str[i] == '1');
	for(int i = 1; i <= N + 1; ++i) Right[i] = i;
	for(int L, R, i = 1; i <= M; ++i){
		scanf("%d%d", &L, &R);
		Right[L] = max(Right[L], R);
	}
	for(int i = 1; i <= N; ++i) Right[i] = max(Right[i], Right[i - 1]);
	dp[1][s[Right[1]]] = 1;
	for(int i = 1; i <= N; ++i)
		for(int j = 0; j <= N; ++j)
			if(dp[i][j]){
				int lin = S(Right[i] + 1, Right[i + 1]);
				int one = j, zero = Right[i] - (i - 1) - j;
				if(one) dp[i + 1][j - 1 + lin] = (dp[i + 1][j - 1 + lin] + dp[i][j]) % mod;  
				if(zero) dp[i + 1][j + lin] = (dp[i + 1][j + lin] + dp[i][j]) % mod;
			}
	cout << dp[N + 1][0];
	return 0;
}

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

using pii = pair<int, int>;
using ll = long long;

constexpr ll M = 1e9 + 7;

ll ten_pow[1024];
ll fact[256];
ll comb[256][256];

void init() {
    ten_pow[0] = 1;
    for(int i = 1; i < 1024; ++i) {
        ten_pow[i] = (ten_pow[i - 1] * 10) % M;
    }
    fact[0] = 1;
    for(int i = 1; i < 256; ++i) {
        fact[i] = (fact[i - 1] * i) % M;
    }
    for(int i = 0; i < 256; ++i) {
        for(int j = 0; j < 256; ++j) {
            if(i == j || j == 0) {
                comb[i][j] = 1;
            } else {
                comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % M;
            }
        }
    }
}

ll solve(vector<int> const& a, vector<int> const& d) {
    int const n = a.size();

    vector<vector<vector<ll>>> dp(5, vector<vector<ll>>(n, vector<ll>(n * 4 + 1)));
    ll res = 0;
    vector<ll> sum(5);
    for(int i = 0; i < n; ++i) {
        sum[d[i]] = (sum[d[i]] + a[i]) % M;
    }
    for(int i = 0; i < n; ++i) {
        if(dp[d[i]][0][0] == 0) {
            dp[d[i]][0][0] = 1;
            for(int j = 0; j < n; ++j) {
                if(i == j) {
                    continue;
                }
                for(int k = n - 1; k >= 0; --k) {
                    for(int l = 0; l < n * 4 + 1; ++l) {
                        if(dp[d[i]][k][l] == 0) {
                            continue;
                        }
                        dp[d[i]][k + 1][l + d[j]] = (dp[d[i]][k + 1][l + d[j]] + dp[d[i]][k][l] * (k + 1)) % M;
                    }
                }
            }
        }
    }
    for(int i = 1; i < 5; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < 4 * n + 1; ++k) {
                if(dp[i][j][k] == 0) {
                    continue;
                }
                for(int l = 0; l <= n - 1 - j; ++l) {
                    ll t = (sum[i] * dp[i][j][k]) % M;
                    t = (t * ten_pow[k]) % M;
                    t = (t * comb[n - 1 - j][l]) % M;
                    t = (t * fact[l]) % M;
                    res = (res + t) % M;
                }
            }
        }
    }

    return res;
}

int main() {
    init();

    int n;
    cin >> n;
    int zero_cnt = 0;
    vector<int> a(n);
    vector<int> d(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        d[i] = to_string(a[i]).size();
        zero_cnt += (a[i] == 0);
    }

    ll res = solve(a, d);
    if(zero_cnt != 0) {
        int idx = find(begin(a), end(a), 0) - begin(a);
        a.erase(a.begin() + idx);
        d.erase(d.begin() + idx);
        ll leading_zero = (zero_cnt * solve(a, d)) % M;
        res = (res - leading_zero + M) % M;
    }

    cout << res << endl;
}


Measured memory_bytes: 11156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<double> v(n);
  for(int i=0;i<n;i++)
    cin>>v.at(i);
  sort(v.begin(),v.end());
  double m=v.at(0);
  for(int i=1;i<n;i++)
    m=(m+v.at(i))/2;
  cout<<fixed<<setprecision(10)<<m<<endl;
}

Measured memory_bytes: 256
a = input()
b = int(a[:2])
c = int(a[2:])
if 1 <= b <= 12 and 1 <= c <= 12:
    print("AMBIGUOUS")
elif 1 <= b <= 12:
    print("MMYY")
elif 1 <= c <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		double T = sc.nextInt() + 0.5;

		int result = (int) (Math.floor(T / A) * B);

		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <bitset>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <random>
#include <cassert>

using namespace std;

//#define FAST_ALLOCATOR_MEMORY 1e8
#undef LOCAL
//#include "optimization.h"

bool ans = 0;
int order[12];
bool used[12];
int h, w;
bool bad;
vector<string> a(12);

void doit(int lvl, int pos) {
	if (ans)
		return;
	if (lvl == (w + 1) / 2) {
		int l = 0;
		vector<int> p(w);
		for (int i = 0; i < 12; i++) {
			if (order[i] == i)
				p[((w + 1) / 2) - 1] = i;
			if (order[i] > i) {
				p[l] = i;
				p[w - 1 - l] = order[i];
				l++;
			}
		}
		multiset<string> s;
		for (int i = 0; i < h; i++) {
			string nw = a[i];
			for (int j = 0; j < w; j++)
				nw[j] = a[i][p[j]];
			if (s.find(nw) != s.end())
				s.erase(s.find(nw));
			else {
				reverse(nw.begin(), nw.end());
				s.insert(nw);
			}
		}
		if (s.size() <= 1)
			ans = 1;
		return;
	}
	if (used[pos]) {
		doit(lvl, pos + 1);
		return;
	}
	if (bad) {
		order[pos] = pos;
		bad = 0;
		doit(lvl + 1, pos + 1);
		bad = 1;
	}
	for (int i = pos + 1; i < w; i++) {
		if (!used[i]) {
			used[i] = 1, used[pos] = 1;
			order[i] = pos, order[pos] = i;
			doit(lvl + 1, pos + 1);
			used[i] = 0, used[pos] = 0;
		}
	}

}

int main() {
	iostream::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> a[i];
	bad = w % 2 == 1;
	doit(0, 0);
	if (ans)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bitset>
#include <iostream>
using namespace std;
int main(){
    bitset<32> b;
    long long int n;
    cin>>n;
    b=n;
    cout<<b<<endl;
    b.flip();
    cout<<b<<endl;
    b.flip();
    cout<<(b<<1)<<endl;
    cout<<(b>>1)<<endl;
}


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

int main() {
    int N;
    int ans;
    cin >> N;  
    vector<int> vec(N);
    for(int i = 0;i < N;i++)
      cin >> vec[i];
    sort(vec.begin(), vec.end());
    int tmp = vec[0];
    for(int i = 0;i < N-1;i++){
       if(tmp != vec[i+1])
         ans++;
       tmp=vec[i+1];       
    }
    cout << ans+1 << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
  int n , k , count = 0; 
  cin >> n >> k ;
  vector<int> v (n) ;
  for (int i = 0 ; i < n ; i++)
  {
      cin >> v[i] ;
  }
 // sort(v.begin() , v.end());
  for (int i = 0 ; i < n; i ++)
  {
      if (v[i]>= k)
      count++ ;
  }
      cout <<count ;
}


Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<utility>

using namespace std;
using vi = vector<int>;
using ll = long long;
using P = pair<int, int>;
int main() {
	ll q[4];
	for (int i = 0; i < 4; i++) {
		cin >> q[i];
	}
	ll n;
	cin >> n;
	n *= 4;
	vector<P> V;
	V.push_back(P(q[0] * 8,0));
	V.push_back(P(q[1] * 4,1));
	V.push_back(P(q[2] * 2,2));
	V.push_back(P(q[3] * 1,3));
	sort(V.begin(), V.end());
	ll ans = 0;
	for (int i = 0; i < 4; i++) {
		int k = V[i].second;
		int size = 1 << k;
		ans += q[k] * (n / size);
		n = n%size;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


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

    ll ans = 0;
    ll digits = 1;
    for(int i = 0; i < 60; i++){
        ll zero = 0, one = 0;
        for(int j = 0; j < n; j++){
            int x = (a[j]>>i) & 1;
            if(x == 0) zero++;
            else one++;
        }
        ll cnt = zero * one;
        cnt %= MOD;
        cnt *= digits;
        cnt %= MOD;
        ans += cnt;
        ans %= MOD;

        digits *= 2L;
        digits %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;
bool graph[8][8];
 
const int NUMBER_OF_SAMPLES = 100000000;
int main(){
   int a;
   cin >> a;
   cout << a+a*a+a*a*a <<endl;
}


Measured memory_bytes: 3628