akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <limits>
#include <queue>
using namespace std;


class FromSrc{
public:
    int dist_id;
    int length;

    FromSrc(int id, int length): dist_id(id), length(length){};

};

using adj_list = vector< list< FromSrc> >;

bool operator>(const FromSrc& p1, const FromSrc& p2){
    return p1.length > p2.length;
}

bool operator<(const FromSrc& p1, const FromSrc& p2){
    return p1.length < p2.length;
}

int int_max = numeric_limits<int>::max();


vector<int> dicstra(int V, int r, const adj_list& adj){

    vector<int> table(V, int_max);
    table[r] = 0;

    priority_queue<FromSrc, vector<FromSrc>, greater<> > Q;
    for(int i = 0; i < V; i++) Q.push(FromSrc(i, table[i]));


    while(!Q.empty()){
        auto next_path = Q.top(); Q.pop();

        int u = next_path.dist_id;
        int path_to_u = next_path.length;

        if( path_to_u > table[u]) continue;//over written element
        if (next_path.length == int_max) break; // lest are unreachable

        for(const auto& from_u: adj[u]){
            int w = from_u.dist_id;
            int new_path = path_to_u + from_u.length;
            if( new_path < table[w] ){
                table[w] = new_path;
                Q.push(FromSrc{w, new_path}); //virtually over write
            }
        }


    }

    return table;

}

int main(){
    int V,E,r; cin >> V >> E >> r;

    adj_list adj(V);


    for(int i = 0; i < E; i++){
        int s,t,d; cin >> s >> t >> d;
        adj[s].push_back(FromSrc{t,d});
    }

    vector<int> table = dicstra(V, r, adj );

    for(int i = 0; i < V; i++){
     int dist = table[i];
     if (dist == int_max){
         cout << "INF" << endl;
     }
     else{
         cout << dist << endl;
     }
    }

    return 0;
}



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k; cin >> n >> k;

    if (n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;
    
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

def main():
    for i in range(N-1,0,-1):
        if H[i-1] > H[i] + 1:
            print("No")
            return
        elif H[i-1] == H[i] + 1:
            H[i-1] -= 1
    print("Yes")
    return

if __name__ == "__main__":
    main()

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

vector<int64_t> make_divisors(int64_t n) {
    vector<int64_t> divisors;
    for (int64_t i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            divisors.push_back(i);
            if(i!=1 && i*i!=n)
				divisors.push_back(n/i);
        }
    }
    sort(divisors.begin(), divisors.end());
    if (n != 1) divisors.push_back(n);
    int div_size = divisors.size();
    return divisors;
}

int max_digit(string a, string b) {
    return max(a.size(), b.size());
}

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> divisors = make_divisors(n);
    int ds = divisors.size(); 
    int pairs = (ds+1) / 2; 
    int ans = 100;
    rep(i,pairs) {
        string a = to_string(divisors[i]);
        string b = to_string(divisors[ds-i-1]);
        int f = max_digit(a, b);
        ans = min(f, ans);
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    int maxa=0, ans=0;
    while (N--){
        int a, b;
        cin >> a >> b;
        if (a > maxa){
            maxa = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	int from,to;
};

int V,E;
int boss[55],height[55];
Edge edge[55];

int get_boss(int id){
	if(boss[id] == id)return id; //自分が代表なら、自分の値を返す
	else{
		return boss[id] = get_boss(boss[id]); //代表でないなら、自分が所属する組織の代表を返しつつ、経路圧縮
	}
}

int is_same(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	//既に同じグループなら何もしない
	if(boss_x == boss_y)return;

	//高さが高い方に吸収する
	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){

	for(int i = 0; i < V; i++){
		boss[i] = i;
		height[i] = 0;
	}
}

int main(){

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

	for(int i = 0; i < E; i++){

		scanf("%d %d",&edge[i].from,&edge[i].to);
		edge[i].from--;
		edge[i].to--;
	}

	int ans = 0,num_group;

	for(int i = 0; i < E; i++){

		init();

		for(int k = 0; k < E; k++){
			if(k == i)continue;

			unite(edge[k].from,edge[k].to);
		}

		num_group = 0;

		for(int k = 0; k < V; k++){
			if(k == get_boss(k)){
				num_group++;
			}
		}
		if(num_group != 1)ans++;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    int i,len,wordlen;
    char s[202];
    char t[202];
    char tt[404];
    char ttt[202];

    scanf("%s", &s);
    len=strlen(s);
    
    for(i=len-2; i>0; i=i-2){
        strcpy(tt,"");
        strcpy(t,"");
        strcpy(ttt,"");
        wordlen=i/2;
        strncpy( t, s, wordlen );
        t[wordlen]='\0';
        //printf("%s\n",t);
        strcat(tt,t);
        strcat(tt,t);
        
        //printf(" tt->%s\n", tt);
        
        strncpy( ttt, s, i );
        ttt[i]='\0';
        //printf("ttt->%s\n", ttt);
       // printf("i->%d\n",i);
        
        if(strcmp(tt,ttt)==0){
            printf("%d\n",i);
            break;
        }
        
        
    }
    
    
    
    return 0;
}

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

using static Input;
using static Util;
class Program
{
    static int[] N;
    static char[][] C;

    static void INPUT()
    {
        N = LineInt();
        C = new char[N[0]][];
        for (var i = 0; i < N[0]; i++)
        {
            C[i] = NextString().ToArray();
        }
    }
    static void OUT()
    {
        var dx = new int[] { -1, 0, 1, 0 };
        var dy = new int[] {  0,-1, 0, 1 };
        for (var h = 0; h < N[0]; h++)
            for (var w = 0; w < N[1]; w++)
            {
                if (C[h][w] == '#')
                {
                    var b = false;
                    for (var i = 0; i < 4; i++)
                    {
                        var nx = w + dx[i];
                        var ny = h + dy[i];
                        if (nx < 0 || N[1] <= nx) continue;
                        if (ny < 0 || N[0] <= ny) continue;

                        if (C[ny][nx] == '#') b = true;
                    }

                    if (!b)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
         
        Console.WriteLine("Yes");
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(f);
    rak.assign(f+1,1);
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ld kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,u;
//vvl v;
//vl vis,d;
pll c[1000005];
int main() {
    IOS;
    cin>>n;
    fo(i,n){
        ld f;
        cin>>f>>s;
        if(s=="JPY")kv+=f;
        else kv+=f*380000;
    }
    cout<<kv;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int f(int N, vector<vector<int>> &v){
  priority_queue<int> q;

  int ret = 0;
  RFOR(i, 1, N+1){
    for(int j : v[i]){
      q.emplace(j);
    }
    if(!q.empty()){
      ret += q.top(); q.pop();
    }
  }
  return ret;
}

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

  int ans = 0;
  vector<vector<int>> vl(N+1), vr(N+1);
  REP(i, N){
    int K, L, R;
    cin >> K >> L >> R;

    int MIN = min(L, R);
    ans += MIN;
    L -= MIN; R -= MIN;
    if(L > 0) vl[K].emplace_back(L);
    else vr[N-K].emplace_back(R);
  }
  ans += f(N, vl)+f(N, vr);
  cout << ans << "\n";
}

signed main() {
  int T; 
  cin >> T;

  REP(i, T){
    solve();
  }

  return 0;
}


Measured memory_bytes: 17388
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    long long n,ans=0;
    cin>>n;
    vector<int>p(1000000);
    int req,cnt;
    for(int i=2;i<1000000;i++){
        if(p[i]!=-1){
            req=1;
            cnt=0;
            for(int j=i*2;j<1000000;j+=i){
                p[j]=-1;
            }
            while(n%i==0){
                cnt++;
                if(cnt==req){
                    cnt=0;
                    req++;
                    ans++;
                }
                n/=i;
            }
        }
    }
    if(n>1)ans++;
    cout<<ans;
	return 0;
}


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

using namespace std;

const long long mod = 1e9 + 7;

int a[1 << 18], c[3];
int n;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    
    long long ans = 1;
    for (int i = 1; i <= n; i++) {
        long long cnt = 0, id = -1;
        if (a[i] == c[0]) {
            cnt++; id = 0;
        }
        if (a[i] == c[1]) {
            cnt++; id = 1;
        }
        if (a[i] == c[2]) {
            cnt++; id = 2;
        }

        if (id == -1) {
            cout << "0\n";
            return 0;
        }
        ans *= cnt; c[id]++;
        ans %= mod;
    }

    cout << ans << '\n';
}

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

int main(){
    ll a; cin >> a;
    put(ll(pow(a,2) + pow(a,3) + a));
}

Measured memory_bytes: 4100
n = int(input())
ans = 0

l = [[0 for i in range(10)] for j in range(10)]

for i in range(1, n+1):
    s = str(i)
    b = int(s[0])
    e = int(s[-1])
    l[b][e] += 1

for b in range(10):
    for e in range(10):
        ans += l[b][e] * l[e][b]
        # if a[b][e] * a[e][b] > 0:
    # print(b, e, l[b][e], l[e][b])

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#define fi first
#define se second
using namespace std;
const int maxn = 1e5 + 100;
typedef long long LL;
typedef pair<int, long long> PLI;
typedef pair<int, int> PII;
vector<PLI> G[maxn];
set<PII> S;
int son[maxn], sz[maxn];
int tree[maxn*4];
int n, tot;
LL ANS = 0, Min = 1e18;
void dfs0(int x, int fa){
    sz[x] = 1;
    for(auto e : G[x]){
        if(e.fi == fa) continue;
        dfs0(e.fi, x);
        sz[x] += sz[e.fi];
        son[x] = max(son[x], sz[e.fi]);
    }
    son[x] = max(son[x], n - sz[x]);
}

void dfs(int x, int fa, LL v){
    sz[x] = 1;
    for(auto e : G[x]){
        if(e.fi == fa) continue;
        dfs(e.fi, x, e.se+v);
        sz[x] += sz[e.fi];
    }
    ANS += v;
}

int main()
{
    cin>>n;
    for(int i = 1; i < n; i++){
        int x, y, w;
        cin>>x>>y>>w;
        G[x].push_back({y, w});
        G[y].push_back({x, w});
    }
    int X;
    dfs0(1, 1);
    for(int i = 1; i <= n; i++) if(son[i] <= n/2) X = i;
    dfs(X, X, 0);
    for(auto e : G[X]){
        if(sz[e.fi] == (n+1)/2) { Min = e.se; break; }
        Min = min(e.se, Min);
    }
    cout<<ANS*2 - Min<<endl;
}

Measured memory_bytes: 13952
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}
int ctoi(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 0;
}

char a[100][100], b[100][100];



int main(void) {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int left = a + b;
	int right = c + d;
	if (left > right)cout << "Left" << endl;
	else if (left == right)cout << "Balanced" << endl;
	else cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 171C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC  9(16) COMP.
01 M          PIC  9(16) COMP.
01 AMR        PIC  9(02) COMP.
01 ALPHA      PIC  X(26) VALUE 'abcdefghijklmnopqrstuvwxyz'.
01 I          PIC  9(04) COMP.
01 OUT        PIC  X(12).
*> 
PROCEDURE DIVISION.                          
  ACCEPT N.
*>
  MOVE SPACE TO OUT.
  MOVE N     TO M.
  PERFORM VARYING I FROM 12 BY -1 UNTIL M = 0
    COMPUTE M = M - 1
    DIVIDE M BY 26 GIVING M REMAINDER AMR
    ADD 1 TO AMR
    MOVE ALPHA(AMR:1) TO OUT(I:1)
  END-PERFORM
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3940
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h> 
 
using namespace std;
 
 
#define         ll                         long  long
#define         lf                         double 
#define         pb(x)                      push_back(x)
#define         ull                        unsigned long long
#define         sfl(a)                     scanf("%lld",&a)
#define         sf(a)                      scanf("%d",&a)
#define         pf(a)                      printf("%d\n",a)
#define         pfl(a)                     printf("%lld\n",a)
#define         pdl(a)                     printf("%llf\n",a)
#define         FOR(x,n)                   for(ll x=1;x<=n;++x)
#define         vii                        vector< ll > v
#define         pi                         3.14159265359
#define         mex                        10000000
#define         pii                        pair< ll , ll >
#define         mem(m,a)                   memset( m, a,sizeof m)
#define         mp(a,b)                    make_pair(a,b)
#define         maxn                       100000
#define         mod                        1000000007
#define         INF                        1e17
#define         f1                         first
#define         f2                         second
#define         all(v)                     v.begin(),v.end()
#define         PI                         acos(-1)
#define         printminusone              printf("-1\n")
#define         bug                        printf("bug")

vector<ll>v;


int main(){
    ll n;
    sfl(n);
    cout << (n*(n-1))/2 << endl;    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
	int n,x=0,y=0,i,z;
    char s1[100],s2[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",s1,s2);
		z=strcmp(s1,s2);
		if(z==0){x+=1;y+=1;}
		if(z>0)x+=3;
		if(z<0)y+=3;
	}
	printf("%d %d\n",x,y);
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char in[105];
int main(){
	int l;
	while(~getI(l)){
		scanf("%s",in);
		int r=0,b=0;
		F(i,0,l){
			if(in[i]=='R') r++;
			else b++;
		}
		printf("%s\n",r>b?"Yes":"No");
	}
}


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

int main() {
    string w;
    cin >> w;
    bool flg = true;
    for (int i = 0; i < w.size(); i++) {
        if (count(w.begin(), w.end(), w[i]) % 2 != 0) {
            flg = false;
        }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,m2,i,j,fa[200005][2],x,y;
map<pair<int,int>,int> mp;
int find(int x,int y)
{
	if (fa[x][y]==x) return x;
	return fa[x][y]=find(fa[x][y],y);
}
int main()
{
	cin>>n>>m>>m2;
	for (i=1;i<=n;i++)
	{
		for (j=0;j<=1;j++) fa[i][j]=i;
	}
	for (i=1;i<=m;i++)
	{
		cin>>x>>y;
		if (find(x,0)!=find(y,0))
		{
			fa[find(x,0)][0]=find(y,0);
		}
	}
	for (i=1;i<=m2;i++)
	{
		cin>>x>>y;
		if (find(x,1)!=find(y,1))
		{
			fa[find(x,1)][1]=find(y,1);
		}
	}
	for (i=1;i<=n;i++)
	{
		find(i,0);find(i,1);
		mp[make_pair(fa[i][0],fa[i][1])]++;
	}
	for (i=1;i<=n;i++)
	{
		cout<<mp[make_pair(fa[i][0],fa[i][1])]<<' ';
	}
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	int n;
	cin >>n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	ll dp[100100];
	rep(i,n){
		dp[i] = INF;
	}
	dp[0] = 0;
	rep(i,n){
		chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
		chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
	}
	cout << dp[n-1]<<endl;


}


Measured memory_bytes: 1408
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    string s1,s2;
    cin >>s1>>s2;

    if(s1.length()+1!=s2.length()) {
        cout<<"No";
        return 0;
    }
    for(int i = 0; i < s1.length(); i++) {
        if(s1[i]!=s2[i]) {
            cout<<"No";
            return 0;
        }
    }
    cout<< "Yes";


    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int N,M;
int P[MAXN],Y[MAXN];
map<int,vector<int> > A;
map<int,int> Rank;
int main()
{
	scanf("%d%d",&N,&M); 
	for(int i=1;i<=M;i++)
	{
		scanf("%d%d",P+i,Y+i);
		A[P[i]].push_back(Y[i]);
	}
	for(map<int,vector<int> >::iterator it=A.begin();it!=A.end();it++)
	{
		sort(it->second.begin(),it->second.end());
		for(int i=0;i<it->second.size();i++) Rank[it->second[i]]=i+1;
	}
	for(int i=1;i<=M;i++) printf("%06d%06d\n",P[i],Rank[Y[i]]);
	return 0;
}

Measured memory_bytes: 17920
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;

const int N = int(5e5)+10;
const int K = int(2e6)+10;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 2e18;

// const ll MOD = 1e9 + 7;
// inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
// inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll a[N];
map<ll,int> mp;

void solve () {
    int n;cin>>n;
    ll curr = 0;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        curr += a[i];
        mp[a[i]]++;
    }
    int q;cin>>q;
    while (q--) {
        ll b,c;cin>>b>>c;
        curr += (c-b) * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout<<curr<<endl;
    }
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

#define NMAX 100000

int partition (int *,int,int);
int n;

int main (void)
{
  int *a,p,q,r,i;

  //input n
  scanf ("%d",&n);

  //ヒープメモリ確保
  a = malloc(sizeof(int) * NMAX);

  //input a[i]
  for (i = 0 ; i < n ; i++){
    scanf ("%d",&a[i]);
  }

  p = 0;
  r = n - 1;

  //partition関数へ移動
  q = partition (a,p,r);

  //output
  for (i = 0 ; i < n ; i++){
    if (i != q)
      printf ("%d",a[i]);
    else if (i == q)
      printf ("[%d]",a[i]);
    if (i < n - 1)
      printf (" ");
    else
      printf ("\n");
  }

  //ヒープメモリ解放
  free(a);

  return 0;
}

int partition (int *a,int p,int r)
{
  int i,j,x,m,n;

  x = a[r];
  i = p - 1;

  for (j = p ; j < r ; j++){
    if (a[j] <= x){
      i = i + 1;
      //a[i]とa[j]を交換
      m = a[i];
      n = a[j];
      a[i] = n;
      a[j] = m;
    }
  }

  //a[i+1]とa[r]を交換
  m = a[i + 1];
  n = a[r];
  a[i + 1] = n;
  a[r] = m;

  return i + 1;
}

Measured memory_bytes: 888
n,p = map(int,input().split())
a = list(map(int,input().split()))
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

g = 0
k=0
for i in a:
    if i%2:
        k+=1
    else:
        g+=1
if p == 0:
    x = 2**g - 1
    y = 0
    for i in range(2,k+1,2):
        y += cmb(k,i)
    ans = y*x + x + y +1
    print(ans)
else:
    x = 2**g-1
    y = 0
    for i in range(1,k+1,2):
        y += cmb(k,i)
    print(y*x+y)


Measured memory_bytes: 38512
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)

using namespace std;

ll n, m;

int main()
{
	cin >> n >> m;
	
	if (n-2 > 0 && m-2 > 0) {
		ll k = (n-2)*(m-2);
		cout << k << "\n";
		return 0;
	}
	
	if (n == 1 && m == 1) {
		cout << 1;
		return 0;
	}
	
	if (n == 1 || m == 1) {
		cout << max(n, m)-2;
		return 0;
	}
	
	if (n == 2 || m == 2) {
		cout << 0;
		return 0;
	}
}


Measured memory_bytes: 256
#include <iostream>    // cin, cout
#include <string>    // string, stoi, to_string
#include <algorithm>    // sort, lower_bound, heap, min, next_permutation 
#include <functional>    // greater, less
#include <vector>    // vector
#include <stack>    // stack
#include <queue>    // queue
#include <list>    // list
#include <map>    // map
#include <set>    // set
#include <tuple>    // tuple
#include <bitset>    // bitset
#include <cstdio>  // fopen, printf, scanf, puts
#include <cmath>    // sin, exp, log, pow, sqrt
#include <iomanip>    // setfill, setbase
#include <ctime>    // clock

using namespace std;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30));
const long long linf = (1LL<<60);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long ans = 1;
    bool ok = true;
    long long A[n];
    for(int i=0; i<n; i++) cin >> A[i];
    sort(A, A+n);
    for(int i=0; i<n; i++)
    {
        if(A[i] == 0)
        {
            ans = 0;
            break;
        }
        else if(ans <= 1000000000000000000/A[i])
        {
            ans *= A[i];
        }
        else
        {
            ok = false;
            break;
        }
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 4436
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, k; cin >> n >> k;
  vll a(n); REP(i, n) cin >> a[i];
  vll asum(n+2, 0), bsum(n+2, 0);
  REP(i, n) {
    asum[i+1] = asum[i] + a[i];
    bsum[i+1] = bsum[i] + max(0LL, a[i]);
  }
  asum[n+1] = asum[n], bsum[n+1] = bsum[n];
  ll ans = 0;
  REP(i, n-k+2) {
    ll bs = bsum[n+1] - (bsum[i+k] - bsum[i]);
    chmax(ans, bs);
    ll ba = bs + asum[i+k] - asum[i];
    chmax(ans, ba);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int s;
  cin >> s;
  unordered_set<ll> us;
  us.emplace(s);
  ll ans = 0;
  for (ll i = 2; i <= 1000000; ++i) {
    if (s % 2 == 0) {
      s = s / 2;
      if (us.find(s) == us.end()) {
        us.emplace(s);
      } else {
        ans = i;
        break;
      }
    } else {
      s = 3 * s + 1;
      if (us.find(s) == us.end()) {
        us.emplace(s);
      } else {
        ans = i;
        break;
      }
    }
  }

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


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use num::Float;
use proconio::input;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap};
use std::io::*;
use std::str::FromStr;
// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn switch<T>(flag: bool, t: T, f: T) -> T {
    if flag {
        t
    } else {
        f
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let text: String = read();
    println!("{}", &text[0..3]);
}


Measured memory_bytes: 2120
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long int n;
   cin>>n;
   pair<long int,long int> a[n];
   for(long int i=0;i<n;i++)
   {
   cin>>a[i].second>>a[i].first;
   }
   sort(a,a+n);
   long int temp=0;
   long long int r=a[0].second;
   //cout<<r<<endl;
   for(long int i=0;i<n;i++)
   {
       if(a[i].first>=r)
       {
           if(i<n-1)
           r+=a[i+1].second;
       }
       else
       {
           temp=1;
           break ;
       }
   }
   if(temp)
   cout<<"No"<<endl;
   else
   cout<<"Yes"<<endl;
}

Measured memory_bytes: 3328
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    int p[51];
    FOR(i,1,N)R(p[i]);
    int cnt=0;
    FOR(i,1,N){
        if(p[i]!=i)cnt++;
    }
    W(cnt<=2?"YES":"NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    char S, T; cin >> S >> T;
    if(S < T) cout << '<' << endl;
    else if(S == T) cout << '=' << endl;
    else cout << '>' << endl;

}


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

int main(){
    int n;
    cin >> n;
    map<int, int> memo;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(memo.count(a)) memo.erase(a);
        else memo[a] = 1;
    }

    cout << memo.size() << endl;
    return 0;
}

Measured memory_bytes: 8052
import math
def solve():
  s = input()
  n = len(s)
  ans = [0]*n
  R = 0
  lastr = 0
  L = 0
  for i in range(n-1):
    if s[i+1] == "R" and s[i] == "R":
      R += 1
    elif s[i] == "R" and s[i+1] =="L":
      R += 1
      ans[i] += math.ceil(R/2)
      ans[i+1] += R-math.ceil(R/2)
      lastr = i
      R = 0
    if s[i] =="L" and s[i+1] == "L":
      L += 1
    elif s[i] == "L" and s[i+1] == "R":
      L += 1
      ans[lastr+1] += math.ceil(L/2)
      ans[lastr] += L-math.ceil(L/2)
      L = 0
    if i == n-2:
      L += 1
      ans[lastr+1] += math.ceil(L/2)
      ans[lastr] += L-math.ceil(L/2)
  print(*ans)
      

solve()

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for(char c: s) {
        if (c == 'R')
            cnt += 1;
    }
    if (cnt != 2) {
        cout << cnt << endl;
    } else {        
        if (s == "RSR")
            cnt -= 1;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] heights = new int[N];
        for (int i = 0; i < N; i++) {
            heights[i] = sc.nextInt();
        }

        int[] cost = new int[N];
        cost[0] = 0;
        cost[1] = Math.abs(heights[1] - heights[0]);
        for (int i = 2; i < N; i++) {
            cost[i] = Math.min(cost[i - 1] + Math.abs(heights[i] - heights[i - 1]), cost[i - 2] + Math.abs(heights[i - 2] - heights[i]));
        }

        System.out.println(cost[N - 1]);
    }
}

Measured memory_bytes: 50044
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  int i,j,cnt=0;
  int m1,d1,m2,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  if(d2==1)cout<<"1";
  else cout<<"0";
}

Measured memory_bytes: 256
from sys import stdin
from itertools import accumulate
from itertools import groupby
import itertools

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

lin = list(accumulate(li)) 

ma = sum(li)
sa = 10**10
for i in range(n):
    hidari = lin[i]
    migi = ma-hidari
    sa = min(sa,abs(hidari-migi))

print(sa)
    

Measured memory_bytes: 25772
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
using namespace std;

int main() {
  int a[5],sum = 0,m = 10;
  for ( int i = 0; i < 5; i++ ) {
    cin >> a[i];
    int y;
    if ((a[i] % 10) == 0) y = 0;
    else y = 1;
    int x = (a[i]/10 + y)*10;
    //cout << x << endl;
    sum += x;

    if ( (a[i] % 10) != 0 ){
      m = min(m,a[i]%10);  
    }
  }
  cout << sum - ( 10 - m ) << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import groupby

S = list(input())
K = int(input())

N = len(S)

if len(set(list(S))) == 1:
    print(N * K // 2)
else:
    G = list(map(lambda g: len(list(g[1])), (groupby(S))))
    cnt = sum(map(lambda g: g // 2, G)) * K

    if S[0] != S[N - 1]:
        print(cnt)
    else:
        a = G[0]
        b = G[-1]
        print(cnt - (a // 2 + b // 2 - (a + b) // 2) * (K - 1))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

ll MOD = 1000000007;

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

    int N;
    cin >> N;

    vd ps(N);
    for(int i=0;i<N;i++) cin >> ps[i];

    vd dprow(N+1, 0);
    vector<vd> dp(N+1, dprow);
    dp[0][0] = 1.;

    for(int i=1;i<=N;i++) {
        double p = ps[i-1];
        dp[i][0] = (1-p)*dp[i-1][0];
        dp[i][i] = p*dp[i-1][i-1];
        for(int j=1;j<i;j++){
            dp[i][j] = p*dp[i-1][j-1] + (1-p)*dp[i-1][j];
        }
    }
    
    double ans = 0.;
    for(int i=0;i<=N;i++) {
        if (i > N-i) ans += dp[N][i];
    }

    cout << setprecision(18);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

ll mod = 1000000007;

ll modpow(ll a,ll p){
    if(p==0)return 1;
    if(p%2==0){
        ll d=modpow(a,p/2);
        return d*d%mod;
    }
    return a*modpow(a,p-1)%mod;
}

ll divide(ll a,ll b){
    return a*(ll)modpow(b,mod-2)%mod;
}

vecll P;
void make_perm(ll m){
    P.resize(m+1);
    P[0]=1;
    rep2(i,1,m){
        P[i]=P[i-1]*i%mod;
    }
    return;
}
 ll C(ll a,ll b){
     return divide(divide(P[a],P[b]),P[a-b])%mod;
 }

int main(){
    ll n=in(),m=in();
    make_perm(m*2);
    ll ans = 0;
    rep(i,n){
        ans = (ans + ((ll)pow(-1,i)*C(n,i+1)*divide(P[m-i-1],P[m-n])%mod+mod)%mod)%mod;
    }
    ans = divide(P[m],P[m-n])*(divide(P[m],P[m-n])-ans+mod)%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 11156
package main

import (
	"fmt"
	"sort"
)

// Pair .
type Pair [2]int

// Pairs .
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Less(i, j int) bool {
	return p[i][1] < p[j][1]
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	pairs := make([]Pair, m)
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		pairs[i] = Pair{a, b}
	}
	sort.Sort(Pairs(pairs))

	ans, t := 0, 0
	for i := 0; i < m; i++ {
		p := pairs[i]
		if p[0] < t && t <= p[1] {
			continue
		}
		ans++
		t = p[1]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6400
import numpy as np
mod = 10 ** 9 + 7

n = int(input())
x = np.array([int(a) for a in input().split()])

answer = 0
for d in range(61):
    x, r = x // 2, x % 2
    s = int(r.sum())
    b = (2 ** d) % mod
    answer += (b * s * (n - s)) % mod
print(answer%mod)


Measured memory_bytes: 49032
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define LL long long
#define P pair<int, int>
#define LP pair<int,int>
int N;
vector<int> A;
int rest[200010];
int ans;
int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	sort(A.begin(), A.end());
	int idx = 0;
	rest[idx] = 1;
	for(int i = 1; i < N; i++){
		if(A[i - 1] == A[i]) rest[idx]++;
		else rest[++idx]++;
	}
	A.erase(unique(A.begin(), A.end()), A.end());
	for(int i = A.size() - 1; i >= 0; i--){
		if(rest[i] == 0) continue;
		

		for(int j = 30; j >= 0; j--){

			if(A[i] >> j & 1){
				int  want = (1 << (j + 1)) - A[i];
				int to = lower_bound(A.begin(), A.end(), want) - A.begin();
				
				while(A[to] == want && rest[to] != 0 && rest[i] != 0){
					rest[i]--;
					rest[to]--;
					if(rest[i] < 0) break;
					ans++;
				}
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1908
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        s: String
    }
    for _ in 0..s.len() {
        print!("x");
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
N, K = map(int, input().split())
#%%time
i = 0
ans = 0
while i <= 10**9:
    if N < K:
        ans = 1
        break
    elif N == K:
        ans = 2
        break
    elif K**i > N:
        ans =  i
        break
    else :
         i += 1 
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int digit(int n) {
  int count = 0;
  while (n) {
    count += n % 10;
    n /= 10;
  }
  return count;
}

int main(void) {
  int n, i, ans, tmp;
  scanf("%d", &n);
  ans = 1000000;
  for (i = 1; i < n; i++) {
    tmp = digit(i) + digit(n - i);
    if (tmp < ans) ans = tmp;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
def resolve():
  n, x = map(int, input().split())
  l = list(map(int, input().split()))
  ans = 1
  d = 0
  for i in l:
    d = d + i
    if d <= x:
      ans += 1
    else:
      break

  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0 )
    {
        cout<<"Possible";
    }
    else
    {
        cout<<"Impossible";
    }
    return 0;
    
}


Measured memory_bytes: 256