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

void shellSort(int x[], int N);
void insertionSort(int x[], int N, int g);
void trace(int x[], int N);

long long gCount = 0;

int main(){
    int N;

    cin >> N;

    int x[N];

    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    shellSort(x, N);
    cout << gCount << endl;
    trace(x, N);

    return 0;
}

void shellSort(int x[], int N){
    int num = 0, i, h =1;
    vector<int> g;

    i = 0;
    do{
        g.push_back(h);
        h = h * 3 + 1;
        i++;
    }while(h < N);
    cout << g.size() << endl;
    for(i = g.size() - 1 ; i >= 0; i--){
        cout << g[i] << " ";
        insertionSort(x, N, g[i]);
    }
    cout << endl;
}

void insertionSort(int x[], int N, int g){
    int tmp, i, j;

    for(i = g; i < N; i++){
        tmp = x[i];
        j = i - g;
        while(j >= 0 && x[j] > tmp){
            x[j + g] = x[j];
            j = j - g;
            gCount++;
        }
        x[j + g] = tmp;
    }
    // trace(x, N);
}

void trace(int x[], int N){
    for(int i = 0; i < N; i++){
        cout << x[i] << endl;
    }
}

Measured memory_bytes: 6988
N=int(input())
i = list(map(int, input().split()))
c=0
for t in range (0,N):
    if i[t]%2==0 and i[t]%3!=0 and i[t]%5!=0:
        c=c+1
if c==0:
    print ('APPROVED')
else:
    print ('DENIED')

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)
	ans := 0
	for i := 0; i <= N-3; i++ {
		if S[i:i+3] == "ABC" {
			ans++
		}
	}
	fmt.Println(ans)
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
string s;
int cnt[50][26] = {{0}};
int ans[26] = {0};

int main(){
  scanf("%d",&n);
  REP(i,n){
    cin >> s;
    REP(j,s.size()){
      cnt[i][s[j]-'a']++;
    }
  }
  REP(i,26){
    ans[i] = cnt[0][i];
    FOR(j,1,n){
      ans[i] = min(ans[i],cnt[j][i]);
    }
    REP(j,ans[i]){
      printf("%c",'a'+i);
    }
  }
  printf("\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
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;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
string s;

void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>s;
  ll n = s.size()-1;
  ll ans = 0;
  rep(i,1<<n){
    ll cnt = 0;
    // cout<<i<<endl;
    rep(j,n+1){
      cnt += s[j] - '0';
      if(i>>j&1) {
        ans += cnt;
        cnt = 0;
      }
      if(cnt != 0 && j == n) ans += cnt;
      cnt *= 10;
    }
  }
  cout<<ans<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
n,p=int(input()),list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n)]
dp[0][0],dp[0][1]=1-p[0],p[0]
for i in range(1,n):
  for j in range(i+2):
    if j==0:dp[i][j]=dp[i-1][j]*(1-p[i])
    elif j==i+1:dp[i][j]=dp[i-1][j-1]*p[i]
    else:dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i]
print(sum(dp[-1][n//2+1:]))

Measured memory_bytes: 262792
D,N = map(int,input().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(101*100)
    else:
        print(N*(100**D))
else:
    if N == 100:
        print(101*(100**D))
    else:
        print(N*(100**D))

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, ch[100001] = {0};
  cin >> n;
  ll a[n], result = n;
  rep(i, n) {
    cin >> a[i];
    if (a[i] <= 100000) {
      ch[a[i]]++;
      if (ch[a[i]] == a[i]) result -= a[i];
    }
  }
  cout << result << endl;
}

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

int main(){
    char s[11],str[11];
    scanf("%s",s);
    int i,j,len;
  	len = strlen(s);
  	j = 0;
  for(i=0;i<len+1;i++){
    str[i]='\0';
  }
    for(i=0;i<len;i++){
        if(s[i]!='B'){
            str[j]=s[i];
            j++;
        }
        else if(j > 0){
            j--;
            str[j]='\0';
        }
    }
    printf("%s",str);
 
 
 
 
}

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

long long n, cnt, a[200005], ans;

signed main() {
	cin>>n;
	for(int i = 2; i <= sqrt(n); i++) 
	     if(n%i == 0) {
	     	a[++cnt] = i;
	     	if(i*i != n) a[++cnt] = n/i;
	     }
	for(int i = 1; i <= sqrt(n - 1); i++)  {
		if((n - 1)%i == 0) {
			ans += 2;
			if(i*i == n - 1) ans--;
		}
	}
	for(int i = 1; i <= cnt; i++) {
		int t = 0;
		long long s = n, res = 1;
		while(s%a[i] == 0) {
			t++;
			s /= a[i];
			res *= a[i];
		}
		
		if((n - res)%(res*a[i]) == 0) ans++;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <list>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

/*******-c++14 don't include-*******/
template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}
/*******---------------------*******/

static const int INTINF = (2147483647);
static const ll LLINF = (1ll<<32);
static const int MAX = 100001;

int arr[MAX];

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 1;
    char c = s[0];
    rep2(i, 1, n){
        if(c == s[i]){
            
        }
        else{
            c = s[i];
            res++;
        }
    }
    cout << res << endl;
    
    
    return 0;
}


Measured memory_bytes: 1020
void main() {
    string s = readln.chomp;
    bool ok = true;
    if (s[0] != 'A') ok = false;
    if (s[2..$-1].count('C') != 1) ok = false;
    if (s.filter!isLower.to!string.length != s.length - 2) ok = false;
    writeln(ok ? "AC" : "WA");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String day = sc.nextLine();

		switch(day) {
		case "MON":
			System.out.println(6);
			break;
		case "TUE":
			System.out.println(5);
			break;
		case "WED":
			System.out.println(4);
			break;
		case "THU":
			System.out.println(3);
			break;
		case "FRI":
			System.out.println(2);
			break;
		case "SAT":
			System.out.println(1);
			break;
		case "SUN":
			System.out.println(7);
			break;
		}
		
		sc.close();

	}

}


Measured memory_bytes: 21716
from collections import deque
queries = [input().split() for _ in range(int(input()))]
A = deque()
for query in queries:
    if query[0] == "0":
        if query[1] == "0":
            A.appendleft(int(query[2]))
        elif query[1] == "1":
            A.append(int(query[2]))
    elif query[0] == "1":
        print(A[int(query[1])])
    elif query[0] == "2":
        if query[1] == "0":
            A.popleft()
        elif query[1] == "1":
            A.pop()


Measured memory_bytes: 113884
/**
/home/shiblesadik/Documents/Contest/K.cpp
**/
#include<bits/stdc++.h>
using namespace std;
int TEST=0,CASE=1;
#define         pf              printf
#define         si(x)           scanf("%d",&x)
#define         sl(x)           scanf("%lld",&x)
#define         sd(x)           scanf("%lf",&x)
#define         pb(x)           push_back(x)
#define         mp(x,y)         make_pair(x,y)
#define         clr(x,y)        memset(x,y,sizeof(x))
#define         all(x)          x.begin(),x.end()
#define         MX              401000
#define         left            (indx<<1)
#define         right           left+1
#define         mid             ((l+r)>>1)
#define         speed           (ios::sync_with_stdio(false),cin.tie(0))
#define         fpoint(x)       (cout.precision(x),cout<<fixed)
#define         FOR(i,a,n)      for(int i=(a);i<=n;i++)
long long int         mod  =    1000000007LL;
const long double     pi   =    2.0*acos(0.0);
typedef long long int ll;
typedef long double ld;
struct vpair{
        int a,b;
        vpair(int a,int b){this->a=a,this->b=b;}
};
bool cmp(int &a,int &b){
        return a<b;                ///ascending order
///        return a>b;                ///descending order
}
ll n,m,a,b,c,d,k,x,y,z,ans=0,total=0;
vector<int> v;
string s;
ll arr[3000]={0};
bitset<10000000> bit=0;
int main(void){
        sl(n);
        for(int i=1;i<=n;i++){
                sl(arr[i]);
                ans+=arr[i];
        }
        bit[0]=1;
        for(int i=1;i<=n;i++){
                bit|=(bit<<arr[i]);
        }
        for(ll i=(ans+1)/2;i<=10000000;i++){
                if(bit[i]){
                        pf("%lld\n",i);
                        exit(0);
                }
        }
        return 0;
}

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

// @category セグメント木 (Segment Tree)
// @title セグメント木 (Segment Tree)
// 抽象 SegmentTree (0-indexed・一点更新・区間取得)
template <typename MonoidType>
struct SegmentTree {
    using Function = function< MonoidType(MonoidType, MonoidType) >;

    // node, identity element
    int n;
    vector<MonoidType> node;
    MonoidType E0;

    // update / combine function
    Function upd_f, cmb_f;

    void build(int m, vector<MonoidType> v = vector<MonoidType>()) {
        if(v != vector<MonoidType>()) m = v.size();
        n = 1; while(n < m) n *= 2;

        node = vector<MonoidType>(2*n-1, E0);
        if(v != vector<MonoidType>()) {
            for(int i=0; i<m; i++) {
                node[n-1+i] = v[i];
            }
            for(int i=n-2; i>=0; i--) {
                node[i] = cmb_f(node[2*i+1], node[2*i+2]);
            }
        }
    }

    // initialize
    SegmentTree() {}
    SegmentTree(int n_, MonoidType E0_,
                Function upd_f_, Function cmb_f_,
                vector<MonoidType> v = vector<MonoidType>()) :
        E0(E0_), upd_f(upd_f_), cmb_f(cmb_f_) {
        build(n_, v);
    }

    // update k-th element (applied value: x)
    void update(int k, MonoidType x) {
        k += n - 1;
        node[k] = upd_f(node[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = cmb_f(node[2*k+1], node[2*k+2]);
        }
    }

    // range query for [a, b)
    // 非再帰のアイデア: http://d.hatena.ne.jp/komiyam/20131202/1385992406
    MonoidType query(int a, int b) {
        MonoidType vl = E0, vr = E0;
        for(int l=a+n, r=b+n; l<r; l>>=1, r>>=1) {
            if(l & 1) vl = cmb_f(vl, node[(l++)-1]);
            if(r & 1) vr = cmb_f(node[(--r)-1], vr);
        }
        return cmb_f(vl, vr);
    }
};

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

    SegmentTree<int> seg(N, 0,
                         [](int a, int b) { return a + b; },
                         [](int a, int b) { return a + b; });

    int ans = 0;
    for(int i=0; i<N; i++) {
        int cnt = seg.query(P[i], N);
        if(cnt == i) ans++;
        seg.update(P[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3072
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
#include <functional>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	string s;
	cin >> s;
	int zero = 0, one = 0;
	for (auto c : s) {
		if (c == '0') {
			zero++;
		} 
		else {
			one++;
		}
	}
	cout << s.length() - abs(one - zero) << endl;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    int ans = min(a, b) + min(c, d);

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d){
        cout << "Left" << endl;
    }else if(a + b < c + d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  int kari = 0;
  int tri = 0;
  for(int i = 0;i < n;i++){
    int a = 0;
    cin >> a;
    if(i+1 == a){
      
    }else{
      kari++;
    }
    if(kari == 3){
      tri = 1;
    }
  }
  if(tri == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;	

void solve() {
    int n, k;
    cin >> n >> k;
    ll ans;
    if (k % 2) {
        ll num = n / k;
        ans = num * num * num;
    } else {
        ll num = n / k;
        ll num1 = n / (k / 2) - num;
        ans = num * num * num + num1 * num1 * num1;
    }
    cout << ans << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin>>N;
    vector<vector<int>> a(N, vector<int>(N-1, 0));
    rep(i,N) {
        rep(j,N-1){
        cin>>a[i][j];
        a[i][j]--;
        }
        reverse(all(a[i]));
    }
    vector<pair<int,int>> q;

    auto check = [&](int i){
        if(a[i].size() == 0)return;
        int j = a[i].back();
        if( a[j].size() == 0)return;
        if(a[j].back() == i){
            if(i < j)swap(i,j);
            q.push_back({i,j});
        }
    };
    rep(i,N){
        check(i);
    }
    int day = 0;
    while(!q.empty()){
        day++;
        sort(all(q));
        q.erase(unique(q.begin(),q.end()), q.end());
        vector<pair<int,int>> prevQ;
        swap(prevQ,q);
        for(auto p : prevQ){
            int i = p.first;
            int j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(auto p : prevQ){
            int i = p.first;
            int j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i,N){
        if(a[i].size() != 0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<day<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int ar[105];
int32_t main(){
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		ans+=ar[i];
	}
	sort(ar+1,ar+n+1);
	if(!(ans%10)){
		for(int i=1;i<=n;i++){
			if((ans-ar[i])%10){
				ans-=ar[i];
				break;
			}
		}
	}
	cout<<ans*(!!(ans%10));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int n,m,p;
int H[10][10];
int F[10][10][10];

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

bool can(int x,int y,int z) {
    if(0 <= x && x < n && 0 <= y && y < n && 0 <= z && z < n) return true;
    return false;
}

int main() {
    while(cin >> n >> m >> p) {
        if(n == 0 && m == 0 && p == 0) break;
        
        memset(H,0,sizeof(H));
        memset(F,0,sizeof(F));

        bool flag = false;

        rep(q,p) {
            int x,y;
            cin >> x >> y;
            x--;
            y--;

            F[y][x][H[y][x]] = q%2 + 1;
            H[y][x]++;

            rep(i,n) {
                rep(j,n) {
                    rep(k,n) {
                        rep(l,13) {
                            int x = i;
                            int y = j;
                            int z = k;
                            int len = 0;

                            while(can(x,y,z) && F[y][x][z] == q%2 + 1) {
                                y += dy[l];
                                x += dx[l];
                                z += dz[l];
                                len++;
                            }
                            

                            if(len >= m && !flag) {
                                flag = true;
                                if(q%2 == 0) cout << "Black ";
                                else cout << "White ";
                                cout << q+1 << endl;
                            }
                        }
                    }
                }
            }
        }

        if(!flag) cout << "Draw" << endl;







    }

    return 0;
}

Measured memory_bytes: 1168
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

const double r = 1.0;
const double PI = acos(-1.0);

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
};
Point operator+(const Point &a, const Point &b) {
    return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, double b) {
    return Point(a.x * b, a.y * b);
}
inline double Distance2(const Point &a, const Point &b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
// p1??¨??????p1p2???theta?????¢?????????????????£????????????????????????????????????????????????
Point Circle(const Point &p1, const Point &p2, double theta) {
    Point p12 = p2 - p1;
    Point rp(p12.x * cos(theta) - p12.y * sin(theta), p12.x * sin(theta) + p12.y * cos(theta));
    double len = sqrt(p12.x * p12.x + p12.y * p12.y);

    return (rp * (1.0 / len)) + p1;
}

int main()
{
    int n;

    while (true) {
        // Input
        scanf("%d", &n);
        if (n == 0) break;
        vector<Point> p(n);
        for (int i = 0; i < n; ++i)
            scanf("%lf %lf", &p[i].x, &p[i].y);

        // Solve
        // 2???????????????????§£???????£???¨??????
        int ans = 1;
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j) {
                double d = Distance2(p[i], p[j]);

                if (d <= 4.0 * r * r) {
                    double theta = (PI - acos((2.0 - d) * 0.5)) * 0.5;

                    for (int s = -1; s <= 1; s += 2) {
                        Point c = Circle(p[i], p[j], s * theta);

                        int num = 2;
                        for (int k = 0; k < n; ++k) {
                            if (k != i && k != j && Distance2(c, p[k]) <= 1.0)
                                ++num;
                        }

                        ans = max(ans, num);
                    }
                }
            }

        // Output
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
void CountingSort(int *, int * , int);
int n, *C;
int main()
{
  int i, *A, *B;

  scanf("%d",&n);
  A = (int *)malloc((n+1) * sizeof(int));
  B = (int *)malloc((n+1) * sizeof(int));
  C = (int *)malloc(10001 * sizeof(int));
  
  for(i = 1 ; i <= n ; i++) scanf("%d",&A[i]);

  /*for(i = 0 ; i <= n-1 ; i++) CountingSort(A, B, i);*/
  CountingSort(A, B, 10000);

  for(i = 1 ; i < n ; i++) printf("%d ",B[i]);
  printf("%d\n",B[n]);
  
  free(A);
  free(B);
  free(C);
  
  return 0;
}

void CountingSort(int *A, int *B, int k)
{
  int i, j;

  for(i = 0 ; i <= k ; i++) C[i] = 0;

  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  for(i = 1 ; i <= k ; i++) C[i] = C[i] + C[i-1];

  for(j = n ; j >= 1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--; }

}


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

const ll mod = 1e9+7;



int main() {

    ll n;
    cin>>n;
    ll v[n];
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }    
    ll c[n];
    for(ll i=0;i<n;i++){
        cin>>c[i];
        c[i]=v[i]-c[i];
    }
    ll ans=0;
    sort(c,c+n);
    for(ll i=n-1;i>=0;i--){
        ans=max(ans,ans+c[i]);
    }   
    cout<<ans<<endl;

}


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

using namespace std;

int main(void)
{
	int num = 0;
	char S[10];
	cin >> S;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '-')
			num--;
		else
			num++;
	}
	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
a=sorted(a)
cnt=0
if len(a)%2==0:
  for i in range(1,len(a),2):
    if [i,i]==a[i-1:i+1]:
      cnt+=1
    else:
      cnt=-10**5-1
else:
  if a[0]==0:
    for i in range(2,len(a),2):
      if [i,i]==a[i-1:i+1]:
        cnt+=1
      else:
        cnt=-10**5-1
  else:
    cnt=-10**5-1
print((2**cnt)%(10**9+7) if cnt>=0 else 0)

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

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

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

int N;
const int maxn = 200;

LL sum[maxn];

int main()
{
    cin >> N;
    _rep(i,1,N){
        LL num;
        cin >> num;
        sum[i] = sum[i-1];
        sum[i] +=  num;
    }

    LL alls = sum[N];
    LL ans = 1e18;

    _rep(i,1,N-1){
        LL lefts = sum[i];
        LL rights = alls - lefts;
        ans = min(abs(lefts-rights),ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	
	public static boolean exist(int[] list, int number, int start, int end) {
	
		int l = end - start;
		int midIndex = start + l/2;
		
		if(start == end) {
			return list[start] == number;
		}
		else if(list[midIndex] == number) {
			return true;
		}
		else if(list[midIndex] > number) {
			return exist(list,number,start,midIndex);
		}
		else {
			return exist(list, number, midIndex+1, end);
		}
		
				
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String arraySizeS = sc.nextLine();
		int arraySize = Integer.parseInt(arraySizeS);
		String[] inputArrayS = sc.nextLine().split(" ");
		int[] inputArray = new int[arraySize];
		for( int i = 0; i < arraySize; i += 1) {
			inputArray[i] = Integer.parseInt(inputArrayS[i]);}
		String arraySizeS2 = sc.nextLine();
		int arraySize2 = Integer.parseInt(arraySizeS2);
		String[] inputArrayS2 = sc.nextLine().split(" ");
		int[] inputArray2 = new int[arraySize2];
		for( int j = 0; j < arraySize2; j += 1) {
			inputArray2[j] = Integer.parseInt(inputArrayS2[j]);	
		}
		
		int counter = 0;
		
		for(int m = 0; m < inputArray2.length; m += 1) {
			if (exist(inputArray,inputArray2[m],0,inputArray.length-1)) {
				counter += 1;
			}
		}
		System.out.println(counter);
			
	}

}


Measured memory_bytes: 65448
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    bool z = false;
    for(int i = 0; i < s.length(); i++){
        for(int j = 0; j < s.length(); j++){
            string t = s;
            t.erase(i, j);
            if(t == "keyence"){
                z = true;
                break;
            }
        }
    }
    if(z) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll a[200005];
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}

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

const int inf = 0x3f3f3f3f;

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> ab(M);
    for(int i=0;i<M;i++){
        cin >> ab.at(i).second >> ab.at(i).first;
    }

    sort(ab.begin(),ab.end());
    
    int rem=0;
    int x_cur=-inf;
    for(int i=0;i<M;i++){
        if(ab.at(i).second>=x_cur){
            x_cur=ab.at(i).first;
            rem++;
        }
    }

    cout << rem << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string seireki;
    cin>>seireki;
    bool ifreiwa=true;
    string y,m,d;
    y=seireki.substr(0,4);
    m=seireki.substr(5,2);
    d=seireki.substr(8,2);
    //cout<<y<<" "<<m<<" "<<d<<endl;
    if(y<"2019") ifreiwa=false;
    else if(y=="2019"){
        if(m<"04") ifreiwa=false;
        else if(m=="04"){
            if(d<="30") ifreiwa=false;
        }
    }
    if(ifreiwa) cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$ans = 0;
for($i=1; $i<=$N; $i++) {
    list($X, $Y) = preg_split("/\s/i",trim(fgets(STDIN)));
    if($Y=="BTC") {
        $ans+= $X * 380000.0;
    }else{
        $ans+= $X;
    }
}
echo $ans;


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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	while(a>0&&c>0){
		c = c-b;
		if(c<=0){
			cout << "Yes" << endl;
			return 0;
			break;
		}
		a = a-d;
		if(a<=0){
			cout << "No" << endl;
			return 0;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3620
package main

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

var N int

func main() {
	N := nextInt()
	jpy := int64(0)
	btc := float64(0)
	for i := 0; i < N; i++ {
		x := nextString()
		u := nextString()
		if u == "JPY" {
			m, _ := strconv.ParseInt(x, 10, 64)
			jpy += m
		} else {
			m, _ := strconv.ParseFloat(x, 64)
			btc += m * 380000.0
		}
	}
	fmt.Printf("%v", float64(jpy)+btc)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP += [[s, p, i+1]]

SP.sort(key = lambda x: (x[0], -x[1]))
#print(SP)

for _city, _point, idx in SP:
    print(idx)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef long double ld;
const ld eps = 1.0e-13; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}
void solve()
{
	mp::cpp_dec_float_100 a,b,c;
	cin>>a>>b>>c;
	
	mp::cpp_dec_float_100 n=mp::sqrt(a)+mp::sqrt(b);
	mp::cpp_dec_float_100 m=mp::sqrt(c);
	if(n<m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() 
{
  int N,R,ans;
  
  cin>>N>>R;
  
  if(N<10)
  {
    ans=(10-N)*100;
    ans+=R;
  }
  else
  {
    ans=R;
  }
  
  cout<<ans;
}

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

int main() {
    fast;
    ll a, d; cin>>a>>d;
    vec<vec<ll>> p(a, vec<ll>(d));
    for(int q=0; q<a; q++) for(int w=0; w<d; w++) cin>>p[q][w];
    int o = 0;
    for(int q=0; q<a; q++){
        for(int w=q+1; w<a; w++){
            ll s = 0;
            for(int e=0; e<d; e++) s+=(p[q][e]-p[w][e])*(p[q][e]-p[w][e]);
            o+= (ll)sqrt(s)*(ll)sqrt(s)==s;
        }
    }
    cout<<o;
}

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

int main() {

    int n,r,t;

    long long int ans = 0;

    cin >> n >> r >> t;

    vector<int> em(1000);
    vector<int> fu(1000);
    vector<int> member(100);
    vector<int> pos(100);

    for(int i=0;i<1000;i++){
        em[i] = fu[i] = 0;
    }

    for(int i=0;i<n;i++){
        cin >> member[i];
        pos[i] = 0;
    }

    for(int k=0; k<t;k++){
        for(int i=0;i<n;i++){
            pos[i] += member[i];
            pos[i] = pos[i] % r;
            //cout << pos[i] << " " << member[i] << " " << i << endl;
            //cout << pos[i] << endl;
            if(k != 0){
                //cout << t << endl;
                em[pos[i]]++;
            }
            //cout << fu[pos[i]] << " " << pos[i] << " " << member[i] << " " << i << endl;
            if(fu[pos[i]] == 0){
                ans++;
            }
            else {
                fu[pos[i]]--;
            }
        }
        for(int i=0;i<r;i++){
            if(em[i] > 0) {
                fu[i] += em[i];
                em[i] = 0;
            }
            //cout << i << " " << fu[i] << " " << em[i] << endl;
        }
    }



    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;
using vi = vector<int>;

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

int main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    int N;
    ll p;
    ll a;
    cin >> N >> a;
    p = a;
    while (--N) {
        cin >> a;
        p = lcm(p, a);
    }

    outl(p);
}



Measured memory_bytes: 256
//============================================================================
// Author       : Sun YaoFeng
//============================================================================

//#pragma 	comment(linker, "/STACK:100240000,100240000")
//#include	<cstdio>
//#include	<cstdlib>
//#include	<cstring>
//#include	<algorithm>

#include	<bits/stdc++.h>

using	namespace	std;

#define DB		double
#define	lf		else if
#define I64		long long
#define unt		unsigned int
#define	Rd()	(rand()<<15|rand())
#define For(i,a,b)	for(int i=(int)(a);i<=(int)(b);i++)
#define Rep(i,a,b)	for(int i=(int)(a);i>=(int)(b);i--)

#define	fi	first
#define se	second
#define MK	make_pair
#define pb	push_back
#define PA	pair<int, int>

//#define	min(a,b)	((a)<(b)?(a):(b))
//#define	max(a,b)	((a)<(b)?(b):(a))

#define	CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for	(; CH < '0' || ch > '9';)	f= (ch == '-');
		for	(; ch >= '0' && ch <= '9'; CH)	x= x*10 + ch -'0';
		return	f? -x : x;
}

#define n	100005
#define P	1000000007

int		N, M, x[n], G[n];

struct	Mat{
		int 	A[3][3];
		
		Mat()	{
			for	(int i= 0; i <= 2; i ++)
				for	(int j= 0; j <= 2; j ++)	A[i][j]= 0;
		}
		
		Mat	operator *	(const Mat&b)	const{
			Mat	c, a= *this;
			
			for	(int i= 0; i <= 2; i ++)
				for	(int k= 0; k <= 2; k ++)	if  (a.A[i][k])
					for	(int j= 0; j <= 2; j ++)if  (b.A[k][j])
						c.A[i][j]= (1ll* a.A[i][k]* b.A[k][j] + c.A[i][j])%P;
			return	c;
		}
		
		Mat	operator *	(const int&k)	const{
			Mat	c;
			For(i, 0, 2)	For(j, 0, 2)
				c.A[i][j]= 1ll*A[i][j]*k%P;
			return	c;
		}
		
		Mat	operator +	(const Mat&b)	const{
			Mat	c;
			For(i, 0, 2)	For(j, 0, 2)
				c.A[i][j]= (A[i][j] + b.A[i][j]) % P;
			return	c;
		}
		
		Mat	operator ^	(int K)	const{
			Mat	ret, a=*this;
			for	(int i= 0; i <= 2; i ++)	ret.A[i][i]= 1;
			
			for (;;)	{
				if  (K&1)	ret= ret*a;
				
				K>>= 1;
				if  (K)		a= a*a;
					else	break;
			}
			return	ret;
		}
}A, B, S;

int		main(int argc, char* argv[]){
		N= IN();
		M= IN();
		For(i, 1, M)	x[i]= IN();
		x[++ M]= N;
		
		A.A[0][0]= 1;	A.A[0][1]= 2;	A.A[0][2]= 1;
		A.A[1][0]= 0;	A.A[1][1]= 1;	A.A[1][2]= 1;
		A.A[2][0]= 1;	A.A[2][1]= 2;	A.A[2][2]= 2;
		
		B.A[0][0]= 0;	B.A[0][1]= -2;	B.A[0][2]= 1;
		B.A[1][0]= 1;	B.A[1][1]= 1;	B.A[1][2]= -1;
		B.A[2][0]= -1;	B.A[2][1]= 0;	B.A[2][2]= 1;

		For(i, 1, M)	{
			G[i]= (A^x[i]).A[0][2];
			G[i]= (G[i] - ((A^x[i])*S).A[0][2]) % P;
			S= S + (B^x[i])*G[i];
		}
		
		printf("%d\n", (G[M] + P) % P);
		
		return	0;
}

Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))
ans = "No"

odd = 0
even = 0
four = 0

for i in A:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        even += 1
    else:
        odd += 1
        
if four >= even + odd - 1:
    ans = "Yes"

if four >= odd and even > 1:
    ans = "Yes"
    
print(ans)

Measured memory_bytes: 62576
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  int n,a,b;
  cin>>a>>b;
  int ans =(a*(a-1))/2+(b*(b-1))/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int H, W;
	cin >> H >> W;

	while (H != 0){

		int j, k;
		for (j = 0; j < H; j++){
			for (k = 0; k < W; k++){

				if (j == 0 || j == H - 1 || k == 0 || k == W - 1)
					cout << "#";
				else cout << ".";

			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}


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

int main() {
    ll n;
    cin>>n;
    V a1(n);
    V a2(n);
    rep(i,n){
        ll tmp;
        cin>>tmp;
        a1[i]=tmp+i;
        a2[i]=-tmp+i;
    }
    sort(a2.begin(),a2.end());
    ll ans=0;
    rep(i,n){
        ans+=upper_bound(a2.begin(), a2.end(), a1[i])-lower_bound(a2.begin(), a2.end(), a1[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6404
#include<stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);

    if(a<=0 && 0<=b){
        printf("Zero");
    }else if(a<0 && b<0){
        if((a-(b-1))%2==0){
            printf("Positive");
        }else{
            printf("Negative");
        }
    }else{
        printf("Positive");
    }

    return 0;
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  
  int n = s.size();
  vector<int> a;
  ll chunk = 1;
  
  ll ans = 0;
  
  rep(i,n-1){
      if(s[i] == s[i+1]){
        chunk++;
      }else{
		a.PB(chunk);
        chunk = 1;
      }
      if(i == n-2){
		a.PB(chunk);
      }
  }
  
  if(n == 1){
	cout << n * k / 2 << endl;
    return 0;
  }
  
  if(s[0] != s[n-1]){
    rep(i,a.size()){
      if(a[i] > 1){
        ans += a[i] / 2;
      }
    }
    ans *= k;
  }else{
    if(a.size() > 1){
      ll b = a[0] + a[a.size()-1];
    	REP(i,a.size()-2){
      	if(a[i] > 1){
      	  ans += a[i] / 2;
     	 }
    	}
   	ans *= k;
    
    ans += (b/2)*(k-1);
    ans += a[0]/2;
    ans += a[a.size()-1]/2;
    }else{
      ans = (n * k) /2;
    }
  }
  
  cout << ans << endl;
  

}

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

int main() {
    
    string str;
    cin >> str;
    int i = 0;
    int j = str.size() - 1;
    int count = 0;
    
    while(i <= j) {
        if(str[i] != str[j]) count++;
        i++; j--;
    }
    cout << count << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n, kv; cin >> n >> kv;
	int ans = 0;

	n++;

	for (int k = kv; k <= n; ++k)
	{
		int mn = (k * (k - 1)) / 2;

		int mx = (n * (n - 1)) / 2;

		k = n - k;

		mx -= (k * (k - 1)) / 2;

		k = n - k;

		mx %= mod;
		mn %= mod;

		ans += (mx - mn + 1 + mod) % mod;
		ans %= mod;
	}

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

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
# 入力
N = int(input())

l = []
for i in range(N):
    d1, d2 = map(int, input().split())
    l.append([d1, d2])
#print(l)

flag = 0
cont = 0
for i in l:
    if(i[0]==i[1]):
        flag = 1
        cont = cont + 1
        #print(cont)
        if (cont>=3):
            break
    else:
        cont = 0
        flag =0



if (cont >=3):
    print("Yes")
else:
    print("No")


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

int main() {
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  
  string t="No";
  
  int c=0;
  
  for(int i=0; i<a; i++){
    if(s[i] != '-'){
      c++;
    }
  }
  if(s[a] == '-'){
    c++;
  }
  for(int i=a+1; i<a+b+1; i++){
    if(s[i] != '-'){
        c++;
    }
  }
  
  if(c == a+b+1){
    t="Yes";
  }

  cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        ans = 0
        for k in range(d):
            ans += (x[i][k]-x[j][k])**2
        if math.sqrt(ans).is_integer() == True:
            count += 1
print(count)

Measured memory_bytes: 8936
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] s = new String[h];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next();
		}
		int[][] dp = new int[h][w];
		for (int i = 1; i < w; i++) {
			if (s[0].charAt(i - 1) == '.' && s[0].charAt(i) == '#') {
				dp[0][i] = dp[0][i - 1] + 1;
			} else {
				dp[0][i] = dp[0][i - 1];
			}
		}
		for (int i = 1; i < h; i++) {
			if (s[i - 1].charAt(0) == '.' && s[i].charAt(0) == '#') {
				dp[i][0] = dp[i - 1][0] + 1;
			} else {
				dp[i][0] = dp[i - 1][0];
			}
		}
		for (int i = 1; i < h; i++) {
			for (int j = 1; j < w; j++) {
				if (s[i].charAt(j - 1) == '.' && s[i].charAt(j) == '#') {
					dp[i][j] = dp[i][j - 1] + 1;
				} else {
					dp[i][j] = dp[i][j - 1];
				}
				if (s[i - 1].charAt(j) == '.' && s[i].charAt(j) == '#') {
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + 1);
				} else {
					dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]);
				}
			}
		}
		if (s[0].charAt(0) == '#') {
			dp[h - 1][w - 1]++;
		}
		System.out.println(dp[h - 1][w - 1]);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21588