akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define mp 				make_pair
#define ff 				first
#define ss 				second
#define sz(x) 			(int)(x).size()
#define all(x) 			begin(x), end(x)
#define rall(x) 		(x).rbegin(), (x).rend() 
#define rsz 			resize
#define ins 			insert 
#define ft 				front() 
#define bk 				back()
#define pf 				push_front 
#define pb 				push_back
#define eb 				emplace_back 
#define lb 				lower_bound 
#define ub 				upper_bound 
#define w(x)			int x;cin>>x;while(x--)
#define pqmax			priority_queue<int>
#define pqmin			priority_queue<int,vector<int>,greater<int>>

#define rep(i,a,b) 		for (int i = (a); i < (b); ++i)
#define per(i,a,b) 		for (int i = (b)-1; i >= (a); --i)
#define trav(a,x) 		for (auto a: x)

#define setbits(x)  	__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

void solve(){

	int n;
	cin>>n;
	unordered_map<string,int> mp;
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<'\n';
	cout<<"WA x "<<mp["WA"]<<'\n';
	cout<<"TLE x "<<mp["TLE"]<<'\n';
	cout<<"RE x "<<mp["RE"]<<'\n';
	return;
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	

		solve();
	

	/*STUFF TO LOOK:	
	1. Special cases/corner cases(n==0||n==1)
	2. Variables in for loops
	3. Input ranges
	*/

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

int main(){
    int A,B,C,D;
    int N;
    cin >> N;
    A = N/1000;
    B = N/100 % 10;
    C = N/10 % 10;
    D = N % 10;

    bool op1,op2,op3;
    int sum;
    REP(i,8){
        sum = A;
        op1 = i & 1;
        op2 = (i >> 1) & 1;
        op3 = (i >> 2) & 1;
        sum = (op1) ? sum+B : sum-B;
        sum = (op2) ? sum+C : sum-C;
        sum = (op3) ? sum+D : sum-D;
        if(sum == 7)
            break;
    }
    string ans = "";
    ans += to_string(A);
    ans += (op1) ? "+" : "-";
    ans += to_string(B);
    ans += (op2) ? "+" : "-";
    ans += to_string(C);
    ans += (op3) ? "+" : "-";
    ans += to_string(D);
    ans += "=7";

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


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

int main()
{
    int a;
    cin >> a;
    set<int> s;
    s.insert(a);
    for(int i=1; i<= 1000000; i++){
        if(a%2 == 0){
            a = a/2;
        }else{
            a = 3*a + 1;
        } 
        if(s.count(a) == 1){
            cout << i+1 << endl;
            return 0;
        }else{
            s.insert(a);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	map<string,int> week;
	week["MON"] = 1; 
		week["TUE"] = 2; 	week["WED"] = 3; 	week["THU"] = 4; 	week["FRI"] = 5; 	week["SAT"] = 6;
			week["SUN"] = 0;  
	string s;
	cin >> s;
	cout << 7 - week[s];
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

#define mp make_pair
#define mt make_tuple
#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)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 ans(string s) {
    i64 res = 0;
    int len = 1;
    for1(i, s.size() - 1) {
        if (s[i] == s[i - 1]) ++len;
        else res += len / 2, len = 1;
    }
    return res + len / 2;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    string s;
    int k;
    cin >> s >> k;
    i64 res;
    if (s == string(s.size(), s[0])) res = 1LL * (i64)s.size() * k / 2;
    else if (k < 3) {
        string t;
        forn(i, k) t += s;
        res = ans(t);
    } else {
        i64 r1, r2;
        string t;
        forn(i, 2) t += s;
        r1 = ans(t);
        t += s;
        r2 = ans(t);
        res = r1 + (k - 2) * (r2 - r1);
    }
    cout << res << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

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

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

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

int main(){
	int n,i,j=0,l,a[111]={},mins=0,maxs=-111;
	string s;
	cin>>n>>s;
	FOR(i,0,n){
		if(s[i]=='('){
			//if(j<0)j=0;
			j++;
		}else{
			j--;
		}
		//cout<<j<<endl;
		//j+=a[i];
		if(mins>j)mins=j;
		//if(maxs<j)maxs=j;
	}
	//cout<<mins<<endl;
	FOR(i,0,-mins){
		s="("+s;
	}
	//cout<<"te"<<endl;
	j=0;
	l=s.length();
	FOR(i,0,l){
		if(s[i]=='('){
			j++;
		}else{
			j--;
		}
		//j+=a[i];
		//if(mins>j)mins=j;
	}
	FOR(i,0,j){
		s=s+")";
	}
	cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
#include <algorithm>
using namespace std;

int s[100005];
int ss[100005];

int main()
{
   	int n, m;
   	cin >> n >> m;
   	for (int i = 0; i < m; i++) {
   		cin>>s[i];	
	}
   	sort(s,s+m);
   	for (int i = 0; i < m-1; i++) {
   		ss[i] = s[i+1]-s[i];	
	}
   	sort(ss, ss+m-1);
   	long long sum = 0;
   	for (int i = 0; i < m-n; i++) {
   		sum += ss[i];	
	}
   	cout << sum;
   	
	return 0;
}


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

int main(){
    int d;
    std::cin >> d;
    std::vector<int> c(26);
    for(int i = 0; i < 26; i++){
        std::cin >> c[i];
    }
    std::vector<std::vector<int>> s(d, std::vector<int>(26));
    for(int j = 0; j < d; j++){
        for(int i = 0; i < 26; i++){
            std::cin >> s[j][i];
        }
    }
    std::vector<int> t(d);
    for(int j = 0; j < d; j++){
        std::cin >> t[j];
    }
    int m;
    std::cin >> m;
    std::vector<int> d_c(m);
    std::vector<int> q(m);
    for(int k = 0; k < m; k++){
        std::cin >> d_c[k];
        std::cin >> q[k];
    }

    std::vector<int> l(26);
    for(int i = 0; i < 26; i++){
        l[i] = 0;
    }

    int old = 0;

    int v;
    for(int k = 0; k < m; k++){
        v = 0;
        for(int i = 0; i < 26; i++){
            l[i] = 0;
        }
        old = t[d_c[k] - 1];
        t[d_c[k] - 1] = q[k];

        for(int j = 0; j < d; j++){
            for(int i = 0; i < 26; i++){
                if(i == t[j] - 1){
                    v = v + s[j][i];
                    l[i] = j + 1;
                }
                else{
                    v = v - c[i]*(j + 1 - l[i]);
                }
            }
        }
        std::cout << v << std::endl;
        // t[d_c[k] - 1] = old;
    }
}

Measured memory_bytes: 3980
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

ll mod = 1e9+7,a,k,sq;
vec<pll> bl;

void split(){
    for(int q=1; q<=sq; q++) bl.pb({q,q});
    for(ll q = sq+1; q<=a;){
        ll n = a/q, r = a/n;
        bl.pb({q,r});
        q = bl.back().S+1;
    }
}

int numbl(ll n){
    int l = 0, r = sq;
    for(; ;){
        int md = (l+r)/2;
        if(bl[md].S==n) return md;
        if(bl[md].S<n) l = md;
        else r = md;
    }
}

int main() {
    fast;
    cin>>a>>k;
    sq = sqrt(a);
    split();
    sq = bl.size();
    vec<ll> dp(sq), pr(sq);
    for(int q=0; q<sq; q++){
        dp[q] = bl[q].S-bl[q].F+1;
        pr[q] = dp[q] + (q ? pr[q-1] : 0);
    }
    for(int g=1; g<k; g++){
        for(int q=0; q<sq; q++){
            ll mx = a/bl[q].F;
            dp[q] = pr[numbl(mx)]*(bl[q].S-bl[q].F+1);
        }
        for(int q=0; q<sq; q++) pr[q] = dp[q]+(q ? pr[q-1] : 0), pr[q]%=mod;
    }
    cout<<pr[sq-1];
}

Measured memory_bytes: 2292
/**
 * PrintChessboard.cpp
 * Create:20180420
 * Description:複数のH,Wのリストを読み込み、
 * その分の四角形を表示する。
 * 四角形は一辺を"#"で表す。
 */
#include <iostream>
#include <vector>

/**
 * チェス盤クラス
 * @param height 高さ
 * @param width  幅
 */
class Chessboard {
private:
  int width;
  int height;
public:
  /**
   * コンストラクタ
   * @param width  横幅
   * @param height 縦幅
   */
  Chessboard(int height, int width){
    this->width = width;
    this->height = height;
  }

  /**
   * 描写
   */
  void draw(){
    for(int i = 0; i < height; i++) {
      if (i % 2 == 0){
        for (int j = 0; j < width; j++) {
          if (j % 2 == 0){
            std::cout << "#";
          } else {
            std::cout << ".";
          }
        }
      } else {
        for (int j = 0; j < width; j++) {
          if (j % 2 == 0){
            std::cout << ".";
          } else {
            std::cout << "#";
          }
        }
      }
      std::cout << std::endl;
    }
  }
};

int main(int argc, char* argv[]){
  std::vector<Chessboard> vec;
  int h, w;

  while (true){
    std::cin >> h >> w;
    if (h == 0 && w == 0)
      break;
    Chessboard c = Chessboard(h, w);
    vec.push_back(c);
  }

  for(Chessboard c: vec){
    c.draw();
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int A,B;
    cin>> A>> B;
    int sum,time,sa;
    sum = A+B;
    time = A*B;
    sa = A-B;
    int ans = max(sum,time);
    ans = max(ans,sa);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

bool isPrefix(const string& a, const string &b){
    if(a.size() <= b.size()){
        rep(i, a.size()){
            if(a[i] == b[i]) continue;
            else return false;
        }
    } else {
        return false;
    }
    return true;
}

bool solve(int n){
    vector<string> v(n);
    int G[26][26] = {};
    rep(i, n) cin >> v[i];
    loop(i, 1, n){
        if(isPrefix(v[i - 1], v[i])){
            continue;
        } else if(isPrefix(v[i], v[i - 1])){
            return false;
        } else {
            rep(j, min(v[i].size(), v[i - 1].size())){
                char a = v[i][j], b = v[i - 1][j];
                if(a == b){
                    continue;
                } else {
                    G[a - 'a'][b - 'a'] = true;
                    break;
                }
            }
        }
    }
    rep(k, 26) rep(i, 26) rep(j, 26){
        G[i][j] |= G[i][k] && G[k][j];
    }
    
    rep(i, 26){
        if(G[i][i])	return false;
    }
    return true;
}

int main(){
    int n;
    while(cin >> n, n){
        if(solve(n)){
            cout << "yes";
        } else {
            cout << "no";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1236
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a,b;
    scan(a,b);
    if(a*b%2)
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }
}

Measured memory_bytes: 256
s = input()
l = len(s)
h = l // 2
lis1 = []
lis2 = []
for i in range(0, h):
  lis1.append(s[i])
  lis2.append(s[-(i + 1)])
count = 0
for a, b in zip(lis1, lis2):
  if a != b:
    count += 1
print(count)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,D;
ll Q;
ll X[505050];
ll L[505050];
int QQ[505050];
ll NG[501010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>D;
	L[0]=D;
	FOR(i,N) {
		cin>>X[i];
		L[i+1]=min(L[i],abs(L[i]-X[i]));
	}
	
	cin>>Q;
	FOR(i,Q) cin>>QQ[i];
	
	NG[N]=1;
	for(i=N-1;i>=0;i--) {
		if(NG[i+1]<=X[i]/2) NG[i]=NG[i+1];
		else NG[i]=NG[i+1]+X[i];
	}
	
	FOR(i,Q) {
		x = QQ[i];
		if(L[x-1]==0 || NG[x]>L[x-1]) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main () {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  
  //要素数nの数列のうち、pが何番目に小さいのかを求める。
  vector<int> vec(0);
  rep(i, n) vec.push_back(i+1);
  
  map<vector<int>, int> mp;
  do {
    mp[vec] = mp.size();
  } while (next_permutation(vec.begin(), vec.end()));
  
    cout << max(mp[p] - mp[q], mp[q] - mp[p]) << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	a = max(a, c);
	b = min(b, d);
	printf("%d\n", max(0, b - a));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

p_1 = 0
p_2 = 0
p_3 = 0
p_inf = []
for i in range(n):
    p_1 += abs(x[i]-y[i])
    p_2 += abs(x[i]-y[i])**2
    p_3 += abs(x[i]-y[i])**3
    p_inf.append(abs(x[i]-y[i]))
print(format(float(p_1),".5f"))
print(format(float(p_2**(1/2)),".5f"))
print(format(float(p_3**(1/3)),".5f"))
print(format(float(max(p_inf)),".5f"))


Measured memory_bytes: 5648
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
 //   	freopen("input.txt", "r", stdin);
  //  	freopen("output.txt", "w", stdout);
//	#endif
	int n;
	cin>>n;
	vector<double> p(n);
	rep(i,n){
		cin>>p[i];
	}	
	double ans[n+1][n+1];
	rep(i,n+1)rep(j,n+1)ans[i][j] = 0;
	ans[1][1] = p[0];
	ans[1][0] = 1-p[0];
	repa(i,2,n+1){
		rep(j,i+1){
			if(j == 0){
				ans[i][0] = ans[i-1][0]*(1-p[i-1]);
			}
			// else if(j == n){
			// 	ans[i][n] = ans[i-1][n]*p[i-1];
			// }
			else{
				ans[i][j] = ans[i-1][j-1]*p[i-1];
				ans[i][j] += ans[i-1][j]*(1-p[i-1]);
			}
		}
	}
	// rep(i,n+1){
	// 	rep(j,n+1){
	// 		cout<<ans[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	double res = 0;
	int x = (n+1)/2;
	repa(i,x,n+1){
		res += ans[n][i];
	}	
	cout<<fixed<<setprecision(15)<<res;
	return 0;
}

Measured memory_bytes: 70656
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  cout << s.at(0) << s.size()-2<< s.at(s.size()-1) << endl;
}

Measured memory_bytes: 3608
a = list(map(int, input().split()))
f1 = False
f2 = False
f3 = False

if a[0] == a[1]:
    if a[0] != a[2]:
        f1 = True

if a[0] == a[2]:
    if a[0] != a[1]:
        f2 = True

if a[1] == a[2]:
    if a[0] != a[1]:
        f3 = True


if f1 == True or f2 == True or f3 == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, k=0;
    double meow=0;
    cin>>n>>m;
    int ara[n];
    for(int i=0; i<n; i++) {
        cin>>ara[i];
        meow+=ara[i];
    }
    meow=((double)meow/(4.0*m));
    for(int i=0; i<n; i++) {
        if(ara[i]>=meow) k++;
    }
    if(k>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
from math import factorial
MOD = 10**9 + 7

n = int(input())
s = input()
a = [0] * (n * 2)
for i in range(n*2):
    if s[i] == "B":
        a[i] = 1
        
prevbit = 0
prevlr = 0
lr = [0] * (n*2)
for i in range(n*2):
    if a[i] != prevbit:
        lr[i] = prevlr
    else:
        lr[i] = (prevlr + 1) % 2
    prevlr = lr[i]
    prevbit = a[i]
    
#print(lr)
    
ans = 1
if sum(lr) != n:
    ans = 0
else:
    suml = 0
    for i in range(n*2):
        if lr[i] == 1:
            ans = (ans * suml) % MOD
            suml -= 1
            if suml < 0:
                ans = 0
                break
        else:
            suml += 1
            
print((ans*factorial(n))%MOD)

Measured memory_bytes: 7528
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main() {
  long A, B;
  cin >> A;
  cin >> B;
  if (A < B) {
    swap(A, B);
  }
  long r;
  r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }
  long b;
  b = (long)floor(sqrt(B));

  vector<long> possibles;
  for (long i = 2; i < b + 1; i++) {
    if (B % i == 0) {
      possibles.push_back(i);
      if (B != i) {
        possibles.push_back(B / i);
      }
      // cout << i << endl;
    }
  }
  // for (long i : possibles) {
  //   cout << i << " ";
  // }
  vector<long> prime;
sort(possibles.begin(),possibles.end());
  for (long i : possibles) {
    long flag = 1;
    for (long p : prime) {
      if (i % p == 0) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      prime.push_back(i);
    }
  }

  // for (long i : prime) {
  //   cout << i << " ";
  // }
  // vector<long> power;
  // for (long i : prime) {
  //   long C = B;
  //   long pow = 0;
  //   while (C > 0 && C % i == 0) {
  //     pow++;
  //     C = C / i;
  //   }
  //   power.push_back(pow);
  // }
  long result = 0;
  for (long i : prime) {
    // cout << i << endl;
    if (i > 0) {
      result += 1;
    }
  }
  // long ma = *max_element(power.begin(), power.end());
  // cout << ma << endl;
  // cout << result << endl;
  if (possibles.size() == 0 && B > 1) {
    result = 1;
  }
  cout << result + 1 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,0,4){
        if(s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    print(ans);
}


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

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

    if (b<a){
        tmp = a;
        a = b;
        b = tmp;
    }

    if (c<b){
        tmp = b;
        b = c;
        c = tmp;
    }

    if (b<a){
        tmp = a;
        a = b;
        b = tmp;
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<int,pi>
#define deb(x) cout<<#x<<"="<<x<<endl;
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int N = 1e6+7;
int ans,n,f[N],cnt[N],a[N];
int main()
{
    go;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[a[i]]++;
    }
    for(int i=1;i<N;i++)
        for(int j=i;j<N;j+=i)
        {
            cnt[j]+=f[i];
            if(cnt[j]>2)
                cnt[j]=2;
        }
    for(int i=0;i<n;i++)
        if(cnt[a[i]]==1)
            ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 12208
//他の人の提出は大体において天才的ということですか
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			if ((ll)A[i] * F[N - i - 1] > M) {
				kazu += max(0ll, A[i] - M / F[N - i - 1]);
				if (kazu > K) break;
			}
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);


	Would you please return 0;
}

Measured memory_bytes: 2688
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (n % 2 == 1)
	{
		println(0);
	}
	else
	{
		ull res = 0;
		for (ll i = 10; i <= n; i *= 5)
		{
			res += n / i;
		}

		println(res);
	}
}

Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())

lcd = n * m // gcd(n, m)
mod_s = lcd // n
mod_t = lcd // m
for i in range(n // mod_t):
  if s[i * mod_t] != t[i * mod_s]:
    print(-1)
    break
else:
  print(lcd)

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

int main()
{
	int h,w;
	int i,j,k,l;
	char c;
	char grid[2010][2010];
	int light_l[2010][2010];
	int light_u[2010][2010];
	int light_r[2010][2010];
	int light_d[2010][2010];
	int light_ans;
	
	int max=-1;
	
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)
	{
		scanf("%s",grid[i]);
	}
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(grid[i][j]=='.')grid[i][j]=0;
			else grid[i][j]=1;
		}
	}
	/*
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(grid[i][j]==1)printf("%c",'#');
			else printf("%c",'.');
		}
		printf("\n");
	}*/
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(grid[i][j]==1)
			{
				light_l[i][j]=0;
				light_u[i][j]=0;
			}
			else
			{
				if(j==0)light_l[i][j]=1;
				else light_l[i][j]=light_l[i][j-1]+1;
				if(i==0)light_u[i][j]=1;
				else light_u[i][j]=light_u[i-1][j]+1;
			}
			
			k=h-i-1; l=w-j-1;
			if(grid[k][l]==1)
			{
				light_r[k][l]=0;
				light_d[k][l]=0;
			}
			else
			{
				if(j==0)light_r[k][l]=1;
				else light_r[k][l]=light_r[k][l+1]+1;
				if(i==0)light_d[k][l]=1;
				else light_d[k][l]=light_d[k+1][l]+1;
				
			}
		}
	}
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			k=h-i-1; l=w-j-1;
			light_ans=(light_l[i][j]+light_u[i][j]+light_r[i][j]+light_d[i][j]-3);
			//printf("%d %d :%d %d %d %d : %d\n",i,j,light_l[i][j],light_u[i][j],light_r[i][j],light_d[i][j],light_ans);
			if(max<light_ans)max=light_ans;
		}
	}
	
	
	
	printf("%d",max);
	
}


Measured memory_bytes: 67200
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    cout << min_element(A.begin(), A.end()) - A.begin() + 1 << endl;
    return 0;
}



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

struct vec
{
	int x, y;
	long long int z;
	char m;
	string n;
};

ostream& operator<<(ostream& s, const vec& v)
{
	s << v.x << " " << v.y << " " << v.m << " " << v.z << " " << v.n;
}

bool comp(const vec& v1, const vec& v2)
{
	if (v1.x == v2.x)
	{
		if (v1.y == v2.y)
		{
			if (v1.m == v2.m)
			{
				if (v1.z == v2.z)
				{
					return v1.n < v2.n;
				}
				else return v1.z < v2.z;
			}
			else return v1.m < v2.m;
		}
		else return  v1.y < v2.y;
	}
	else return v1.x < v2.x;

}

int main()
{
	int n, i;
	cin >> n;
	vec cpp[n];
	for (i = 0; i < n; i++)
		cin >> cpp[i].x >> cpp[i].y >> cpp[i].m >> cpp[i].z >> cpp[i].n;

	sort(cpp, cpp + n, comp);

	for (i = 0; i < n; i++)
		cout << cpp[i]<< endl;

	return 0;
}


Measured memory_bytes: 12380
import           Control.Monad (replicateM)
import           Data.List     (foldl')

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putStrLn $ solve s qs

data Query = Reverse | Add Bool Char

getQuery :: IO Query
getQuery = do
  (t:xs) <- words <$> getLine
  if t == "1"
    then return Reverse
    else let [f, c] = xs in return $ Add (f == "1") (head c)

solve :: String -> [Query] -> String
solve s qs = toList $ foldl' g (fromList s) qs
  where g xs Reverse   = rev xs
        g xs (Add f c) = add c f xs

data DoubleList a = DoubleList [a] [a] Bool
  deriving Show

fromList :: [a] -> DoubleList a
fromList xs = DoubleList xs [] True

toList :: DoubleList a -> [a]
toList (DoubleList xs ys True)  = xs ++ reverse ys
toList (DoubleList xs ys False) = ys ++ reverse xs

rev :: DoubleList a -> DoubleList a
rev (DoubleList xs ys f) = DoubleList xs ys $ not f

add :: a -> Bool -> DoubleList a -> DoubleList a
add x True (DoubleList xs ys True)   = DoubleList (x:xs) ys True
add x True (DoubleList xs ys False)  = DoubleList xs (x:ys) False
add x False (DoubleList xs ys True)  = DoubleList xs (x:ys) True
add x False (DoubleList xs ys False) = DoubleList (x:xs) ys False


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

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

int main() {
  int N;
  cin >> N;
  int A[N],B[N],C[N-1];
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N-1) cin >> C[i];
  
  int res = 0;
  int a = -2;
  int b;
  rep(i,N){
    b = A[i]-1;
    if (a+1==b)
      res += C[a];
    res += B[b];
    a = b;
  }
  cout << res << endl;
}

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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int ans = 0;
  if(A + B > C*2){
    int m = min(X,Y);
    ans += C*2*m;
    X -= m; Y -= m;

    if(A*X + B*Y > 2*X*C + 2*Y*C){
      ans += 2*X*C + 2*Y*C;
    } else {
      ans += A*X + B*Y;
    }
  } else {
    ans += A*X + B*Y;
  }

  cout << ans << endl;
}


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

using namespace std;


int main(){
	int N;
	cin >> N;
	map<string,int> m;
	
	rep(i,N)
	{
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	long long ans=0;

	for(auto &p: m){
		int t = p.second;
		ans+=(long long)t*(t-1)/2;
	}
	cout << ans;
}

Measured memory_bytes: 11136
using System;
        using System.Linq;
        using System.Collections.Generic;

        public class Program
        {
            public static void Main(string[] args)
            {
              List<int> num = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

             Console.WriteLine(num[0] % 2 == 0 || num[1] % 2 == 0? "No" : "Yes");
            }
        }

Measured memory_bytes: 11220
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    readln;
    readln.split.to!(int[]).pipe!(ary =>
        readln.chomp.to!int.times!({
                int p, x;
                readf("%d %d\n", &p, &x);
                writeln(ary.sum-ary[p-1]+x);
        })
    );
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    "strings"
)

func main(){
    // 文字列を入力するけど、使わない
    stdin := bufio.NewScanner(os.Stdin)
    stdin.Scan()
    _ = stdin.Text()
    
    // 複数の文字列を入力する
    var elements string
    for stdin.Scan(){
        elements = stdin.Text()
    }
    
    // 数値の配列にする
    array := stringToIntArray(elements)
    
    // 挿入ソートする
    insertionSort(array)
}

/**
 * スペースで区切られた文字列を入力して、数値の配列を返す
 */
func stringToIntArray(input string) []int {
    // スペースで区切られた文字列を文字列の配列にする
    words := strings.Fields(input)
    
    var array []int
    for _, word := range words {
        // 文字列を数値に変換する
        value, _ := strconv.Atoi(word)
        
        // 数値を配列に入れる
        array = append(array, value)
    }
    
    return array
}

/**
 * 挿入ソートする
 */
func insertionSort(array []int) []int {
    for i := 1; i <= len(array)-1; i++ {
        // 配列を表示する
        printArray(array)
        
        // 挿入ソートする
        value := array[i]
        j := i - 1
        for j >= 0 && array[j] > value {
            array[j+1] = array[j]
            j--
        }
        array[j+1] = value
    }

    // 配列を表示する
    printArray(array)
    return array
}

/**
 * 配列を表示する
 */
func printArray(array []int) {
    for index, value := range array {
        fmt.Printf("%v", value)
        // 最後以外はスペース入れる
        if index != len(array) -1 {
            fmt.Printf(" ")
        }
    }
    fmt.Println("")
}







Measured memory_bytes: 1160
#include <stdio.h>


int main(int argc, char const *argv[])
{
    int n;
    scanf("%d", &n);
    int t[n];
    for(int i=0; i < n; i++){
        scanf("%d", &t[i]);
    }

    int sum1 = 0;
    for (int i=0; i < n; i++){
        sum1 += t[i];
    }

    int sum2 = 0;
    for (int i=0; i < n; i++){
        sum2 += t[i]*t[i];
    }

    printf("%d\n", (sum1 * sum1 - sum2) / 2);
    



    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  lint n,i,ans;ans=0;
  cin>>n;
  vint a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
    while(a[i]%2==0){
     a[i]=a[i]/2;ans++; 
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

//Watchin' TVA
public class Main{

	class R implements Comparable<R>{
		String name;
		int s, t;
		boolean u;
		public R(String n, int s, int t) {
			this.s = s;
			this.t = t;
			name = n;
		}
		boolean lap(R r){
			return s<=r.s&&r.s<s+30 || r.s<=s&&s<r.s+30;
		}
		public int compareTo(R o) {
			return t-o.t;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			R[] r = new R[n];
			Map<String, Integer> ref = new TreeMap<String, Integer>();
			for(int i=0;i<n;i++){
				String name = sc.next();
				ref.put(name, i);
				int k = sc.nextInt();
				int t = sc.nextInt();
				int s = k*2400 + t/100*60 + t%100;
				r[i] = new R(name, s, s+30);
			}
			int p = sc.nextInt();
			List<R> l = new ArrayList<R>();
			boolean f = true;
			while(p--!=0){
				R fav = r[ref.get(sc.next())];
				boolean ok = true;
				for(R v:l){
					if(v.lap(fav)){
						ok = false;
						break;
					}
				}
				if(ok){
					fav.u = true;
					l.add(fav);
				}
				else{
					f = false;
				}
			}
			if(!f){
				System.out.println(-1);continue;
			}
			Arrays.sort(r);
			for(R v:r){
				if(v.u)continue;
				boolean ok = true;
				for(R z:l){
					if(z.lap(v)){
						ok = false;break;
					}
				}
				if(ok){
					l.add(v);
				}
			}
			System.out.println(l.size());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// Union-Find {{{
// verified AOJ DSL_1_A
struct UF {
    vector<int> p;  // parent
    vector<int> r;  // rank

    UF(int n) {
        p.resize(n);
        r.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
            r[i] = 1;
        }
    }

    int find(int x) {
        if(x == p[x]){
            return x;
        }else{
            return p[x] = find(p[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(r[x] < r[y]){
            p[x] = y;
        }else{
            p[y] = x;
            if(r[x] == r[y]){
                r[x]++;
            }
        }
    }
}; // }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    int a[50], b[50];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }

    int ans = 0;

    for(int i=0;i<m;i++){
        UF uf(n);
        for(int j=0;j<m;j++){
            if(i != j){
                uf.unite(a[j], b[j]);
            }
        }
        bool flag = false;
        for(int j=0;j<n;j++){
            if(uf.find(0) != uf.find(j)){
                flag = true;
            }
        }
        if(flag) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();

        for(int i = 0; i < str.length(); i += 2){
            System.out.print(str.substring(i,i+1));
        }
        System.out.println();
	}
}

Measured memory_bytes: 29280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
static const bool DEBUG = true;
int main()
{
    ifstream fIn("input.txt");
    if (DEBUG)
    {
        if(fIn.is_open()) cin.rdbuf(fIn.rdbuf());
    }
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    int ans = 0;
    rep(i,n) for(int j = i + 1; j < n; ++j){
        ans += d[i] * d[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int solve( int, int );

int main( void )
{
	int n;

	std::cin >> n;

	std::cout << solve( n, 100000 ) << std::endl;

	return 0;
}

int solve( int n, int debt ){
	int tmp = (int)((( debt * 1.05 ) + 999 ) / 1000 );

	if( n == 1 ){
		return tmp * 1000;
	}

	return solve( n - 1, tmp * 1000 );
}

Measured memory_bytes: 1156
#include <iostream>
#include <queue>

using namespace std;

int main(){

    string s;
    int c;
    while(1){
        getline(cin,s);
        if(s == "0"){
            break;
        }
        int sum=0;
        int length = s.size();
        for(int i=0; i<length; i++){
           sum += s[i] - '0'; 
        }
        cout << sum << endl;        

    }

    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

ll dp[3010][3010];    // dp[i][j] i番目までで、時間の総和がjになる選び方のうち価値の最大
int pre[3010][3010];  // 復元用、それになる１手前、何を食べたか

// ====================================================================

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

int main() {
  ll n, t;
  cin >> n >> t;
  vector<ll> w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];

  for (int i = 0; i < 3010; i++)
    for (int j = 0; j < 3010; j++)
      pre[i][j] = -1;

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j <= t; j++) {
      if (dp[i + 1][j] < dp[i][j]) {
        dp[i + 1][j] = dp[i][j];
        pre[i + 1][j] = -1;
      }
      if (j + w[i] < 3010 && dp[i + 1][j + w[i]] < dp[i][j] + v[i]) {
        dp[i + 1][j + w[i]] = dp[i][j] + v[i];  // 食べた
        pre[i + 1][j + w[i]] = i;
      }
    }
  }

  ll ans = 0;
  ll mx = n, my;
  for (int i = 0; i < t; i++) {
    if (ans < dp[n][t]) {
      ans = dp[n][i];
      my = i;
    }
    ans = max(ans, dp[n][i]);
  }

  // 復元
  vector<int> tabe;  // 食べてないリスト
  for (int i = n; i > 0; i--) {
    // cout << i << " " << my << endl;
    if (pre[i][my] != -1) {  // 1つ前の品物を食べた
      // cout << pre[i][my] << "wotabeta" << endl;
      my -= w[pre[i][my]];
    } else {
      tabe.push_back(i - 1);
    }
  }

  sort(tabe.begin(), tabe.end());

  ll saigo = 0;
  for (int i = 0; i < tabe.size(); i++) {
    saigo = max(saigo, v[tabe[i]]);
  }
  cout << ans + saigo << endl;
}


Measured memory_bytes: 106240
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m; ll k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep(i, n) cin >> a[i+1];
    rep(i, m) cin >> b[i+1];

    rep(i, n) a[i+1] += a[i];
    rep(i, m) b[i+1] += b[i];

    int ans = 0;
    rep(i, n+1) {
        if (a[i] > k) continue;
        int d = upper_bound(b.begin(), b.end(), k - a[i]) - b.begin();
        chmax(ans, i+d-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6376
from itertools import permutations
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

cnt = 0
for l in permutations(range(1,n+1),n):
    cnt+=1
    if(l==p):
        a=cnt
    if(l==q):
        b=cnt
print(abs(a-b))


Measured memory_bytes: 3060
s_list=list(input())
count = 0
for i in range(len(s_list)):
    if i % 2 == 0:
        if s_list[i] == 'L':
            count += 1
    else:
        if s_list[i] == 'R':
            count += 1
if count == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940