akhauriyash/Code-Regression huggingface dataset:
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(h, w int, a []string) [][]byte {
        memo := make([][]int, h+1)
        for i := range memo {
                memo[i] = make([]int, w+1)
        }

        for i := 0; i < h; i++ {
                for j := 0; j < w; j++ {
                        if a[i][j] == '.' {
                                memo[i][j]++
                        }
                }
        }

        for i := 0; i < h+1; i++ {
                sum := 0
                for j := 0; j < w+1; j++ {
                        sum += memo[i][j]
                        if j == w {
                                memo[i][j] = sum
                        }
                }
        }
        for j := 0; j < w+1; j++ {
                sum := 0
                for i := 0; i < h+1; i++ {
                        sum += memo[i][j]
                        if i == h {
                                memo[i][j] = sum
                        }
                }
        }

        b := make([][]byte, h)
        k := 0
        for i := 0; i < h; i++ {
                if memo[i][w] != w {
                        b[k] = []byte{}
                        k++
                }
                for j := 0; j < w; j++ {
                        if memo[i][w] != w && memo[h][j] != h {
                                b[k-1] = append(b[k-1], a[i][j])
                        }
                }
        }

        if k != h {
                b = b[:k]
        }
        return b
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var h, w int
        fmt.Fscan(r, &h, &w)
        a := make([]string, h)
        for i := range a {
                fmt.Fscan(r, &a[i])
        }
        for _, b := range solution(h, w, a) {
                fmt.Println(string(b))
        }
}

Measured memory_bytes: 768
/**
     **author : _KMS_
     **created : 29-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+10,MOD=998244353;
typedef long long ll;
string s,p,q="";
int dp[3007][3007];
int main() {
   
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>s>>p;
  for(int i=1;i<=s.size();i++)
  {
    for(int j=1;j<=p.size();++j)
    {
      if(s[i-1]==p[j-1])
      {
        dp[i][j]=dp[i-1][j-1]+1;
      }
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }

  int l=s.size();
  int r=p.size();
  while(l>0&&r>0)
  {
    if(s[l-1]==p[r-1])
    {
      q+=s[l-1];
      l--;
      r--;
    }
    else if(dp[l-1][r]>dp[l][r-1])l--;
    else r--;
  }
  reverse(q.begin(),q.end());
  cout<<q<<"\n";
 


  return 0;
} 

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

int main(){
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<string> x;
    for(int i=1; i<=k; i++){
        for(int j=0; j+i-1<n; j++){
            x.push_back(s.substr(j,i));
        }
    }
    sort(x.begin(),x.end());
    string ans = x[0];
    int cnt = 1;
    auto p = x.begin();
    while(cnt < k){
        p++;
        if(*p != ans) {
            cnt++;
            ans = *p;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1660
import sys

def main():
    # sys.stdin = open('input149c.txt')

    x = int(input())

    r = False
    while not r:
        r = True
        for i in range(2,x):
            if x % i == 0:
                r = False
                break

        if r == False:
            x += 1
        
    print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  int m,f,r;
  char rank[5] = {'A','B','C','D','F'};

  for ( ; ; ){
    scanf("%d %d %d",&m,&f,&r);
    if (m == -1 && f == -1 && r == -1){
      break;
    }else if (m == -1 || f == -1 || m + f < 30){
      printf("%c\n",rank[4]);
    }else if (m + f >= 80){
      printf("%c\n",rank[0]);
    }else if (m + f >= 65){
      printf("%c\n",rank[1]);
    }else if (m + f >= 50){
      printf("%c\n",rank[2]);
    }else if (m + f >= 30){
      if (r >= 50){
        printf("%c\n",rank[2]);
      }else{
        printf("%c\n",rank[3]);
      }
    }
  }
  return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

bool solve(int N) {
	vi col(N + 1);
	if (N & 1) {
		int now = 0;
		for (int i = 1; i <= N / 2; ++i) {
			col[i] = col[N-i] = now++;
		}
		col[N] = now++;
	} else {
		int now = 0;
		for (int i = 1; i <= N / 2; ++i) {
			col[i] = col[N+1-i] = now++;
		}		
	}
	vector<pii> edges;
	for (int i = 1; i <= N; ++i) {
		for (int j = i+1; j <= N; ++j) {
			if (col[i] != col[j]) {
				edges.eb(i, j);
			}
		}
	}

	cout << edges.size() << endl;
	for (auto p : edges) {
		cout << p.fi << " " << p.se << endl;
	}
	return true;
}

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

	return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;
ll N;
ll K;
std::vector<ll> P;
std::vector<ll> C;

void solve() {
  ll ans = -1e18;

  rep(i, N) {
    int x = i;
    vector<ll> s;
    ll tot = 0;
    while (1) {
      x = P.at(x);
      s.push_back(C.at(x));
      tot += C.at(x);
      if (x == i) break;
    }
    int l = s.size();
    ll t = 0;
    rep(j, l) {
      t += s.at(j);
      if (j + 1 > K) break;
      ll now = t;
      if (tot > 0) {
        ll e = (K - (j + 1)) / l;
        now += tot * e;
      }

      ans = max(ans, now);
    }
  }

  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%lld", &N);
  scanf("%lld", &K);
  P.resize(N);
  C.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &P[i]);
    P.at(i)--;  // 0-indexed
  }
  for (int i = 0; i < N; i++) {
    scanf("%lld", &C[i]);
  }
  solve();
  return 0;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
int n, cnt;
int a[maxn];
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	int head = 0;
	for(int i = 0; i < n; i++){
		int mint = head;
		for(int j = head + 1; j < n; j++){
			if(a[mint] > a[j]){
				mint = j;
			}
		}
		if(mint != head){
			cnt++;
			swap(a[mint], a[head]);
		}
		head++;
	}
	int first = 1;
	for(int i = 0; i < n; i++){
		if(first)first = 0;
		else printf(" ");
		printf("%d", a[i]);
	}
	printf("\n%d\n", cnt);
	return 0;
}


Measured memory_bytes: 3216
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	string num; cin >> num;

	for (auto i : num) {
		if (i == '7') {
			cout << "Yes";
			exit(0);
		}
	}
	cout << "No";
	return 0;
}

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

int main() {
  int n; cin >>n;
  int ans = 0;
  int buf;
  for (int i=0; i<n; i++){
    cin >>buf; ans += buf-1;
  }
  
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
n=int(input())
ans=[]
s=n+1-n%2
for i in range(1,n+1-n%2):
  for j in range(i+1,n+1-n%2):
    if i+j==s:
      continue
    ans.append(str(i)+" "+str(j))
if n%2:
  for i in range(1,n):
    ans.append(str(i)+" "+str(n))
print(len(ans))
print("\n".join(ans))

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  string s, t; cin >> s >> t;
  int N = s.size(), M = t.size();
  // LCS
  int dp[3030][3030] = {};
  dp[0][0] = 0;
  rep(i, N) rep(j, M) {
    if(s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
  }

  // 復元
  string ans = "";
  while(N > 0 && M > 0) {
    if(dp[N][M] == dp[N-1][M]) N--;
    else if(dp[N][M] == dp[N][M-1]) M--;
    else {
      ans = s[N-1]+ans;
      N--, M--;
    }
  }

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


Measured memory_bytes: 36096
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int a;
	cin >> a;
	if (a < 1200)cout << "ABC";
	if (a >= 1200 && a < 2800)cout << "ARC";
	if (a >= 2800)cout << "AGC";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int S,a,b,c;
  cin >> S;
  a = S%10;
  b = (S-a)%100;
  b = b/10;
  c = (S-a-b)%1000;
  c = c/100;
  cout << a+b+c << endl;
  return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int A, B;
	cin >>A >>B;
	vector<vector<int>> c(100, vector<int> (100, 0));
	for (int i=0; i<50; i +=2)
		for (int j=0; j<100; j +=2) {
			A--;
			if (A>0)
				c.at(i).at(j)=1;
			else
				c.at(i).at(j)=0;
			c.at(i+1).at(j)=0;
			c.at(i).at(j+1)=0;
			c.at(i+1).at(j+1)=0;
		}
	for (int i=50; i<100; i +=2)
		for (int j=0; j<100; j +=2) {
			B--;
			if (B>0)
				c.at(i+1).at(j)=0;
			else
				c.at(i+1).at(j)=1;
			c.at(i).at(j)=1;
			c.at(i).at(j+1)=1;
			c.at(i+1).at(j+1)=1;
		}
	cout <<100 <<' ' <<100 <<endl;
	for (int i=0; i<100; i++) {
		for (int j=0; j<100; j++)
			if (0==c.at(i).at(j))
				cout <<'#';
			else
				cout <<'.';
		cout <<endl;
	}
	return 0;
}



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


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int countA = 0, countB = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != GetCharA(i))
                {
                    countA++;
                }

                if (S[i] != GetCharB(i))
                {
                    countB++;
                }
            }

            Console.WriteLine(Math.Min(countA, countB));
        }

        static char GetCharA(int i)
        {
            return (char) ((i & 1) * '0' + (~i & 1) * '1');
        }

        static char GetCharB(int i)
        {
            return GetCharA(~i);
        }
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll k, x;
  cin >> k >> x;
  for(ll i = x-k+1; i <= k+x-1; i++){
    cout << i << (i==x+k-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;
#define MAXN   1000005
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
set<int> fac(int x) 
{ 
    set<int> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void solve()
  {

	int n;
	cin>>n;
	int a[n];
	int hcf=1,lcm=1,flag=0;
	mii m;
	rep(i,n)
	{
		cin>>a[i];
		if(i==0){hcf=a[i];lcm=a[i];}
		else {hcf=__gcd(hcf,a[i]);}
		set<int> p=fac(a[i]);
		for(auto j:p)
		{
			if(m.find(j)!=m.end())flag=1;
			m[j]++;
		}
		
	}
	
		if(flag==0)cout<<"pairwise coprime";
		else 
		{
			if(hcf==1)cout<<"setwise coprime";
			else cout<<"not coprime";
			return;
		}
	
	

  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   sieve();
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 24140
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000
#define mod 1000000007
double f(int a){
	int c=0,b=a;
	while(b)c+=b%10,b/=10;
	return 1.0*a/c;
}
int q;
signed main(){
	cin>>q;
	int a=1;
	int b=1;
	while(q){
		if(f(a)>f(a+b)){
			a+=b*9;
			b*=10;
		}
		else{
			cout<<a<<endl;
			a+=b;
			q--;
		}
	}
	return 0;
}


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

//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	vector<int> rcs(n), bcs(n), gcs(n);
	rcs[0]=s[0]=='R';
	bcs[0]=s[0]=='B';
	gcs[0]=s[0]=='G';
	 
	
	for(int i=1; i<n; i++){
		rcs[i]=rcs[i-1]+(s[i]=='R');
		bcs[i]=bcs[i-1]+(s[i]=='B');
		gcs[i]=gcs[i-1]+(s[i]=='G');
	}
	long long ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(s[i]==s[j]) continue;
			
			if(s[i]!='G' && s[j] !='G'){
				//cout<<i<<' '<<j<<' '<<gcs[n-1]-gcs[j]<<'\n';
				
				ans+=gcs[n-1]-gcs[j];
			}
			else if(s[i]!='R' && s[j]!='R'){
				ans+=rcs[n-1]-rcs[j];
			}
			else {
				ans+=bcs[n-1]-bcs[j];
			}
			int d=2*j-i;
			if(d<n && s[d]!=s[i] && s[d]!=s[j]) ans--;
			
		}
	}
	cout<<ans;
	

    return 0;
}

Measured memory_bytes: 3664
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;

int main()
{
  //"Don't regret anything you do, because in the end it makes you who you are."
  string s,s1;
  vector <int> a(26),b(26);
  int c = 0,p =0;
  cin >> s >> s1;
  for (int i = 0; i < s.size(); ++i)
  {
    if(s[i] != s1[i])
      p++;
  }
  cout << p;
  return 0;
}


Measured memory_bytes: 3848
import math
N, K = map(int,input().split())
logs = list(map(int,input().split()))
a = 0
b = max(logs)
b_memo = set()
count=0
flg =0
while math.ceil(a) != math.ceil(b):
    c = (a+b)/2
    times = []
    for i in logs:
        times.append(math.floor(i/c))
    if sum(times) > K:
        a = c
    else:
        b = c
    if b - a < 0.001:
        count +=1
    if count >20:
        flg+=1
        break
if flg == 0:         
    print(math.ceil(b))
else:
    a = math.ceil(a)
    times = []
    for j in logs:
        times.append(math.floor(i/a))
    if sum(times) > K:
        print(math.ceil(b))   
    else:
        print(math.ceil(a)) 

Measured memory_bytes: 219852
#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>;

int main(){
    int L;
    cin >> L;
    double len;
    len = double(L)/3;
    double ans;
    ans = len*len*len;
    printf("%f", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  vector<vector<ll>> abc(n, vector<ll>(3));
  rep(i, n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

  vector<vector<ll>> dp(n, vector<ll>(3, -1));
  rep(i, 3) dp[0][i] = abc[0][i];

  reps1(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (j != k) chmax(dp[i][j], dp[i-1][k] + abc[i][j]);
      }
    }
  }
  cout << *max_element(dp[n-1].begin(), dp[n-1].end()) << endl;
  //rep(i, n) rep(j, 3) cout << dp[i][j] << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<string.h>
int main(){
  char s[51],t[51];
  scanf("%s%*c%s",s,t);
  int slen,tlen,i,j;
  slen=strlen(s);
  tlen=strlen(t);
  int check=0;
  for(i=slen-tlen;i>=0;i--){
    check=0;
    for(j=0;j<tlen;j++)
      if(s[i+j]!=t[j] && s[i+j]!='?')
        check=1;
    if(check==0){
      for(j=0;j<slen;j++){
        if(i<=j &&j<i+tlen)
          printf("%c",t[j-i]);
        else if(s[j]=='?')
          printf("a");
        else
          printf("%c",s[j]);
      }
      puts("");
      return 0;
    }
  }
  puts("UNRESTORABLE");
  return 0;
}


Measured memory_bytes: 128
N, M, Q = map(int, input().split())
A = [[0] * N for _ in range(N)]
for _ in range(M):
    l, m = map(int, input().split())
    A[l - 1][m - 1] += 1

questions = []
for _ in range(Q):
    p, q = map(int, input().split())
    questions.append((p - 1, q - 1))


D = []
for l in range(N):
    s = 0
    d = []
    for r in range(N):
        s += A[l][r]
        d.append(s)
    D.append(d)

T = []
for r in range(N):
    s = 0
    t = [0]
    for l in range(N):
        s += D[l][r]
        t.append(s)
    T.append(t)

for question in questions:
    print(T[question[1]][N] - T[question[1]][question[0]])


Measured memory_bytes: 30000
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define N_MAX 200002

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll inv_(ll n){
    if(n == 1) return 1;
    else return MOD-inv_(MOD%n)*(MOD/n)%MOD;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}
ll dpch[200000];
ll dpall[200000];
ll cntch[200000];
ll par[200000];
int N;
vector<int> G[200000];
bool used[200000];

void clear(){
    for(int i = 0; i < N; i++) used[i] = false;
}


void dfs1(int v){
    used[v] = true;
    dpch[v] = 1;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            par[G[v][i]] = v;
            dfs1(G[v][i]);
            dpch[v] *= finv[cntch[G[v][i]]+1];
            dpch[v] %= MOD;
            dpch[v] *= dpch[G[v][i]];
            dpch[v] %= MOD;
            cntch[v] += (cntch[G[v][i]]+1);
        }
    }
    dpch[v] *= fac[cntch[v]];
    dpch[v] %= MOD;
}

void dfs2(int v){
    used[v] = true;
    ll tmp;
    if(v != 0){
        tmp = dpall[par[v]]*inv_(comb(N-1, cntch[v]+1));
        tmp %= MOD;
        tmp *= (comb(N-1, cntch[v]));
        tmp %= MOD;
        dpall[v] = tmp;
    }
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            dfs2(G[v][i]);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    init();
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(0);
    clear();
    dpall[0] = dpch[0];
    dfs2(0);
    for(int i = 0; i < N; i++) cout << dpall[i] << endl;
}

Measured memory_bytes: 25076
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;

#define MaxN 100005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}


int main()
{
    //std::ios::sync_with_stdio(false);
    int N;
    read(N);
    int a = N/100;
    N%=100;
    int b = N/10;
    N%=10;
    int c = N;
    if(a==c) puts("Yes");
    else puts("No");
    //system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

using std::string;
using std::cin;
using std::cout;
typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N, M;
    cin >> N >> M;
    std::priority_queue<ll, vector<ll>, std::greater<ll>> A;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        A.push(a);
    }
    using P = std::pair<ll, ll>;
    vector<P> BC;
    for (int i = 0; i < M; i++) {
        ll b, c;
        cin >> b >> c;
        BC.push_back(std::make_pair(b, c));
    }
    std::sort(BC.begin(), BC.end(),
              [](const P &x, const P &y) { return x.first < y.first;});
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < BC[i].first; j++) {
            if (A.top() < BC[i].second) {
                A.pop();
                A.push(BC[i].second);
            } else {
                break;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A.top();
        A.pop();
    }
    cout << ans << std::endl;
    
    return 0;
}



Measured memory_bytes: 3188
#include <cstdio>

int main(){
 int a, b, c, d;
 scanf("%d", &a);
 b = a / 3600;
 c = (a % 3600) / 60;
 d = a % 60;
 printf("%d:%d:%d\n", b, c, d);
 return 0;
}



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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

vector<long long> bg_len(51);
vector<long long> pt(51);
long long ans(int N, long long X) {
  if(N == 0) return 1;
  if(X == 1) {
    return 0;
  } else if(2 <= X && X <= bg_len[N - 1] + 1) {
    return ans(N - 1, X - 1);
  } else if(X == 1 + bg_len[N - 1] + 1) {
    return pt[N - 1] + 1;
  } else if(bg_len[N - 1] + 3 <= X) {
    return pt[N - 1] + 1 + ans(N - 1, X - bg_len[N - 1] - 2);
  }
}

int main() {
  int N;
  long long X;
  cin >> N >> X;
  bg_len[0] = 1;
  pt[0] = 1;
  REP(i, 50) {
    bg_len[i + 1] = 2 * bg_len[i] + 3;
    pt[i + 1] = 2 * pt[i] + 1;
  }
  long long a = ans(N, X);
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    b:[isize;a],
    }
    let mut c=0;
    let mut ans=0;
    for i in 0..a {
        if c<=b[i]{ans+=1;c=b[i];}
    }
    println!("{}",ans);
}

Measured memory_bytes: 2128
def main():
    mod = 10**9 + 7
    s = int(input())
    dp = [0] * (s+3)
    dp[0] = 1
    for i in range(0,len(dp)):
        for j in range(i+3,len(dp)):
            dp[j] = dp[j] + dp[i]

    print(dp[s]%mod)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
# -*- coding: utf-8 -*-
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10**9)
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()

def calc(i):
    if i == N-2:
        return (A[i], A[i+1]), (-A[i], -A[i+1])
    else:
        X, Y = calc(i+1)
        return ([A[i], max(X[0] + X[1], Y[0] + Y[1])],
                [-A[i], max(-X[0] + X[1], -Y[0] + Y[1])])

print(max(map(sum, calc(0))))

Measured memory_bytes: 94236
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	long long n,a,b;
	cin>>n>>a>>b;
	int sum=0;
	for(int i=1;i<=n;i++){
		long long tmp=0;
		long long tmp2=i;
		while(tmp2>0){
			tmp+=tmp2%10;
			tmp2/=10;
		}
		if(tmp>=a&&tmp<=b){
			sum+=i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	string s, t;
	cin >> s >> t;

	sort(ALL(s));
	sort(ALL(t)); reverse(ALL(t));

	if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;

	rtn 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_M = 10;
int n,m;
int s[MAX_M];
int p[MAX_M];

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;
  forn(i,m) {
    int k; cin >> k;
    int pat = 0;
    forn(i,k) {
      int s; cin >> s;
      pat |= (1 << (s-1));
    }
    s[i] = pat;
  }

  forn(i,m) cin >> p[i];

  int res = 0;
  for (int pat = 0; pat < (1<<n); pat++) {
    bool ok = true;
    forn(i,m) {
      ok &= popcnt(pat & s[i]) % 2 == p[i];
    }
    if (ok) res++;
  }

  cout << res << endl;


  return 0;
}


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

int main(){
    int n,k;
    string s;

    cin>>n;
    cin>>s;
    cin>>k;
    char c[n];
    strcpy(c,s.c_str());
    char a=c[k-1];
    pan(i,n){
    	if(c[i]!=a){
    		cout<<"*";
    	}
    	else{
    	    cout<<c[i];
    	}
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
int main(void){
    int n,a;cin>>n>>a;
    vector<int> x(n+1);
    rep(i,n) cin>>x[i];
    x[n]=a;
    sort(x.begin(),x.end());
    int g=x[1]-x[0];
    rep(i,n)g=gcd(g,(x[i+1]-x[i]));
    cout<<g<<endl;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	Scanner scan = new Scanner(System.in);
	
	void compute() {
		int n = scan.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>(200000);
		ArrayList<Integer> sorted = new ArrayList<>(200000);
		for (int i=0;i<n;i++) {
			int buf = scan.nextInt();
			list.add(buf);
			sorted.add(buf);
		}
		
		Collections.sort(sorted);
		
		int max = sorted.get(sorted.size()-1);
		int max2 = sorted.get(sorted.size()-2);
		for (int i=0;i<n;i++) {
			System.out.println(list.get(i) != max ? max : max2);
		}
	}
	
	
	public static void main(String...arg) {
		new Main().compute();
	}
}


Measured memory_bytes: 100676
# AtCoder Beginner Contest 106
# C - To Infinity

# 5000000000000000

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

whileone=-1
ans=-1
for i in range (len(S)):
    if S[i]=="1":
        whileone=i+1
    else:
        ans=S[i]
        break

if whileone>0 and whileone>=K:
    print(1)
else:
    print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll hida = 4*a*b;
    ll migi = c-a-b;

    if(hida<migi*migi&&migi>0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
n, a, b = map(int, input().split())
ans = n // (a+b)
ans *= a
if n % (a+b) != 0:
    ans += min(a, n % (a+b))
print(ans)

'''
ext = []
cnt = 0
while cnt <= n:
    for _ in range(a):
        ext.append('b')
    cnt += a
    for _ in range(b):
        ext.append('r')
    cnt += b
print("".join(ext[0:n]))
'''


Measured memory_bytes: 38384
a, b, c, x, y = map(int, input().split(" "))
ab = a * x + b * y

if x >= y:
    abc = c * 2 * y + a * (x - y)
else:
    abc = c * 2 * x + b * (y - x)

cc = c * 2 * max(x, y)
print(min(ab, abc, cc))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;

using namespace std;

int main(){

    LL n,m;
    cin>>n>>m;
    LL sum[2*m+5];
    LL ad[m];

    fill_n(sum,2*m+5,0);
    fill_n(ad,m,0);
    LL a[n];
    REP(i,n){
        cin>>a[i];
        a[i]--;
    }
    REP(i,n-1){
        if(a[i]<a[i+1]){
            sum[a[i]+1]--;
            sum[a[i+1]]++;
        }else{
            sum[a[i]+1]--;
            sum[a[i+1]+m]++;
        }
    }



    REP(i,2*m){
        sum[i+1]+=sum[i];
    }
    REP(i,m){
        sum[i]+=sum[i+m];
    }

    REP(i,n-1){
        ad[a[i+1]]+=(a[i+1]-a[i]+m)%m-1;
    }

    LL cnt[m];
    fill_n(cnt,m,0);
    REP(i,n-1){
        if(a[i]>a[i+1]){
            cnt[0]+=a[i+1]+1;
        }else{
            cnt[0]+=a[i+1]-a[i];
        }
    }
    LL minn = cnt[0];
    for(int i=1;i<m;i++){
        cnt[i]=cnt[i-1]+ad[i-1]+sum[i-1];
        minn = min(minn,cnt[i]);
    }
    cout<<minn<<endl;
//    REP(i,m){
//        cout<<ad[i]<<" "<<sum[i]<<endl;
//    }


    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
using vt = vector<T>;

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;
  string s;
  cin >> n;
  cin >> s;
  vi r, g, b;
  ll ans = 0;
  REP(i, n) {
    if(s[i]=='R') r.push_back(i);
    else if(s[i]=='G') g.push_back(i);
    else if(s[i]=='B') b.push_back(i);
  }
  if(r.size()>b.size()) swap(r, b);
  if(g.size()>b.size()) swap(g, b);
  set<int> bs;
  REP(i, b.size()) bs.insert(b[i]); 
  REP(i, r.size()) {
    REP(j, g.size()) {
      int dif = abs(r[i]-g[j]);
      ans += b.size();
      auto res = bs.find(r[i]+(g[j]-r[i])/2);
      if(!(dif%2) && res != bs.end()) ans--;
      res = bs.find(r[i]-dif);
      if(res != bs.end()) ans--;
      res = bs.find(r[i]+dif);
      if(res != bs.end()) ans--;
      res = bs.find(g[j]-dif);
      if(res != bs.end()) ans--;
      res = bs.find(g[j]+dif);
      if(res != bs.end()) ans--;
    } 
  } 
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pi 3.1415926535897932384
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18 ;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	cout.precision(12);
	cout.setf(ios::fixed,ios::floatfield);
	double a,b,c,x,d,y,z,r,k,s;
	cin>>a>>b>>x;
	y=(a*a*b-x)/(a*a);
	z=x/(a*a);
	s=y;
	y=(2.0)*y;
	d=a/y;
	r=b/(2.0);
	if(s>r)
    {
        d=(2.0*x)/(a*b*b);
        c=atan(d);
	c=(180.0 *c)/pi;
	c=90.00000000000000-c;
	cout<<c<<endl;
	return 0;
    }
	//cout<<d;
	c=atan(d);
	c=(180.0 *c)/pi;
	c=90.00000000000-c;
	//c=(pi/(2.0))-c;
	cout<<c<<endl;
}


Measured memory_bytes: 256
import copy
N = int(input())
#use {1, 6, 9, 6**2,...}
count = 1
use_money = [1]
x = 1
while 6**x<=N:
  use_money.append(6**x)
  x+=1
x = 1
while 9**x<=N:
  use_money.append(9**x)
  x+=1
use_money.sort(reverse=True)
money = copy.copy(use_money)

while not(N in money):
  B = []
  for x in money:
    for y in use_money:
      if x+y<=N and not(x+y in B):
        B.append(x+y)
  B.sort(reverse=True)
  money = B[:min(5,len(B))]
  count+=1
print(count)

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

int main() {
 int N,M;
  cin>>N>>M;
  vector<vector<int>> A(N,vector<int>(0));
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    A.at(a-1).push_back(b-1);
    A.at(b-1).push_back(a-1);
  }
  for(int i=0;i<A.at(0).size();i++){
    for(int j=0;j<A.at(A.at(0).at(i)).size();j++){
      if(A.at(A.at(0).at(i)).at(j)==N-1){
        cout<<"POSSIBLE";
        goto FIN;
      }
    }
  }
  cout<<"IMPOSSIBLE";
  FIN:;
}



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

#define fill(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pb push_back
#define smp(x,y,z) mp(x,mp(y,z))
#define reads(x) scanf("%s",&x)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)

typedef long long ll;
typedef string s;
typedef pair<ll,ll> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vector<int> > matrix;

const ll oo = 1e16;
const int maxSize = 100100;
const int mod = 1e9+7;

const double EPS = (1e-9);

int dcmp(double x, double y){return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;}

int n,arr[100100],coun[100100]={0} ;
multiset<int> ones;
vi twos;

int main(){
    cin >> n ;
    fill(coun,0);
    for(int i=0 ;i<n ;i++){
        cin>>arr[i] ; coun[arr[i]]++;
    }
    n=0;
    for(int i=1;i<=100000;i++){
        if( coun[i]%2 !=0)coun[i]%=2;
        else if(coun[i]!=0) coun[i]=2 ;
        if(coun[i]==1)ones.insert(i);
        if(coun[i]==2)twos.pb(i);
        if(coun[i]!=0)n++;
    }
     if(sz(twos)%2==0){
        cout << n ;
    }else {
        cout << n-1 ;
    }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    double N,L; cin >> N >> L;
    vector<double> T(N); REP(i,N) cin >> T[i];

    pair<double,double> ans(0,0);
    REP(i,N-1)FOR(j,i+1,N){
        pair<double, double> A;
        A.first = cos(PI*(T[i]+T[j]) / L);
        A.second = sin(PI*(T[i]+T[j]) / L);
        ans.first += 3*(N-2-(j-i-1))*A.first;
        ans.second += 3*(N-2-(j-i-1))*A.second;

        A.first = cos(PI*(T[i]+T[j]) / L + PI);
        A.second = sin(PI*(T[i]+T[j]) / L + PI);
        ans.first += 3*(j-i-1)*A.first;
        ans.second += 3*(j-i-1)*A.second;
    }

    ans.first /= N*(N-1)*(N-2)/2;
    ans.second /= N*(N-1)*(N-2)/2;

    cout << fixed << setprecision(10) << ans.first << " ";
    cout << fixed << setprecision(10) << ans.second << endl;

    return 0;
}

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

string S; long long ans = 0, cnt = 0;

int main() {
	cin >> S;
	for (int i = 0; i < (int)S.size() - 1; i++) {
		if (S[i] == 'A') {
			cnt++;
		}
		else if (S.substr(i, 2) == "BC") {
			ans += cnt; i++;
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;



int main(void) {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 - 1 << endl;;
	}
	else {
		cout << n / 2 << endl;
	}
	return 0;
}




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

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(a * b < n || a + b > n + 1){
        cout << -1 << endl;
        return 0;
    }
    int c, e;
    for(c = 0; c < n; c++){
        if(c * a + b - c > n){
            c--;
            e = n - c * a - (b - c - 1);
            break;
        }
    }
    if(a * b == n){
        c = b;
        e = 0;
    }
    for(int i = 0; i < c; i++){
        for(int j = 0; j < a; j++) cout << n - (i + 1) * a + j + 1 << " ";
    }
    for(int j = 0; j < e; j++) cout << n - c * a - e + j + 1 << " ";
    for(int j = n - c * a - e; j > 0; j--) cout << j << " ";
    cout << endl;
}


Measured memory_bytes: 3552
S = input()

sum_1 = 0
sum_2 = 0
sum_3 = 0
sum_4 = 0

for i in range(4):
    if S[0] == S[i]:
        sum_1 += 1
    if S[1] == S[i]:
        sum_2 += 1
    if S[2] == S[i]:
        sum_3 += 1
    if S[3] == S[i]:
        sum_4 += 1
    
if sum_1 == sum_2 == sum_3 == sum_4 == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064