akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  int x,y;
  cin>>x>>y;
  int d=0;
  vector<vi> a(2);
  rep(i,n){
    int t=0;
    while(s[i]=='F'&&i<n)t++,i++;
    a[d].push_back(t);
    d=1-d;
  }
  int g=8000;
  int dx[2][2*8000]={},dy[2][2*8000]={};
  dx[0][g]=dy[0][g]=1;
  rep(i,a[0].size())rep(j,2*g)if(dx[i%2][j]){
    dx[(i+1)%2][j+a[0][i]]=1;
    if(i>0)dx[(i+1)%2][j-a[0][i]]=1;
    dx[i%2][j]=0;
  }
  rep(i,a[1].size())rep(j,2*g)if(dy[i%2][j]){
    dy[(i+1)%2][j+a[1][i]]=1;
    dy[(i+1)%2][j-a[1][i]]=1;
    dy[i%2][j]=0;
  }
  if(dx[(int)(a[0].size())%2][x+g] && dy[(int)(a[1].size())%2][y+g])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main()
{
    int n,c=0,c1=0,c2=0,c3=0;
    string x={"x"};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC"){c++;}
        else if(s=="WA"){c1++;}
        else if(s=="TLE"){c2++;}
                else {c3++;}

    }
    cout<<"AC"<<" "<<x<<" "<<c<<endl;
     cout<<"WA"<<" "<<x<<" "<<c1<<endl;
      cout<<"TLE"<<" "<<x<<" "<<c2<<endl;
       cout<<"RE"<<" "<<x<<" "<<c3<<endl;
    return 0;
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] data = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();
            int n = data[0];
            int m = data[1];
            int l = data[2];

            long[,] a = new long[n, m];
            long[,] b = new long[m, l];
            long[,] c = new long[n, l];

            for (int i = 0; i < n; i++)
            {
                int[] input = Console.ReadLine()
                    .Split(' ')
                    .Select( x => int.Parse(x))
                    .ToArray() ;
                for (int j = 0; j < m; j++)
                {
                    a[i, j] = input[j];
                }
            }

            for (int i = 0; i < m; i++)
            {
                int[] input = Console.ReadLine()
                    .Split(' ')
                    .Select( x => int.Parse(x))
                    .ToArray() ;
                for (int j = 0; j < l; j++)
                {
                    b[i, j] = input[j];
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    for (int k = 0; k < l; k++)
                    {
                        c[i, k] += a[i, j] * b[j, k];
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < l; j++)
                {
                    sb.Append(c[i, j] + " ");
                }
                Console.WriteLine(sb.ToString().Trim());
            }

        }
    }
}

Measured memory_bytes: 10196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (LL)x*y%MOD;
}

LL dp[2010][2010] = {};
LL acc[2010][2010] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    VL S(N),T(M);
    REP(i,N)cin >> S[i];
    REP(i,M)cin >> T[i];

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            if(S[i-1] != T[j-1]) {
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (acc[i-1][j-1]+1) % MOD;
            }

            acc[i][j] = sub(add(add(acc[i-1][j],acc[i][j-1]),dp[i][j]),acc[i-1][j-1]);
        }
    }

    //REP(i,N+1){
    //    REP(j,M+1){
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    //REP(i,N+1){
    //    REP(j,M+1){
    //        cout << acc[i][j] << " ";
    //    }
    //    cout << endl;
    //}


    cout << acc[N][M]+1 << endl;

}

Measured memory_bytes: 63232
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000003
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=1000023;
ll fact[N];
ll invfact[N];
ll inv[N];
void factorialsComputation()
{
    inv[0]=inv[1]=1;
    fact[0]=fact[1]=1;
    invfact[0]=invfact[1]=1;
    for(int i=2;i<N;i++)
    {
        inv[i]=(inv[mod%i]*(mod-mod/i))%mod;
        fact[i]=(fact[i-1]*i)%mod;
        invfact[i]=(invfact[i-1]*inv[i])%mod;
    }
}
void solve()
{
    ll q;
    cin>>q;
    while(q--)
    {
        ll x,d,n;
        cin>>x>>d>>n;
        if(d==0)
        {
            cout<<power(x,n)<<'\n';
            continue;
        }
        ll ans=x*power(d,n-1);
        ans%=mod;
        ll start=x*inv[d];
        start%=mod;
        ll last=start+n-1;
        if(last>=mod)
        {
            cout<<0<<'\n';
            continue;
        }
        ll mult=fact[last]*invfact[start];
        mult%=mod;
        ans*=mult;
        ans%=mod;
        cout<<ans<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    factorialsComputation();
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int N,C,K;
    cin>>N>>C>>K;
    vint T(N);rep(i,N)cin>>T[i];sort(all(T));

    int cur=0;
    int ans=0;
    while(cur<N){
        int nex=cur;
        while(nex<N&&nex-cur<C&&T[nex]-T[cur]<=K)nex++;
        ans++;
        cur=nex;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
double ans=0;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
  	double b;
  	cin>>b;
  	ans+=1/b*1.0;
  }
  ans=1/ans;
  cout<<ans;
  return 0;
}

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

int main (void){
  long double a = 0,b = 0,h = 0,m = 0,x = 0,y = 0;
  cin >> a >> b >> h >> m;
  long double z = 0,r = 0,pi = 3.141592653589793;

  x = pow(a,2);
  y = pow(b,2);

  r = (h + m/60) *30 - m*6;

  
  if(r != 0 && r != 180){
    z = (x+y)-(2*a*b*cos(r*pi/180));
    z = sqrt(z);
    cout << fixed << setprecision(10) << z << endl;
    return 0;
  }else if(r == 0){
    a = a - b;
    if(a < 0){
      a = -a;
    }
    cout << a << endl;
    return 0;
  }else{
    cout << a+b <<endl;
  }
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> gusu(100000);
    vector<pair<int,int>> kisu(100000);
    rep(i,0,100000){
        gusu[i].second = i;
        kisu[i].second = i;
    }
    
    rep(i,0,n){
        int a;
        cin >> a;
        if(i%2==0){
            gusu[a].first++;
        }else{
            kisu[a].first++;
        }
    }
    sort(gusu.begin(),gusu.end());
    reverse(gusu.begin(),gusu.end());
    sort(kisu.begin(),kisu.end());
    reverse(kisu.begin(),kisu.end());

    if(gusu[0].second==kisu[0].second){
        int M = max(gusu[1].first,kisu[1].first);
        cout<<n-M-gusu[0].first<<endl;
    }else{
        cout<<n-gusu[0].first-kisu[0].first<<endl;
    }

  return 0;
}

Measured memory_bytes: 4832
#-*-coding:utf-8-*-

def main():
    h, w = map(int, input().split())
    arry = [list(input()) for _ in range(h)]
    arry_new = []

    for i in range(h):
        if len(set(arry[i])) == 1 and arry[i][0] == '.':
            continue
        else:
            arry_new.append(arry[i])

    for j in range(len(arry_new[0])):
        flag = 1
        for k in range(len(arry_new)):
            if arry_new[k][j] == '.':
                flag *= 1
            else:
                flag *= 0
        if flag == 1:
            for l in range(len(arry_new)):
                arry_new[l][j] = ''
    for ans in arry_new:
        for i in ans:
            print(i, end='')
        print('')

if __name__ == '__main__':
    main()

Measured memory_bytes: 4596
function Main(s) {
  var s = s.split("\n").map(e => e.split(" ").map(e => e*1));
  n = s[0][0], m = s[0][1];
  a_b = s.slice(1, m+1).sort((a, b) => a[1]-b[1]);
  var end = a_b[0][1]-2;
  ans = 1; 
  for (var i=0; i<m; i++) {
    if (a_b[i][0]-1 <= end) {
      continue;
    } else {
      end = a_b[i][1]-2;
      ans++;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 54752
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000000007
#define ll long long
using namespace std;
int main() {
  int a;
  cin >> a;
  if (a >= 1200) {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ll n,l;
   cin>>n>>l;
   ll a[n];cin>>a[0];int flag=0;
   if(l<a[0]){flag=1;cout<<1;}
   else
   {
       for(int i=1;i<n;i++)
       {cin>>a[i];
        a[i]=a[i]+a[i-1];
        if(l<a[i])
        {
            flag=1;
            cout<<i+1;
            break;
        }
       }
   }if(flag==0)
   cout<<n+1;
   
  
   
    return 0;
}

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

using namespace std;



int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    long long p = 0, cnt = 0;

    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    for(int&x : a){
//        cout << x << " " << cnt << endl;
        if(p+1 == x){
            cnt++;
        }else if (x <= p){
            cnt += x;
        }else {
            cout << -1 << endl;
            return 0;
        }
        p = x;
    }
    cout << cnt << endl;
    return 0;
}


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

inline int getint(void){
    int res = 0, c; while((c = getchar_unlocked() - '0') >= 0) res = 10 * res + c;
    return res;
}

char S[10];
inline void putint(int x){
    int idx = 0; do { S[idx++] = (x % 10) ^ '0'; x /= 10; } while(x);
    while(idx--) putchar_unlocked(S[idx]);
    putchar('\n');
}

int n;

constexpr int MAX_Q = 500'000;
int indices[MAX_Q];
int L[MAX_Q], R[MAX_Q], res[MAX_Q];

constexpr int MAX_N = 500'000;
int A[MAX_N];
int data[MAX_N + 1];
int LAST[MAX_N + 1];

inline void erase(int idx){ for(; idx <= n; idx += idx & -idx) --data[idx]; }
inline void add(int idx){ for(; idx <= n; idx += idx & -idx) ++data[idx]; }
inline int  sum(int idx){ int res = 0; for(; idx; idx -= idx & -idx) res += data[idx]; return res; }


int main(void){
    n = getint();
    const int q = getint();
    for(int i = 0; i < n; ++i) A[i] = getint();
    for(int i = 0; i < q; ++i) L[i] = getint() - 1, R[i] = getint();
    for(int i = 0; i < q; ++i) indices[i] = i;
    std::sort(indices, indices + q, [](const int x, const int y){
        if(R[x] != R[y]) return R[x] < R[y];
        return x < y;
    });
    for(int i = 1, cnt = 0, idx = 0; i <= n; ++i){
        const int color = A[i - 1];
        if(LAST[color]) erase(LAST[color]); else ++cnt;
        LAST[color] = i; add(i);
        while(idx < q and R[indices[idx]] == i){ 
            res[indices[idx]] = cnt - sum(L[indices[idx]]); ++idx; 
            
        }
    }

    for(int i = 0; i < q; ++i) putint(res[i]);

    return 0;
}

Measured memory_bytes: 17312
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

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

	int n;
	int a[200005];
	int cnt[200005];
	int ans = 0;
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n + 1) {
		cnt[i] = 0;
	}
	rep(i, n) cnt[a[i]]++;
	rep(i, n + 1) {
		ans += cnt[i] * (cnt[i] - 1) / 2;
	}
	rep(i, n) {
		int gen = cnt[a[i]] * (cnt[a[i]] - 1) / 2 - (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
		cout << ans - gen << endl;
	}

	return 0;
}


Measured memory_bytes: 5760
#include <iostream>

using namespace std;

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

	if (a > b) {
		t = b;
		b = a;
		a = t;
	}

	if (b > c) {
		t = c;
		c = b;
		b = t;
	}

	if (a > b) {
		t = b;
		b = a;
		a = t;
	}

	cout << a <<' '<< b <<' '<< c << '\n';
}


Measured memory_bytes: 3076
N = int(input())
A = list(map(int, input().split()))

S = sum(A)
A_even_sum = 0
for i in range(1, N - 1, 2):
    A_even_sum += A[i]
X = []
x_1 = (S - 2 * A_even_sum)
X.append(x_1)
for i in range(N - 1):
    x_next = int(2 * A[i] - X[i])
    X.append(x_next)
    X[i] = str(X[i])
X[N - 1] = str(X[N - 1])

ans = " ".join(X)
print(ans)

Measured memory_bytes: 17224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int a[510][510];
    ll l, r;
    ll n, m, Q;
    cin >> n >> m >> Q;

    Fill(a, 0);
    rep(i, m){
        cin >> l >> r;
        a[l][r]++;
    }

    reps(i, 1, n){
        reps(j, 1, n){
            a[i][j] += a[i][j-1];
        }
    }

    ll p, q;
    rep(i, Q){
        cin >> p >> q;
        ll sum = 0;
        reps(j, p, q){
            sum += a[j][q] - a[j][p-1];
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
def partition(A,p,r):
    x=A[r]
    i=p-1
    for j in range(p,r):
        if A[j]<=x:
            i+=1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[r]=A[r],A[i+1]
    return i+1

n=int(input())
A=list(map(int,input().split()))
k=partition(A,0,len(A)-1)
front=" ".join(map(str,A[:k]))
back=" ".join(map(str,A[k+1:]))
ans=front+" ["+str(A[k])+"] "+back
print(ans)


Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n,tot;
int a[200005],b[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i],tot-=a[i];
	for (int i=1;i<=n;i++)  cin>>b[i],tot+=b[i];
	
	if (tot<0)  return cout<<"No"<<endl,0;
	
	for (int i=1;i<=n;i++)
	{
		if (a[i]<b[i])  tot=tot-(b[i]-a[i]+1)/2;
	}
	if (tot<0)  cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	
	return 0; 
}

Measured memory_bytes: 3804
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
    int H, W, m, n;
    scanf("%d %d\n%d %d", &H, &W, &m, &n);
    printf("%d\n", H * W - m * W - n * H + m * n);
    return 0;
}

Measured memory_bytes: 128
import sys

N,M = map(int, input().split())

L = []

d = {}

for _ in range(M):
    P,S = input().split()
    P = int(P)
    L.append([P,S])

for i in range(M):
    p,s = L[i]
    if p in d:
        if s=="AC" and d[p]["AC"]==0:
            d[p]["AC"] = 1
        elif s=="WA" and d[p]["AC"]==0:
            d[p]["WA"] = d[p]["WA"] + 1
    else:
        d[p] = {}
        d[p]["AC"] = 0
        d[p]["WA"] = 0
        if s=="AC":
            d[p]["AC"] = 1
        else:
            d[p]["WA"] = 1

ac_count = 0
wa_count = 0

for i in range(1,N+1,1):
    if not (i in d):
        continue    
    ac_count = ac_count + d[i]["AC"]
    if d[i]["AC"]!=0:
        wa_count = wa_count + d[i]["WA"]

print(ac_count, wa_count)


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

#define MAX_N 1000
#define MAX_M 1000

string s, t;
int dp[MAX_N + 1][MAX_M + 1];

void solve(){
	for(int i = 0; i < s.length(); i++){
		for(int j = 0; j < t.length(); j++){
			if(s[i] == t[j]){
				dp[i + 1][j + 1];
					dp[i + 1][j + 1] = dp[i][j] + 1;
				} else {
					dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
				}
			}
		}
		cout << dp[s.length()][t.length()] << endl;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s >> t;
		solve();
	}
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 2; i < 55556; i++) {
		for(int j = 2; j * j <= i; j++) {
			if(i % j == 0) {
				goto NEXT;
			}
		}
		if(i % 5 == 1) {
			cout << i << " ";
			cnt++;
		}
		if(cnt == n) {
			cout << endl;
			return 0;
		}
		NEXT:;
	}
	return 0;	
}


Measured memory_bytes: 256
import java.lang.Math.sqrt

fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(' ').map(String::toInt)
    val vs = (1..n).map{readLine()!!.split(' ').map(String::toInt)}
    print(vs.indices.flatMap { i -> (i+1 until n).map { j ->
        val xi = vs[i]
        val xj = vs[j]
        (0 until d).map{k ->
            val y = xi[k]
            val z = xj[k]
            (y - z) * (y - z)
        }.sum()
    }.filter { s ->
        s == sqrt(s.toDouble()).toInt() * sqrt(s.toDouble()).toInt()
    }
    }.size)
}

Measured memory_bytes: 38236
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	rep(i, n)
	{
		int a; cin >> a;
		if (a % 2 == 0)
		{
			if (a % 3 != 0 && a % 5 != 0)
			{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll n;
    cin >> n;
    ll ans = 0;
    ll d;
    vector <ll> v;
    for (ll i=0;i<n;i++){
        cin >> d;
        v.push_back(d);
    }
    for(ll i=0;i<n;i++){
        for (ll j=i+1;j<n;j++){
            ans += v[i] * v[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2017年05月06日 星期六 20时47分46秒
File Name     :1.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

struct Node{
	int a,b,c;
	Node(int a,int b,int c){
		this->a=a;
		this->b=b;
		this->c=c;
	}
	bool operator < (const Node& tmp)const{
		if(a!=tmp.a) return a<tmp.a;
		if(b!=tmp.b) return b<tmp.b;
		return c<tmp.c;
	}
};
set<Node>st;
int a[3],b[3];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	for(int i=0;i<3;i++) scanf("%d",a+i);
	sort(a,a+3);
	st.insert(Node(a[0],a[1],a[2]));
	int ans=0;
	while(1){
		if(a[0]&1 || a[1]&1 || a[2]&1) break;

		ans++;
		b[0]=(a[0]+a[1])>>1;
		b[1]=(a[0]+a[2])>>1;
		b[2]=(a[1]+a[2])>>1;
		for(int i=0;i<3;i++) a[i]=b[i];
		Node tmp=Node(a[0],a[1],a[2]);
		if(st.count(tmp)) {ans=-1;break;}
		st.insert(tmp);
	}
	printf("%d\n",ans);	
    return 0;
}


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

int main(){
	int x;
	cin>>x;
	int s = x/100;
	rep(i,s+1){
		if(0<=x&&x<=i*5){
			puts(1);
			return 0;
		}
		x-=100;
	}
	puts(0);
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int R, C;
int num[2003][2003];
int he[2003][2003], ve[2003][2003];
char word[2004];

int main()
{
	int Q;
	scanf("%d %d %d", &R, &C, &Q);
	for (int i = 1; i <= R; i++) {
		scanf("%s", word);
		for (int j = 1; j <= C; j++) {
			num[i][j] = word[j - 1] - '0';
		}
	}

	for (int i = 1; i <= R + 1; i++) {
		for (int j = 1; j <= C; j++) {
			int here = (num[i][j] && num[i - 1][j]);
			ve[i][j] = here;
		}
	}
	for (int i = 1; i <= R; i++) {
		for (int j = 1; j <= C + 1; j++) {
			int here = (num[i][j] && num[i][j - 1]);
			he[i][j] = here;
		}
	}

	for (int i = 0; i <= R + 1; i++) {
		for (int j = 0; j <= C + 1; j++) {
			if (i) {
				num[i][j] += num[i - 1][j];
				he[i][j] += he[i - 1][j];
				ve[i][j] += ve[i - 1][j];
			}
			if (j) {
				num[i][j] += num[i][j - 1];
				he[i][j] += he[i][j - 1];
				ve[i][j] += ve[i][j - 1];
			}
			if (i && j) {
				num[i][j] -= num[i - 1][j - 1];
				he[i][j] -= he[i - 1][j - 1];
				ve[i][j] -= ve[i - 1][j - 1];
			}
		}
	}

	while (Q--) {
		int r1, r2, c1, c2;
		scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
		int total = num[r2][c2] - num[r1 - 1][c2] - num[r2][c1 - 1] + num[r1 - 1][c1 - 1];
		// (r1 + 1, r2) (c1, c2)
		int edge = ve[r2][c2] - ve[r1][c2] - ve[r2][c1 - 1] + ve[r1][c1 - 1];
		// (r1, r2) (c1 + 1, c2)
		edge += he[r2][c2] - he[r1 - 1][c2] - he[r2][c1] + he[r1 - 1][c1];
		int ans = total - edge;
		//printf(">>%d %d\n", total, edge);
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 48768
from collections import deque

s = list(input())
q = int(input())
query = [list(input().split()) for i in range(q)]
now = 0
a = deque(s)
for i in query:
  if i[0] == "1":
    now ^= 1
  elif i[0] == "2":
    f,c = int(i[1]),i[2]
    if (f+now) % 2:
      a.appendleft(c)
    else:
      a.append(c)
if now:
  a.reverse()
ans = "".join(a)
print(ans)


Measured memory_bytes: 118392
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);

    int k,a,b;
    cin >> k >> a >> b;
    bool flag=0;
    repr(i,a,b+1) {
        if (i%k==0) flag=1;
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;


    return 0;   
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int ll
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
inline ll sum(ll n){
	if(n<10) return n;
	return n%10+sum(n/10);
}
signed main(){
	ll n=rd();
	int ans = sum(n);
	string s = to_string(n);
	int sz = s.size();
	ans = max(ans, (s[0] - '0') - 1 + (sz - 1) * 9);
	writeln(ans);
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b, c;
	while (cin >> a >> b >> c, a || b || c) {
		int n; cin >> n;
		vector<double>R(n);
		rep(i, 0, n)cin >> R[i];
		int m = max(a, max(b, c));
		double x, y;
		if (m == a) {
			x = b; y = c;
		}
		else if (m == b) {
			x = a; y = c;
		}
		else {
			x = a; y = b;
		}

		double z = sqrt(x*x + y*y) / 2.0;

		rep(i, 0, n) {
			if (z < R[i])cout << "OK" << endl;
			else cout << "NA" << endl;
		}

	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int ws(int x)
{
    int num=0;
    while(x)
    {
        num++;
        x/=10;
    }
    return num;
}

int main()
{
    int N;
    while(cin>>N)
    {
        int i,cnt=0;
        for(i=1; i<=N; i++)
            if(ws(i)%2)
                cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    if (s.size()>t.size()){
        cout<<"GREATER\n";
    }else if(s.size()<t.size()){
        cout<<"LESS\n";
    }else{
        if (s>t){
            cout<<"GREATER\n";
        }else if(s<t){
            cout<<"LESS\n";
        }else{
            cout<<"EQUAL\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<PLL> arr;
	priority_queue<ll> q;

	fr(i,0,n)
	{
		ll x,y;
		//rl2(x,y);
		cin>>x>>y;
		arr.PB(MP(x,y));
		//q.push(MP(y,x));
	}
	sort(ALL(arr));
	ll ans=0;
	map<ll,ll> mp;
	int flag=1;
	// fr(i,0,n)
	// {
	// 	if(arr[i].F>m)
	// 		break;
	// 	if(!mp.count(arr[i].F))
	// 	{
	// 		ans+=arr[i].S;
	// 		mp[arr[i].F]=arr[i].S;
	// 	}
	// 	else
	// 	{
	// 		if(arr[i].S>mp[arr[i].F])
	// 		{
	// 			ans-=mp[arr[i].F];
	// 			mp[arr[i].F]=arr[i].S;
	// 			ans+=arr[i].S;
	// 		}
	// 	}
	// }
	ll pos=0;
	fr(i,1,m+1)
	{
		while(arr[pos].F<=i&&pos<n)
		{
			q.push(arr[pos].S);
			pos++;
		}
		if(q.empty())continue;
		ans+=q.top();
		q.pop();
	}
	// int i=0;
	// while(i<m)
	// {
	// 	PLL pr=q.top();
	// 	q.pop();
	// 	if(pr.S<=m)
	// 	{
			
	// 		// if(pr.S==m)
	// 		// {
	// 		// 	if(flag)
	// 		// 		ans+=pr.F;
	// 		// }
	// 		// else
	// 		// 	ans+=pr.F;
	// 		// if(pr.S==m)
	// 		// {
	// 		// 	flag=0;
	// 		// }
	// 		if(mp[pr.S]<m-pr.S+1)
	// 		{
	// 			mp[pr.S]++;
	// 			ans+=pr.F;
	// 			i++;
	// 		}
	// 	}
	// 	if(q.empty())
	// 		break;
	// }
	wl(ans);
	NL;
	return 0;
}

Measured memory_bytes: 3568
Q,H,S,D = map(int,input().split())
N = int(input())

cost = [8*Q, 4*H, 2*S, D]
mult = [4,2,1,1/2]

b = min(cost)
idx = cost.index(b)

if idx == 3:
    if N%2 == 0:
        ans = N//2*D
    else:
        ans = N//2 * D
        ans += min(4*Q, 2*H, S)
else:
    ans = N*b//2

print(ans)

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  ll k;
  ll tmp1 = 0;
  ll tmp2 = 0;
  cin >> s >> k;
  bool flag = true;
  rep(i,s.size()-1) if(s[i] != s[i+1]) flag = false;

  if(flag){
    cout << s.size() * k / 2 << endl;
    return 0;
  }

  string t = s+s;
  rep(i,s.size() - 1){
    if(s[i] == s[i+1]) {
      s[i+1] = '-';
      tmp1++;
    }
  }

  rep(i,t.size() - 1){
    if(t[i] == t[i+1]){
      t[i+1] = '-';
      tmp2++;
    }

  }
  
  cout << tmp1 + (tmp2 - tmp1)*(k-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void BubbleSort(int );
void SelectionSort(int);

struct card{

  char character;   

  int  number;

};


struct card inputdata[100];
struct card inputdata2[100];
struct card temp;

int main(){

  int sumcard,i,j,flag;

  flag = 0;

  scanf("%d",&sumcard);

  for(i = 0; i < sumcard; i++){

    scanf("%c%c%d",&inputdata[i].character,&inputdata[i].character,&inputdata[i].number);
    // scanf("%c",&inputdata[i].number[0]);

    inputdata2[i].character = inputdata[i].character;
    inputdata2[i].number = inputdata[i].number;

  }

  /* printf("\n");

  for(i = 0; i < sumcard; i++){

    printf("%c %d\n",inputdata[i].character,inputdata[i].number);

    }*/

  //  printf("test\n");
  BubbleSort(sumcard);

  for(i = 0; i < sumcard-1; i++){

    printf("%c%d ",inputdata[i].character,inputdata[i].number);

  }

  printf("%c%d\n",inputdata[i].character,inputdata[i].number);


  printf("Stable\n");

  
  SelectionSort(sumcard);

  for(i = 0; i < sumcard -1; i++){

    printf("%c%d ",inputdata2[i].character,inputdata2[i].number);

  }

  printf("%c%d\n",inputdata2[i].character,inputdata2[i].number);

  for(i = 0; i < sumcard; i++){

    if(inputdata[i].character != inputdata2[i].character){

      flag = 1;

      break;

    }

  }

  if(flag == 0){

    printf("Stable\n");

  }

  else{

    printf("Not stable\n");

  }


  return 0;

}

void BubbleSort(int sumcard){

  int i,x,j;


  for(i = 0; i < sumcard ; i++){

    for(j = sumcard-1; j >= i+1; j--){

      if(inputdata[j].number < inputdata[j-1].number){

	temp = inputdata[j];

	inputdata[j] = inputdata[j-1];
	inputdata[j-1] = temp;



      }
    }

  }
}

void SelectionSort(int sumcard){

  int i,j,minj,x;
  char y;

  for(i = 0; i < sumcard; i++){

    minj = i;

    for(j = i; j < sumcard; j++){

      if(inputdata2[j].number < inputdata2[minj].number){

	minj = j;

      }

    }
      temp = inputdata2[i];
    
      inputdata2[i] =inputdata2[minj];

      inputdata2[minj] = temp;
     
  }
  
}



 

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

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

    int num = n;
    int sum_d = 0;
    while (num != 0) {
        sum_d += num % 10;
        num /= 10;
    }

    if (n % sum_d == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

const long long mod = 1000000007;
long long w , b;
long long expw[210000] , expb[210000] , pw[210000] , pb[210000];
long long fac[210000] , ifac[210000] , inv2[210000];
long long ans[210000];
long long ksm ( long long f , long long x ) {
	long long s = 1;
	while ( x ) {
		if ( x % 2 ) s = s * f % mod;
		f = f * f % mod; x = x / 2;
	}
	return s % mod;
}
long long inv ( long long x ) {
	return ksm ( x , mod - 2 );
}
long long C ( long long x , long long y ) {
	return fac[x] * ifac[y] % mod * ifac[x-y] % mod;
}
void work () {
	long long i;
	scanf ( "%lld%lld" , &b , &w );
	fac[0] = 1;
	for ( i = 1 ; i <= b + w ; i++ ) fac[i] = fac[i-1] * i % mod;
	ifac[b+w] = inv ( fac[b+w] );
	for ( i = b + w - 1 ; i >= 0 ; i-- ) ifac[i] = (ifac[i+1]*(i+1)) % mod;
	inv2[0] = 1;
	inv2[1] = inv ( 2 );
	for ( i = 2 ; i <= b + w ; i++ ) inv2[i] = inv2[i-1] * inv2[1] % mod;
	for ( i = b ; i <= b + w ; i++ ) {
		expb[i] = C(i-1,b-1) * inv2[i] % mod;
		//printf ( " %lld\n" , pb[i] );
	}
	for ( i = w ; i <= b + w ; i++ ) {
		expw[i] = C(i-1,w-1) * inv2[i] % mod;
		//printf ( "  %lld\n" , pw[i] );
	}
	for ( i = 1 ; i <= b + w ; i++ ) {
		pw[i] = (pw[i-1] + expw[i]) % mod;
		pb[i] = (pb[i-1] + expb[i]) % mod;
	}
	for ( i = 0 ; i < b + w ; i++ ) {
		printf ( "%lld\n" , ( ( 1 - pw[i] - pb[i] + mod + mod ) % mod * inv2[1] % mod + pw[i] ) % mod );
	}
}
int main () {
	work ();
	return 0;
}


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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	
	bool isYes = true;
	// 後ろからマスの高さを求める
	for (int i = N - 2; i >= 0; i--)
	{
		// 手前の方が1より高い
		if (H[i] > H[i + 1] + 1)
		{
			isYes = false;
		}
		// 手前と後が同じ値の場合
		else if (H[i] == H[i + 1] + 1) {
			// 1下げる
			H[i]--;
		}
	}
	
	// 出力
	if (isYes == true)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/dp/tasks/dp_f

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1e9 + 7)
#define LINF (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

#define SIZE 3001
int dp[SIZE][SIZE];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t, ans = "";
    cin >> s >> t;
    for (size_t i = 0; i <= s.length() - 1; i++) {
        for (size_t j = 0; j <= t.length() - 1; j++) {
            if (s[i] != t[j]) {
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            } else {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
        }
    }
    int i = s.length() - 1, j = t.length() - 1;
    while (i >= 0 && j >= 0) {
        if (s[i] == t[j]) {
            ans += s[i];
            i--;
            j--;
        } else {
            if (dp[i][j + 1] > dp[i + 1][j]) {
                i--;
            } else {
                j--;
            }
        }
    }
    reverse(ALL(ans));
    cout << ans << endl;

    return 0;
}


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

int main(){
	long long a[100005];
    int t[100005];
	int n,m;
	int i,j,k,ans;
	cin>>n>>m;
	for (i=1;i<=n;i++)
		cin>>a[i];
	for (i=1;i<=n;i++)
		t[i]=1;
	for (i=1;i<=m;i++)
	{
		cin>>j>>k;
		if (a[j]>a[k])
			t[k]=0; 
		else 
			t[j]=0;
		if (a[k]==a[j])
			{
				t[j]=0;
				t[k]=0;
			}
	}
	ans=0;
	for (i=1;i<=n;i++)
	{
		if (t[i])
			ans++;
	}	
 	cout<<ans<<endl;
 	return 0;
} 

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

int main()
{
    int n;
    cin >> n;
    long long mod = 1e9 + 7;
    long long ans = 1;
    for(int i=1; i<=n; i++){
        ans = (ans*i)%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    int i =Math.min(A,B),ans =0,count =0;
    while (true) {
      if(A % i == 0 && B % i == 0) count++;
      if(count == K) {
        ans = i;
        break;
      }
      i--;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
using namespace std;
 
int main() { 
    int n;   
    string s;
    double x, ans = 0.0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x >> s;
        if(s[0] == 'J') ans += x;
        else ans += x*380000.0;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int w = sc.nextInt();
    for(int i=0;i<s.length();i=i+w) {
      System.out.print(s.charAt(i));
    }
    }
  }


Measured memory_bytes: 23636
a = list(input())
b = list("abcdefghijklmnopqrstuvwxyz")
for i in range(len(b)):
    c = True
    for j in range(len(a)):
        if b[i] == a[j]:
            c = False
    if c:
        print(b[i])
        exit()
print("None")


Measured memory_bytes: 3956
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),X=in();
	vector<int> L(X);
	REP(i,N) L[i]=in();
	int num = 1,old = 0;
	for(int i=1;i<=N;i++){
		int d = old+L[i-1];
		if(d<=X) num++;
		old = d;
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



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

	if (s.size() > k) {
		rep(i, k) {
			cout << s[i];
		}
		cout <<"..." << endl;
	}
	else {
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>

int main()
{
	char s[1001];
	char t[1001];

	scanf("%s", s);
	scanf("%s", t);

	int min;
	min = strlen(t);

	int i;
	for(i = 0; i < strlen(s) - strlen(t) + 1; i++) {
		int j;
		int count;
		for (j = 0, count = 0; j < strlen(t); j++) {
			if (s[i+j] != t[j])
				count++;
		}
		if (count < min)
			min = count;
	}

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


Measured memory_bytes: 1732