akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    print(N * (N - 1) / 2);

    return 0;
}

Measured memory_bytes: 384
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

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

int n;
LL g_a, g_b, s_a, s_b, b_a, b_b;

LL dp_a[5050], dp_b[25252525];

int main(){
    cin >> n;
    cin >> g_a >> s_a >> b_a;
    cin >> g_b >> s_b >> b_b;
    for(LL i = 0;i <= n;i++){
        if(i >= g_a && g_b - g_a > 0)dp_a[i] = max(dp_a[i], dp_a[i - g_a] + (g_b - g_a));
        if(i >= s_a && s_b - s_a > 0)dp_a[i] = max(dp_a[i], dp_a[i - s_a] + (s_b - s_a));
        if(i >= b_a && b_b - b_a > 0)dp_a[i] = max(dp_a[i], dp_a[i - b_a] + (b_b - b_a));
    }
    LL m = 0;
    for(LL i = 0;i <= n;i++)m = max(m, dp_a[i] + n);
    for(LL i = 0;i <= m;i++){
        if(i >= g_b && g_a - g_b > 0)dp_b[i] = max(dp_b[i], dp_b[i - g_b] + (g_a - g_b));
        if(i >= s_b && s_a - s_b > 0)dp_b[i] = max(dp_b[i], dp_b[i - s_b] + (s_a - s_b));
        if(i >= b_b && b_a - b_b > 0)dp_b[i] = max(dp_b[i], dp_b[i - b_b] + (b_a - b_b));
    }
    LL ans = m;
    for(LL i = 0;i <= m;i++)ans = max(ans, dp_b[i] + m);
    cout << ans << endl;
}

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

int main(){
  int N,H;
  cin>>N>>H;
  vector<int> a(N),b(N);
  for(int i=0;i<N;i++)
    cin>>a[i]>>b[i];
  sort(a.begin(),a.end(),greater<int>());
  sort(b.begin(),b.end(),greater<int>());
  int maxa = a.front();
  int ans = 0;
  for(int i=0;i<N;i++){
    if(b[i] < maxa) break;
    H -= b[i];
    ans++;
    if(H <= 0) break;
  }
  if(H > 0){
    ans += H / maxa;
    if(H % maxa) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << seinomi(a[a.size() / 2] - a[a.size() / 2 - 1]) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N,K;
	cin>>N>>K;
	VI X(N);
	int Lsum=0,Ssum=0; 
	bool F=false;
	REP(i,N){
		cin>>X[i];
		if(X[i]<0)Lsum++;
		else if(X[i]==0)F=true;//K--;
		else Ssum++;
	}
	if(K==0){
		cout<<0<<endl;
		return 0;
	}
	if(Lsum==0){
		cout<<X[K-1]<<endl;
		return 0;
	}
	else if(Ssum==0){
		cout<<X[N-K]*-1<<endl;
		return 0;
	}
	//cout<<K<<endl;
	int Lst=LB(X,0)-X.begin();
	int ans=INF;
	int i=0,j=0,Lstt=Lst;
	if(F){ 
		K--;
	
		if(Lst<=K){
			//cout<<"A"<<endl;
			while(i<=Lstt && Lstt+j<N){
				ans=min(ans,min(X[i]*-1,X[Lst+j])+X[i]*-1+X[Lst+j]);
				//cout<<ans<<" "<<i<<" "<<Lst+j<<endl;
				i++;
				j++;
			}
			cout<<ans<<endl;
		}
		else{
			i=Lst-K;
			//cout<<"B"<<endl;
			while(i<=Lstt && Lstt+j<N){
				ans=min(ans,min(X[i]*-1,X[Lst+j])+X[i]*-1+X[Lst+j]);
				//cout<<ans<<" "<<i<<" "<<Lst+j<<endl;
				i++;
				j++;
			}
			cout<<ans<<endl;
		}
	}
	else{
		if(Lst<=K){
			j+=K-Lst-1;
			//cout<<j<<" "<<Lst<<endl;
			//cout<<"C"<<endl;
			while(i<Lst && Lst+j<N){
				ans=min(ans,min(X[i]*-1,X[Lst+j])+X[i]*-1+X[Lst+j]);
				//cout<<ans<<" "<<i<<" "<<Lst+j<<endl;
				i++;
				j++;
			}
			cout<<ans<<endl;
		}
		else{
			i=Lst-K;
			//cout<<"D"<<endl;
			while(i<Lst && Lst+j<N){
				ans=min(ans,min(X[i]*-1,X[Lst+j])+X[i]*-1+X[Lst+j]);
				//cout<<ans<<" "<<i<<" "<<Lst+j<<endl;
				i++;
				j++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> T(N);
    ll sum_time = 0;
    ll ans = INF;
    rep(i, N){
        cin >> T[i];
        sum_time += T[i];
    }
    ll M; cin >> M;
    rep(i, M){
        ll p, x; cin >> p >> x; p--;
        cout << sum_time - (T[p] - x) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

 int linerSearch(int n,int S[],int key){
	int i=0;
	S[n]=key;
	while(S[i] != key)
		i++;
	return i != n;
         }

 int main(){
         int n,S[10000],q,key,i,count=0;
         scanf("%d",&n);
         for(i=0;i<n;i++){scanf("%d",&S[i]);}

         scanf("%d",&q);
         for(i=0;i<q;i++){
                   scanf("%d",&key);
                   if(linerSearch(n,S,key))count++;
                   }


         printf("%d\n",count);
         return 0;
         }


Measured memory_bytes: 2124
#include <iostream>
using namespace std;
int main(){
  while(true){
    int H;
    cin>>H;
    if(H==0){
      break;
    }
    int S[10][5];
    for(int y=0;y<H;y++){
      for(int x=0;x<5;x++) {
        cin>>S[y][x];
      }
    }
    int sco=0;
    while(true){
      bool flg=false;
      for(int y=0;y<H;y++){
        int m=S[y][2];
        if(m==0){
          continue;
        }
        if(S[y][0]==m&&S[y][1]==m){
          sco+=m*3;
          S[y][0]=S[y][1]=S[y][2]=0;
          flg=true;
          if(S[y][3]==m){
            sco+=m;
            S[y][3]=0;
            if(S[y][4]==m){
              sco+=m;S[y][4]=0;
            }
          }
        }
        else if(S[y][1]==m&&S[y][3]==m){
          sco+=m*3;
          S[y][3]=S[y][1]=S[y][2]=0;
          flg=true;
          if(S[y][4]==m){
            sco+=m;
            S[y][4]=0;
          }
        }
        else if(S[y][4]==m&&S[y][3]==m){
          sco+=m*3;
          S[y][3]=S[y][4]=S[y][2]=0;
          flg=true;
        }
      }
      if(!flg){
        break;
      }
      for(int x=0;x<5;x++){
        for(int y=H-1;y>=0;y--){
          if(S[y][x]!=0){
            continue;
          }
          for(int y2=y-1;y2>=0;y2--){
            if(S[y2][x]!=0){
              S[y][x]=S[y2][x];
              S[y2][x]=0;
              break;
            }
          }
        }
      }
    }
    cout<<sco<<endl;
  }
  return 0;
}



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

int main() {
  int n,result = 0;
  cin >> n;
  int dp[3][n];
  cin >> dp[0][0] >> dp[1][0] >> dp[2][0];
  for(int i=1;i<n;++i) {
    int a,b,c;
    cin >> a >> b >> c;
    dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + a;
    dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + b;
    dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + c;
  }
  result = max(dp[0][n-1],dp[1][n-1]);
  result = max(result,dp[2][n-1]);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1408
import copy
N, M = map(int, input().split())
edges = [[] for _ in range(N+1)]


for i in range(M):
  a, b = map(int, input().split())
  edges[a].append(b)
  edges[b].append(a)

ans = 0

def dfs(u, visited):
  global ans
  stack = [u]

  while stack:
    u = stack.pop()
    visited.add(u)

    e = list(filter(lambda x: x not in visited, edges[u]))
    l = len(e)
    if l == 0:
      if len(visited) == N:
        ans += 1
    elif l == 1:
      stack.append(e[0])
    else:
      for next in e:
        dfs(next, copy.copy(visited))


dfs(1, set())
print(ans)

Measured memory_bytes: 46556
N = int(input())
A = [int(l) for l in input().split()]


count1 = 0
k = 0
while True:
    count2 = 0
    for i in range(N):
        if A[i]/2** k % 2 !=0:
            break
        else:
            count2 += 1
    if count2 == N:
        count1 += 1
    else:
        break
    k += 1

print(count1)

Measured memory_bytes: 3060
import sys
from io import StringIO
import unittest

from collections import Counter

def resolve():
    n = int(input())
    l = [input() for _ in range(n)]
    cnt = 0
    ee = dict()

    for ll in l:
        tmp = ''.join(sorted(ll))

        if tmp in ee.keys():
            cnt += ee[tmp]
            ee[tmp] += 1
        else:
            ee[tmp] = 1

    print(cnt)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
acornistnt
peanutbomb
constraint"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
oneplustwo
ninemodsix"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa"""
        output = """4"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, x;
		cin >> n >> x;
		vector<int> a(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		for(int i=0; i < n; i++)a[i] -= x;
		vector<unordered_map<int, long long>> dp(n+1);
		dp[0][0] = 1;
		for(int i=0; i < n; i++){
			for(auto it:dp[i]){
				dp[i+1][it.first] += dp[i][it.first];
				dp[i+1][it.first+a[i]] += dp[i][it.first];
			}
		}
		cout << dp[n][0] - 1<< "\n";
		
		
		

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int N,L;
  int apple,sum;
  scanf("%d %d", &N, &L);
  if(L >= 0){
    apple = L;
  } else if (L+N-1 >= 0){
    apple = 0;
  } else{
    apple = L+N-1;
  }
  
  for(int j=1; j<=N; j++){
   sum += L+j-1;
  }

  sum -= apple;
  printf("%d", sum);
  return 0;

}


Measured memory_bytes: 128
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin). unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	() => (get().parse::<i64>().unwrap());
    	($t:ty) => (get().parse::<$t>().unwrap());
    }
    let n = get!();
    let y = get!();
    
    let answer = |a,b,c| {
    	println!("{} {} {}", a, b, c);
	};
    
    for i in 0..n+1 {
    	for j in 0..n+1 {
        	if i + j > n { break; }
            let k = n - i - j;
            let v = i*10000+j*5000+k*1000;
            if v == y {
            	answer(i, j, k);
                return;
            }
        }
    }
    answer(-1, -1, -1);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int datanum = 0;
    int x = 0;
    int y = 0;
    int z = 0;
    int n = 0;
    int i = 0;
    int count = 0;

    scanf("%d", &datanum);

    for (i = 1; i <= datanum; i++) {
        count = 0;
        for (x = 1; x < 99; x++) {
            for (y = 1; y < 99; y++) {
                for (z = 1; z < 99; z++) {
                    n = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                    if (n > i) {
                        break;
                    }
                    if (n == i) {
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }

    return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	string n; cin>>n;
	for(auto i:n){
		if(i=='7'){cout<<"Yes\n"; exit(0);}
	}
	cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
//累積和
int main(){//A
/*
    int x;cin>>x;
    if(x==0) cout<<1<<endl;
    else cout<<0<<endl;
    */
   ll a,b,c,d;cin>>a>>b>>c>>d;
   ll ans = max({a*c,a*d,b*c,b*d});
   cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
	int tt;
	int t;
	int m,s;
	
	tt=0;
	for (int i=0; i<4; i++){
		scanf("%d", &t);
		tt += t;
	}
	
	m = tt/60;
	s = tt%60;
	printf("%d\n%d\n", m, s);
	
	return 0;
}
	

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

int main(int argc, char *argv[])
{
  char str[1200];
  int i;

  fgets(str, 1200 - 1, stdin);

  for (i = 0; i < strlen(str); i++) {
    if ('A' <= str[i] && str[i] <= 'Z') str[i] += 0x20;
    else if ('a' <= str[i] && str[i] <= 'z') str[i] -= 0x20;
  }

  printf("%s", str);

  return 0;
}

Measured memory_bytes: 524
<?php
fscanf(STDIN,"%d %d",$L,$R);
//1組目を初期値にする
$result = (($L%2019)*(($L+1)%2019))%2019;
//総当り
for($i=$L;$i<=$R-1;$i++){
  if($result === 0){
    break;
  }
  for($j=$L+1;$j<=$R;$j++){
    if($result === 0){
      break;
    }
    //最小値更新
    if($result > (($i%2019)*($j%2019))%2019){
      $result = (($i%2019)*($j%2019))%2019;
    }
  }
}
echo $result;


Measured memory_bytes: 3956
#include <cstdio>
#include <cassert>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int k;
    char s[112345];
    scanf("%d %d\n", &n, &k);
    for(int i=0; i < n; i++){
        scanf("%c", s + i);
        assert(s[i] == 'L' || s[i] == 'R');
    }
    int score = 0;
    for(int i=0; i < n; i++){
        if(s[i] == 'L'){
            if(i > 0 && s[i-1] == 'L'){
                score++;
            }
        }else if(s[i] == 'R'){
            if(i < n - 1 && s[i+1] == 'R'){
                score++;
            }
        }else{
            assert(false);
        }
    }
    int diff = 0;
    for(int i=0; i < n - 1; i++){
        if(s[i] != s[i + 1]){
            diff++;
        }
    }
    int swap = min(k, diff/2);
    score += 2*swap;
    k -= swap;
    diff -= 2*swap;
    if(k > 0 && diff > 0){
        score++;
    }
    printf("%d\n", score);
    return 0;
}

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

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

    int length = s.length();

    if(s[length-1]=='s') {
        s += 'e';
        s += 's';
    }
    else s += 's';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N;
map<ll,ll> A;
ll Q;
ll B[100000], C[100000];
ll ans;

int main(){
    cin>>N;
    rep(i,N){
        ll a;
        cin>>a;
        A[a]++;
        ans+=a;
    }
    cin>>Q;
    rep(i,Q) cin>>B[i]>>C[i];

    rep(i,Q){
        ans+=(C[i]-B[i])*A[B[i]];
        A[C[i]]+=A[B[i]];
        A[B[i]]=0;

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 11048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <random>
#include <array>
#include <chrono>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

using llint=long long;

llint scoring(vector<llint> c,
            vector<vector<llint>> s,
            vector<llint> result,
            llint d=365){
    
    if(c.size()!=s[0].size()||s.size()!=result.size()){
  
        return -1;
    }else{
        llint score=0;
        vector<llint>held(26,1);
        REP(i,d){
            score+=s[i][result[i]-1];
            REP(j,26){
                if(j+1!=result[i]){
                    held[j]++;
                    
                }else{held[j]=0;}
                score-=c[j]*held[j];
            }
        }
         
        return score;
    }
 }

int main(){
    chrono::system_clock::time_point start, end;
    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    start = chrono::system_clock::now();
    llint d;
    cin>>d;
    std::uniform_int_distribution<> rand26(1, 26),randd(0,d-1);        // [0, 99] 範囲の一様乱数
    
    llint anum=26;
    vector<llint> c(anum);
    
    REP(i,anum){
        cin>>c[i];
    }
    vector<vector<llint>> s(d,vector<llint>(anum));
    REP(i,d){
        REP(j,anum){
            cin>>s[i][j];
        }
    }
    vector<llint> result(d);

    REP(i,d){
        result[i]=rand26(mt);
    }
    double time;
    auto newresult=result;
    while(( time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(
        ( chrono::system_clock::now()) - start).count()
        ))<1900000.){
        newresult=result;
        auto k=randd(mt);
        REP(i,k){
            newresult[randd(mt)]=rand26(mt);
        }
        if(scoring(c,s,newresult,d)>scoring(c,s,result,d)){
            result=newresult;
        }
        //cout<<"unko"<<endl;
    }
   //  cout<<scoring(c,s,result,d)<<endl;
    REP(i,d){
        cout<<result[i]<<endl;
    }
}


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

int calc(int A, int B, int C) {
	if (A % 2 || B % 2 || C % 2) return 0;
	if (A == B && B == C) return -1;
	return calc(B / 2 + C / 2, A / 2 + C / 2, A / 2 + B / 2) + 1;
}

int main() {
	int A, B, C;
	std::cin >> A >> B >> C;
	std::cout << calc(A, B, C) << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,t,x,y,ans;
	scanf("%d %d %d",&a,&b,&t);
	if(a>t){
		printf("0\n");
	}
	else{
		x=t/a;
		y=x*b;
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  
  if((a%3==0)||(b%3==0)||((a+b)%3==0))
  {
      cout<<"Possible"<<endl;
  }
  else
{
  cout<<"Impossible"<<endl;
}

return 0;

}
  

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int x;
	VI X;
	REP(i,3){
		cin >> x;
		X.PB(x);
	}
	sort(X.begin(),X.end());
	if(X[0]+X[1]==X[2]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
package main

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

type vertexId int

type vertex struct {
	id vertexId
	firstVisitAt int
	finishVisitAt int
	adjs []vertexId
}

func createVertex(id int, adjsInt []int) vertex {
	adjs := make([]vertexId, len(adjsInt))
	for i := 0; i < len(adjs); i++ {
		adjs[i] = vertexId(adjsInt[i])
	}
	return vertex{
		id: vertexId(id),
		firstVisitAt: 0,
		finishVisitAt: 0,
		adjs: adjs,
	}
}

func (v *vertex) isVisited() bool {
	return v.firstVisitAt > 0
}

func dfs(currentId vertexId, timestamp int, vertices []vertex) int {
	currentVertex := &vertices[currentId-1]
	if currentVertex.isVisited() {
		return timestamp
	}
	timestamp = timestamp + 1
	currentVertex.firstVisitAt = timestamp
	for _, adjId := range currentVertex.adjs {
		timestamp = dfs(adjId, timestamp, vertices)
	}
	timestamp = timestamp + 1
	currentVertex.finishVisitAt = timestamp
	return timestamp
}

func solveDfs(vertices []vertex) {
	timestamp := 0
	for {
		vid := vertexId(-1)
		for i := 0; i < len(vertices); i++ {
			if !vertices[i].isVisited() {
				vid = vertexId(i+1)
				break
			}
		}
		if vid > 0 {
			timestamp = dfs(vid, timestamp, vertices)
		} else {
			break
		}
	}
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	vertices := make([]vertex, n)
	for i := 0; i < n; i++ {
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		adjN, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		adjs := make([]int, adjN)
		for j := 0; j < adjN; j++ {
			adjId, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			adjs[j] = adjId
		}
		vertices[i] = createVertex(id, adjs)
	}

	solveDfs(vertices)

	for i := 0; i < n; i++ {
		fmt.Printf("%d %d %d\n", vertices[i].id, vertices[i].firstVisitAt, vertices[i].finishVisitAt)
	}
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}



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

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

    vector<int> b(100010, 0);

    for (int i=0; i<N; ++i) {
        ++b[a[i] + 1];
        ++b[a[i] + 2];
        ++b[a[i]];
    }

    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    for (int i=0; i<100010; ++i) {
        if (b[i] >= 0) {
            cout << b[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n, k = gets_i_list

puts k * ((k-1) ** (n-1))

Measured memory_bytes: 14572
#include <iostream>
#include <string>

int main()
{
    int n;
    std::cin >> n;
    std::string str;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        str = std::to_string(i);
        if (str.size() % 2 == 1) { ans++; }
    }

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

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

#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)

int main()
{
    int n,m,i,j,cnt=0,ans;
    cin>>n>>m;
    int a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }for(i=0;i<(n-1);i++)
    {
        for(int k=i+1;k<n;k++)
        {double s=0.0;
        for(j=0;j<m;j++)
        {
            s+=pow(a[i][j]-a[k][j],2);
        }s=sqrt(s);
        ans=(int)s;
        if(ans==s)
        {

            cnt++;
        }}
    }say(cnt);
}




Measured memory_bytes: 256
num = int(input())
vals = list(input().split())

ivals = []
for i in range(num):
  ival = int(vals[i])
  ivals.append(ival)

count = 0
check_flag=0

def is_odd(n):
    """ 奇数判定関数 """
    return (n%2) == 1

while check_flag==0:
  for i in range(num):
    if (ivals[i])%2 != 0:
      check_flag=1
      break
    else:
      ivals[i]=ivals[i]/2
  
  if check_flag==0:
    count+=1

print(count)

Measured memory_bytes: 9116
//package abc175;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		
		//s-r
		int ans = 0;
		
		switch(str) {
			case "SSS":
				ans = 0;
				break;
			case "SSR":
			case "SRS":
			case "RSS":
			case "RSR":
				ans = 1;
				break;
			case "RRS":
			case "SRR":
				ans = 2;
				break;
			case "RRR":
				ans = 3;
				break;
		}
		
		System.out.println(ans);
	}
	
}


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

int main() {
    int n, b[110];
    cin >> n;
    int ans = 0;
    for (int i=0;i<n-1;i++) cin >> b[i];
    ans += b[0] + b[n-2];
    for (int i=1;i<n-1;i++) {
        ans += min(b[i-1], b[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:17:12
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

inline unsigned int fast_gcd(unsigned int x, unsigned int y) {
  assert(x >= 0 && y >= 0);
  int shift;
  if (x == 0) return y;
  if (y == 0) return x;
  shift = __builtin_ctz(x || y);
  x >>= __builtin_ctz(x);
  do {
    y >>= __builtin_ctz(y);
    if (x > y) {
      unsigned int t = y;
      y = x;
      x = t;
    }
    y -= x;
  } while (y);
  return x << shift;
}

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

  int k; cin >> k;
 
  int64 ans = 0;
 
  for (unsigned int a = 1; a <= k; ++a) {
    for (unsigned int b = 1; b <= k; ++b) {
      for (unsigned int c = 1; c <= k; ++c) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
 
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
package main

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

const mod = 1000000007
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	X, N := sc.i(), sc.i()
	p := sc.is(N)
	if N == 0 {
		fmt.Println(X)
		return
	}
	for i := 0; i <= N; i++ {
		x1 := X + i
		x2 := X - i
		found1 := false
		found2 := false
		for _, v := range p {
			if v == x1 {
				found1 = true
			}
			if v == x2 {
				found2 = true
			}
		}
		if !found2 {
			fmt.Println(x2)
			return
		} else if !found1 {
			fmt.Println(x1)
			return
		}
	}
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	vector<vi> edge(n, vi(0));
	rep (i, 1, n - 1) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	int cnt[2] = {0, 0};
	vector<int> col(n, -1);
	function<void(int, int)> color;
	color = [&] (int u, int c) {
		++cnt[col[u] = c];
		for (auto v : edge[u]) {
			if (col[v] == -1) {
				color(v, c ^ 1);
			}
		}
	};
	color(0, 0);
	int num[3] = {n / 3, (n + 2) / 3, (n + 1) / 3};
	if (min(cnt[0], cnt[1]) <= num[0]) {
		int r1 = 3, r2 = 1;
		int tp3 = cnt[0] < cnt[1] ? 0 : 1;
		cerr << col[0] << ' ' << tp3 << endl;
		for (auto p : col) {
			if (p == tp3) {
				cout << r1 << ' ';
				r1 += 3;
			} else {
				if (r2 <= n) {
					cout << r2 << ' ';
					r2 += 1;
					r2 += (r2 % 3 == 0);
				} else {
					cout << r1 << ' ';
					r1 += 3;
				}
			}
		}
	} else {
		int las[3] = {3, 1, 2};
		if (num[2] <= cnt[0] && num[1] <= cnt[1]) {
			swap(las[1], las[2]);
		}
		for (auto p : col) {
			if (las[p + 1] <= n) {
				cout << las[p + 1] << ' ';
				las[p + 1] += 3;
			} else {
				cout << las[0] << ' ';
				las[0] += 3;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

vector<ll> sum;
int main(){
    
    int n;
    scanf("%d", &n);    

    sum.resize(200010, 0LL);
    vector<ll> c(n);
    rep(i, n) scanf("%lld", &c[i]);
    
    ll ans = 1;
    rep(i, n){
        ll x = c[i];
        if(i != 0 and c[i] == c[i-1]) continue;
        (sum.at(x) += ans) %= MOD;
        ans = sum.at(x);
    }
    ppp(ans); 
    
    return 0;
}


Measured memory_bytes: 3456
import numpy as np
n=int(input())
a=np.int32([list(map(int, input().split())) for i in range(n)])
all_diffs = np.expand_dims(a, axis=1) - np.expand_dims(a, axis=0)
d=dict()
for i in all_diffs:
    for j in i:
        d[tuple(j)]=d.get(tuple(j),0)+1
ans=n
ma=0
for i in d:
    if i!=(0,0):
        ma=max(ma,d[i])
print(ans-ma)

Measured memory_bytes: 21912
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

string s[10];

int main()
{
    int H, W;

    cin >> H >> W;

    for (int i = 0; i < H;i++)
    {
        cin >> s[i];
    }

    int cnt = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W;j++)
        {
            if(s[i][j] == '#')
            {
                cnt++;
            }
        }
    }

    if(cnt == H + W - 1)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }

        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long int
#define mxx 1000009
#define si set<int>
int main()  {
    ll a,b;
    cin>>a>>b;
    ll n = __gcd(a,b);
    int ans = 1;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i == 0)
        {
            ans++;
            while(n%i == 0) n/= i;
        }
    }
    if(n != 1)ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
C = sorted(L)
count = 0

import bisect
for i in range(N - 2):
    for  j in range(N - i - 2):
        s = C[i] + C[j + i + 1]
        t = bisect.bisect_left(C,s)
        u = t - (j + i + 1) - 1
        if u <= 0:
            pass
        else:
            count = count + u

print(count)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int P = 1e9 + 7;
inline int qpow(int x,int y){
	static int r; r=1; while (y){ if (y&1) r=(LL)r*x%P;y>>=1,x=(LL)x*x%P; } return r;
}
inline int Inv(int x){
	return qpow(x,P-2);
}
inline int C(int n,int m){
	if (m>n) return 0;
	int ans = 1;
	for (int i = 1; i <= m; ++i) ans = (LL)ans *Inv(i) % P * (n-i+1) % P;
	return ans;
}
int n,a,b,ans;
int main(){
	cin >> n >> a >> b;
	ans = qpow(2,n) - C(n,a) - C(n,b) - 1;
	ans %= P; ans += P; ans %= P;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const char s[4][7][8]={{"aaba","ccba","abcc","abaa"},
		       {"aa.ab",".bbab","a.cca","a.a.a","bbabb"},
		       {"aaca..","bbca..","ac..aa","ac..bb","..aaca","..bbca"},
		       {"aaca...","bbca...","ac.bb..","ac...aa","..a.abb","..a.a.a","..ccbba"}};

int main(){
    //freopen("in.in","r",stdin);
    int n=read(),k=n%4+4;
    if(n<3)return puts("-1"),0;
    if(n==3)return puts("aab\nb.b\nbaa"),0;
    for(int _=1,j=0;_<=n-k;_+=4,++j){
	int m=j*4;
	REP(t,0,3){
	    REP(i,1,m)putchar('.');
	    REP(i,0,3)putchar(s[0][t][i]);
	    REP(i,m+5,n)putchar('.');
	    puts("");
	}
    }
    int m=k%4;
    REP(t,0,k-1){
	REP(i,1,n-k)putchar('.');
	REP(i,0,k-1)putchar(s[m][t][i]);
	puts("");
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
string n;
int k;
int main(){
	cin>>n;
	for (int i=0;i<3;i++){
		k=n[i]-'0';
		if (k==7){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    n;
  answer = 0;
  scan = scanf("%lld", &n);

  ll    ns;
  ns = n;
  /* プログラムを書く */

  // k は 26 の何乗までいくかを示す
  ll    k;
  k = 1;
  while (ns > 0) {
    ns = ns - (ll)round(pow(26, (double)k));
    k++;
  }
  k = k - 1;

  char  *name;

  name = (char *)malloc(sizeof(char) * (k + 1));

  // k でナマエの文字数が分かるので、順番にチェック
  for (int p = 0; p < k; p++) {
    if (n % 26 == 0) {
      name[p] = 'z';
      n = n / 26 - 1;
    } else {
      name[p] = 96 + (n % 26);
      n = n / 26;
    }
  }

  // 最後に name を逆さまにする
  for (ll i = k - 1; i >= 0; i--) {
    printf("%c", name[i]);
  }

  return (0);
}



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

int main() {
	long long X, ANS = 0;
	cin >> X;
	if (X == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (long long i = 2; i * i <= X; i++) {
		long long Cur = i * i;
		while (Cur <= X) {
			ANS = max(ANS, Cur);
			Cur *= i;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;

int maxprofit=INT_MIN;

void recur(vector<int>v,int index,vector<vector<int>>f,vector<vector<int>>profit)
{
    if(v.size()==10)
    {
        int finalprofit=0;
        int days=0;
        for(int i=0;i<f.size();i++)
        {
            int count=0;
            for(int j=0;j<10;j++)
            {
                if(v[j]==1&&v[j]==f[i][j]){
                    count++;
                }
            }
            finalprofit+=profit[i][count];
            days+=count;
        }
        if(days!=0&&finalprofit>maxprofit)
        {
            maxprofit=finalprofit;
        }
    }
    else
    {
        v.push_back(1);
        recur(v,index+1,f,profit);
        v.pop_back();
        v.push_back(0);
        recur(v,index+1,f,profit);
    }
}


int main(){
    int n;
    cin>>n;
    vector<vector<int>>f(n,vector<int>(10)),profit(n,vector<int>(11));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<10;j++)
        {
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<11;j++)
        {
            cin>>profit[i][j];
        }
        
    }
    vector<int>v;
    recur(v,0,f,profit);
    cout<<maxprofit;
    
    
    

}

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC167
{
    class MainClass
    {

        // static int[] s;

        public static void Main(string[] args)
        {
            string s = ReadLine();
            string t = ReadLine();

            int n = s.Length;
            for(int i = 0;i<n;i++){
                if(s[i]!=t[i]){
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25884
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 1000000007


int main(){
  ll n;
  ll a[5];
  rep(i,5){
    cin >> a[i];
  }
  ll res=10,small=0;
  rep(i,5){
    if(a[i]%10<res&&a[i]%10!=0){
      res=a[i]%10;
      small=i;
    }
  }
  ll ans=0;
  rep(i,5){
    if(i!=small){
      ans+=((a[i]-1)/10+1)*10;
    }
  }
  ans+=a[small];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main()
{
    int i,a=0;
    char s[7];
    gets(s); 
    for(i=0;i<=6;i++)
        if(s[i]=='1')
            a++;
    cout<<a; 
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ret=n%10;
  while(n){
    n/=10;
    ret+=n%10;
  }
  return ret;
}
int main(){
  int n;
  string a="No";
  cin>>n;
  if(n%digit(n)==0){a="Yes";}
  cout<<a<<endl;
}

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

using namespace std;
typedef long long int ll;

int main(){
    ll a , b, x;
    cin>>a>>b>>x;
    if(x < b){
        x = x%b;
        cout<<(a*x)/b<<endl;
    }
    else{
        x = b-1;
        cout<<(a*x)/b<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592