akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  bool check = true;
  string s,t; cin >> s >> t;
  if(s.size() + 1 == t.size()){
    rep(i,s.size()){
      if(s[i] != t[i]) check = false;
    }
  }
  else check = false;

  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
N, M = map(int, input().split())
 
cor = 0
penalty = 0
dic_penalty = {}
dic = {}
for i in range(M):
  p, S = input().split()
  p = int(p)
  if p not in dic:
    dic[p] = "_"
    dic_penalty[p] = 0
  if (S == "AC") & (dic[p] != "AC"):
    dic[p] = "AC"
    cor = cor+1
    penalty = penalty + dic_penalty[p]
    continue
  elif (S == "WA") & (dic[p] != "AC"):
    dic_penalty[p] = dic_penalty[p] + 1
    
print("{} {}".format(cor, penalty))

Measured memory_bytes: 21216
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m;cin >> n >>m;
    vi x(m);
    rep(i, m) cin >> x[i];
    sort(all(x));
    vi sa(m-1);
    rep(i, m-1) sa[i]=x[i+1]-x[i];
    sort(all(sa));
    int sum = 0;
    rep(i, m-n) sum+=sa[i];
    cout << sum << endl;
}

Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  int planA = n * a;
  int planB = b;
 
  if (planA < planB) {
    cout << planA << endl;
  } else {
    cout << planB << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<int>ans;
	if (N % 2 != 0) {
		rep(i, N) {
			if (i % 2 == 0) {
				auto it = ans.begin();
				it = ans.insert(it, A[i]);
			}
			else {
				auto it = ans.end();
				it = ans.insert(it,A[i]);
			}
		}
	}
	else {
		rep(i, N) {
			if (i % 2 == 0) {
				auto it = ans.end();
				it = ans.insert(it, A[i]);
			}
			else {
				auto it = ans.begin();
				it = ans.insert(it, A[i]);
			}
		}
	}

	rep(i, N) {
		cout << ans[i];
		if (i != N) {
			cout << ' ';
		}
	}
	cout << endl;
}


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

int k[100005];

int main(){
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;++i){
    int x,y;
    cin >> x >> y;
    k[x]++;
    k[y]++;
  }
  bool ok=true;
  for(int i=0;i<n;++i){
    if(k[i]%2==1) ok=false;
  }
  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 1e-8

using namespace std;
typedef vector<int> vint;
typedef vector<vint>  vvint;
typedef pair<int,int> pint;


int main(){
	int m;
	string str;
	cin >> m;
	for(int l=0;l<m;l++){
		cin >> str;
		set<string> st;
		int i,j;
		st.insert(str);
		for(i=1;i<str.length();i++){
			string a,b;
			for(j=0;j<i;j++){
				a+=str[j];
			}
			for(j=i;j<str.length();j++){
				b+=str[j];
			}
			
			st.insert(a+b);
			reverse(a.begin(),a.end());
			st.insert(a+b);
			reverse(b.begin(),b.end());
			st.insert(a+b);
			reverse(a.begin(),a.end());
			st.insert(a+b);
			reverse(b.begin(),b.end());
			swap(a,b);
			st.insert(a+b);
			reverse(a.begin(),a.end());
			st.insert(a+b);
			reverse(b.begin(),b.end());
			st.insert(a+b);
			reverse(a.begin(),a.end());
			st.insert(a+b);
			reverse(b.begin(),b.end());
		}
		cout << st.size() << endl;
	}
			
	return 0;
}

Measured memory_bytes: 1000
n, k = [int(i) for i in input().split()]
ans = 0
if k == 0:
    ans = n*n
else:
    for b in range(k+1, n+1):
        # number of perfect cycle
        ans += n // b * (b-k)
        r = n % b
        ans += max(r - k+1, 0)
print(ans)

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

signed main(){
	int n[9];
	cin >> n[0] >> n[1] >> n[4];
	n[2] = n[4] * 3 - n[0] - n[1];
	n[6] = n[4] * 2 - n[2];
	n[7] = n[4] * 2 - n[1];
	n[8] = n[4] * 2 - n[0];
	n[3] = n[4] * 3 - n[0] - n[6];
	n[5] = n[4] * 3 - n[2] - n[8];
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++) cout << (j ? " " : "") << n[i * 3 + j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        a<=8&&b<=8?cout<<"Yay!"<<endl:cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else if (n == 2) {
        int a, b;
        cin >> a;
        cin >> b;
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

int main() {
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1)*(n - w + 1) << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    int h, n;
    cin >> h >> n;
    if (h % n == 0)
    {
        cout << h / n << endl;
    }
    else
    {
        cout << h / n + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >>a[i];
    priority_queue<int> que;
    rep(i, n) que.push(a[i]);
    rep(i, m){
        int x = que.top(); que.pop();
        // cout << x << endl;
        que.push(x/2);
    }
    LL ans = 0;
    rep(i, n){
        LL x= que.top(); que.pop();
        ans += x;
    }
    cout << ans<< endl;

}

Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    cout << N * N * N << endl;
    return 0;
}

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

int main(){
    int x[10000];
    
    int n=0;
    while(true){
        //if (n>9999) return -1;
        
        cin >> x[n];
        
        if(x[n] == 0) break;
        
        ++n;
    }
    
    for(int i=0;i<n;++i){
        cout<<"Case "<< i+1 << ": "<<x[i]<<endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
  	cin >> a[i];
  }
  sort(a.begin(), a.end());

  int now = a[0];
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (now != a[i]) {
   	  ans += cnt % 2;
      cnt = 1;
      now = a[i];
    } else {
      cnt++;
    }
  }
  ans += cnt % 2;
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;
int main(){
    int a[1010];
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int sum=0;
    sort(a,a+n);
    for(int i=0;i<k;i++)
        sum+=a[i];
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 3832
n = int(input())
s = list(input())
x, max_x = 0, 0
for i in range(n):
  if s[i] == 'I':
    x += 1
    if max_x < x:
      max_x = x
  elif s[i] == 'D':
    x -= 1
print(max_x)

Measured memory_bytes: 3060
s = input()

for i in range(len(s)):
  if i % 2 == 1 and s[i] == 'R':
    s = False
    break
  elif i % 2 == 0 and s[i] == 'L':
    s = False
    break

if s:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 2940
import Data.IntMap
import qualified Data.IntMap as IM

import Data.List
import qualified Data.List as L
import Data.ByteString.Char8( readInt, getLine, words	)
import qualified Data.ByteString.Char8 as C8
import Data.Maybe( fromJust)
import Control.Applicative( (<$>))

main = do

    let
	intCounts = L.foldl' (\m k->IM.insertWith (+) k 1 m) IM.empty
	readBS2Int = fst . fromJust . readInt
	readLine2Ints = L.map readBS2Int . C8.words <$> C8.getLine

    n_ <- readLn::IO Int
    ds_ <- readLine2Ints
    m_ <- readLn::IO Int
    ts_ <- readLine2Ints
    let
	counter = intCounts ds_	

	proc = L.foldl' (\c t->IM.insertWith (+) t (-1) c) counter ts_

    if Nothing==(find (<0) . IM.elems $ proc)
    then putStr "YES"
    else putStr "NO"

Measured memory_bytes: 60796
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
struct Node{
	int l,r,d;
}s[maxn];
vector<int>a,b;
bool cmp(int a,int b){
	return s[a].d<s[b].d;
}
priority_queue<int,vector<int>,greater<int> >aa,bb;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n;
		scanf("%d",&n);
		ll ans=0;
		FOR(i,0,n){
			scanf("%d%d%d",&s[i].d,&s[i].l,&s[i].r);
			if(s[i].l>s[i].r)a.push_back(i);else {
				b.push_back(i);
				s[i].d=n-s[i].d;
			}
			ans+=min(s[i].l,s[i].r);
		}
		sort(a.begin(),a.end(),cmp);
		sort(b.begin(),b.end(),cmp);
		FOR(i,0,a.size()){
			if(aa.size()==s[a[i]].d && aa.top()<abs(s[a[i]].r-s[a[i]].l)){
				aa.pop();
				aa.push(s[a[i]].l-s[a[i]].r);
			}else if(s[a[i]].d>aa.size())aa.push(s[a[i]].l-s[a[i]].r);
		}
		FOR(i,0,b.size()){
			if(!s[b[i]].d)continue;
			if(bb.size()==s[b[i]].d && bb.top()<abs(s[b[i]].r-s[b[i]].l)){
				bb.pop();
				bb.push(s[b[i]].r-s[b[i]].l);
			}else if(s[b[i]].d>bb.size())bb.push(s[b[i]].r-s[b[i]].l);
		}
		while(!aa.empty())ans+=aa.top(),aa.pop();
		while(!bb.empty())ans+=bb.top(),bb.pop();
		a.clear(),b.clear();
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 7492
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define ls id << 1
#define rs id << 1 | 1
using namespace std;
typedef long long ll;
int n, k;
const int N = 100050;
const ll mod = 1e9 + 7;
ll ans = 1;
struct edge
{
    int v, nxt;
} e[N << 1];
int col[N];
int dep[N];
int head[N], ecnt;
ll a[N];
int f[N], son[N];
void ad(int u, int v)
{
    e[++ecnt].v = v;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

void dfs1(int u, int fa)
{
    for (int i = head[u]; i; i = e[i].nxt)
    {
        int v = e[i].v;
        if (v == fa)
            continue;
        f[v] = u;
        son[u]++;
        dep[v] = dep[u] + 1;
        dfs1(v, u);
    }
}
void dfs2(int u, int fa, ll val)
{
    int t = son[u], nv = k;
    t--;
    a[u] = val;
    for (int i = head[u]; i; i = e[i].nxt)
    {
        int v = e[i].v;
        if (v == fa)
            continue;
        if (dep[v] <= 1)
        {
            dfs2(v, u, --nv);
        }
        else
        {
            dfs2(v, u, k - 2 - t);
            t--;
        }
    }
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i < n; ++i)
    {
        int x, y;
        cin >> x >> y;
        ad(x, y), ad(y, x);
    }
    dfs1(1, 0);
    dfs2(1, 0, k);
    for (int i = 1; i <= n; ++i)
    {
        ans *= a[i];
        ans %= mod;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main(void) {
  int n, k; cin >> n >> k;
  double ans = 0.0;
  for(int i=1; i<=n; i++) {
    int x = i;
    int cnt = 1;
    while(x < k) {
      x *= 2;
      cnt *= 2;
    }
    ans += 1.0/(cnt*n);
  }

  printf("%.10lf\n", ans);

  return 0;
}



// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    if (s[1] == 'B')
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1,0));
    dp[0][0] = 0;
    rep(i,s.size()) dp[i+1][0] = i+1;
    rep(j,t.size()) dp[0][j+1] = j+1;
    rep(i,s.size())rep(j,t.size()){
        dp[i+1][j+1] = min(dp[i+1][j],dp[i][j+1]) + 1;
        dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j] + (s[i]==t[j]?0:1));
    }
    cout << dp.back().back() << endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> ans(n);
	int cnt = 1;
	rep(i, n - 1) {
		if (s[i] == 'R') {
			if (s[i] == s[i + 1]) cnt++;
			else {
				if (cnt % 2 == 0) {
					ans[i] += cnt / 2;
					ans[i + 1] += cnt / 2;
				}
				else {
					ans[i] += (cnt + 1) / 2;
					ans[i + 1] += (cnt - 1) / 2;
				}
				cnt = 1;
			}
		}
	}
	cnt = 1;
	reverse(s.begin(), s.end());
	reverse(ans.begin(), ans.end());
	rep(i, n - 1) {
		if (s[i] == 'L') {
			if (s[i] == s[i + 1]) cnt++;
			else {
				if (cnt % 2 == 0) {
					ans[i] += cnt / 2;
					ans[i + 1] += cnt / 2;
				}
				else {
					ans[i] += (cnt + 1) / 2; 
					ans[i + 1] += (cnt - 1) / 2;
				}
				cnt = 1;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	rep(i, n) cout << ans[i] << (i == n - 1 ? "\n" : " ");
	return 0;
}


Measured memory_bytes: 1024
using System;

class A
{
    static void Main()
    {
        int[] i = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        int A = i[0];
        int B = i[1];
        int C = i[2];
        int D = i[3];
        for (; ; )
        {
            if (C - B <= 0) { Console.WriteLine("Yes"); break; }
            else C -= B;
            if (A - D <= 0) { Console.WriteLine("No"); break; }
            else A -= D;

        }
    }
}

Measured memory_bytes: 27500
#include<stdio.h>

int main(){
    int n,k,r,s,p;
    scanf("%d %d",&n,&k);
    scanf("%d %d %d",&r,&s,&p);
    char t[n];
    scanf("%s",t);
    int ans=0;
    for(int i=0;i<k;i++){
        int tmp=i;
        char pre='a';
        while(tmp<n){
            if(t[tmp]!=pre){
                switch (t[tmp]){
                    case 'r':
                        ans=ans+p;
                        break;
                    case 'p':
                        ans=ans+s;
                        break;
                    case 's':
                        ans=ans+r;
                        break;
            
                    default:
                        break;
                }
                pre=t[tmp];
            }else{
                pre='a';
            }
            tmp=tmp+k;
        }
    }
    printf("%d",ans);
    return 0;
}

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

#include <string.h> 
#include<cstring>
using namespace std;

int main(){
	string moji;
    cin >> moji;
    int n = moji.size();
    int flag = 0;
    for(int i =0;i<n;i++){
    	for(int j = i + 1 ; j < n; j++){
        	if(moji[i]==moji[j]){
            	flag =1;
            }
        }
    }
  	if(flag == 0){
    	cout << "yes"<< endl;
    }else{
    cout << "no"<< endl;
    }	
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main(void)
{
    //入力
    long long A, B, K;
    cin>>A>>B>>K;

    //計算
    for(long long i=0; i<K; i++)
    {
        //奇数だったら一枚食べる
        if(i%2 == 0)
        {
            //高橋君
            if(A%2 == 1) A-=1;
            B += A/2;
            A /= 2;
        }
        else
        {
            //青木君
            if(B%2 == 1) B-=1;
            A += B/2;
            B /= 2;
        }
    }

    //出力
    cout<<A<<" "<<B<<endl;

    return 0;
}

Measured memory_bytes: 256
#abc162d
n=int(input())
s=input()
r=g=b=0
for c in s:
 if c=='R':
  r+=1
 elif c=='G':
  g+=1
 else:
  b+=1
all=r*g*b
sub=0
for i in range(n):
 for j in range(i+1,n):
  if s[i]==s[j]:
   continue
  k=j*2-i
  if k>=n or s[k]==s[i] or s[k]==s[j]:
   continue
  sub+=1
print(all-sub)


Measured memory_bytes: 9208
// ABC 155-C
// 2020.2.16 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef long long ll;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	do c = gc();
	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

ll ins() { // 文字列の入力　スペース以下の文字で入力終了
    ll n = 0;
	int c;
   	do c = gc();
	while (isspace(c));
    int w = 0;
	do n = (n << 5) + (c - 'a'+1), ++w;
    while ((c = gc()) > ' ');
    return n << 5*(10-w);
}

void outs(ll s) {
    int i;
    char a[20];
    i = 0; while (s) {
        if (s & 31) a[i++] = (s & 31) + 'a'-1;
        s >>= 5;
    }
    while (i--) pc(a[i]);
    pc('\n');
}

// 数値のハッシュ関数
#define HASHSIZ 4999999
typedef struct { ll s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

int insert(ll s, int id) {
    HASH *tp = hash + (int)(s % HASHSIZ);
	while (tp->s) {
		if (tp->s == s) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

#define MAX 200005
typedef struct { ll s; int n; } T;
T tbl[MAX];

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	int t1[1 << B], t2[1 << B];

	T *tmp = malloc(n * sizeof(T));
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].s >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].s >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].s >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].s >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
#undef B
}

int main()
{
	int i, N, K, ma;

	ma = 0, K = 0;
    N = in(); while (N--) {
		tbl[K].s = ins();
		if ((i = insert(tbl[K].s, K)) < 0) i = K++;
		if (++tbl[i].n > ma) ma = tbl[i].n;
	}
	N = 0;
	for (i = 0; i < K; ++i) if (tbl[i].n == ma) {
		if (N != i) tbl[N].s = tbl[i].s;
        ++N;
	}
	Usort(tbl, N);
//printf("N=%d\n", N);
	for (i = 0; i < N; ++i) outs(tbl[i].s);
	return 0;
}


Measured memory_bytes: 84480
while True:
    flg = True
    S = input()
    if S == '.':
        exit()
    brackets = []
    for c in S:
        if c == '[':
            brackets.append('[')
        elif c == ']':
            if len(brackets) == 0:
                flg = False
                break
            if brackets.pop() != '[':
                flg = False
                break
        elif c == '(':
            brackets.append('(')
        elif c == ')':
            if len(brackets) == 0:
                flg = False
                break
            if brackets.pop() != '(':
                flg = False
                break
        else:
            pass
    if len(brackets) > 0:
        flg = False
    if flg:
        print('yes')
    else:
        print('no')

Measured memory_bytes: 6720
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

class UnionFind {
    int[] parent;
    this(int N) {
        parent = new int[N];
        parent[] = -1;
    }
    int root(int x) {
        if (parent[x] == -1) return x;
        return parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        parent[y] = x;
    }
    bool query(int x, int y) {
        return root(x) == root(y);
    }
}

void main() {
    int N, Q; scanf("%d %d\n", &N, &Q);
    auto uf = new UnionFind(N);
    foreach (i; 0 .. Q) {
        int t, x, y; scanf("%d %d %d\n", &t, &x, &y);
        if (t == 0) {
            uf.merge(x, y);
        } else {
            writeln(cast(int)uf.query(x, y));
        }
    }
}

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

int main()
{
    int n;
    cin >> n;
    ll k;
    cin >> k;
    int a[200005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    bool b[200005]{0};
    int u = 0;
    while(!b[u]){
        if(k == 0){
            cout << u + 1 << endl;
            return 0;
        }
        b[u] = true;
        u = a[u];
        k--;
    }
    fill(b, b + n, false);
    ll l = 0;
    while(!b[u]){
        if(k == 0){
            cout << u + 1 << endl;
            return 0;
        }
        b[u] = true;
        u = a[u];
        k--;
        l++;
    }
    k %= l;
    fill(b, b + n, false);
    while(!b[u]){
        if(k == 0){
            cout << u + 1 << endl;
            return 0;
        }
        b[u] = true;
        u = a[u];
        k--;
    }
}


Measured memory_bytes: 4572
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	string s="Sunny",c="Cloudy",r="Rainy",ans;
	if(S==s)
		ans=c;
	else if(S==c)
		ans=r;
	else
		ans=s;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll moddividing(ll x,ll y){
    vector<ll> vec(30);
    rep(i,30){
        vec[i] = y;
        y = y * y % 1000000007;
    }
    ll c = x;
    c = c * vec[0] % 1000000007;
    c = c * vec[2] % 1000000007;
    c = c * vec[9] % 1000000007;
    c = c * vec[11] % 1000000007;
    c = c * vec[14] % 1000000007;
    c = c * vec[15] % 1000000007;
    c = c * vec[17] % 1000000007;
    c = c * vec[19] % 1000000007;
    c = c * vec[20] % 1000000007;
    c = c * vec[23] % 1000000007;
    c = c * vec[24] % 1000000007;
    c = c * vec[25] % 1000000007;
    c = c * vec[27] % 1000000007;
    c = c * vec[28] % 1000000007;
    c = c * vec[29] % 1000000007;
    return c;
}

int main(){
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll len = S.size();
    vector<ll> exp_25(2000001);
    ll num = 1;
    for (ll i = 0; i < 2000001; i++){
        exp_25[i] = num;
        num = (num * 25) % 1000000007;
    }
    vector<ll> exp_26(2000001);
    num = 1;
    for (ll i = 0; i < 2000001; i++){
        exp_26[i] = num;
        num = (num * 26) % 1000000007;
    }
    vector<ll> fact(2000001);
    num = 1;
    for (ll i = 0; i < 2000001; i++){
        fact[i] = num;
        num = (num * (i + 1)) % 1000000007;
    }
    ll ans = 0;
    for (ll i = len; i <= len + K; i++){
        ll comb = moddividing(fact[i - 1], (fact[len - 1] * fact[i - len]) % 1000000007);
        comb = (comb * exp_25[i - len]) % 1000000007;
        comb = (comb * exp_26[len + K - i]) % 1000000007;
        ans = (ans + comb) % 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 51184
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 998244353;

lint powmod(long x, long n){
  lint ret = 1;
  while(n > 0){
    if(n&1) ret *= x, ret %= mod, n -= 1;
    else x *= x, x %= mod, n >>= 1;
  }
  return ret;
}

vector<lint> fact;
vector<lint> revfact;

void setfact(int n){
  fact.resize(n+1); revfact.resize(n+1);
  fact[0] = 1;
  rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;
  
  revfact[n] = powmod(fact[n], mod-2);
  for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

lint getC(int n, int r){
  return fact[n] * revfact[r] % mod * revfact[n-r] % mod;
}

int main(){
    int n;
    lint a, b, K;
    scanf("%d%lld%lld%lld", &n, &a, &b, &K);
    
    setfact(n);
    lint ans = 0;
    rep(p, n+1)if((K-a*p) % b == 0){
        lint q = (K-a*p) / b;
        if(0<=q && q<=n) (ans += getC(n, p) * getC(n, q) % mod) %= mod;
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ar array
#define db double
#define pow pw
const db pi = 3.14159265358979323846;
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
const int mxn=3e5+7,INF=1e9+7;
int m,n,k;
int r[mxn],c[mxn];
map<pair<int,int>,int> a;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>m>>n>>k;
    for (int i=0;i<k;i++)
    {
        int u,v;
        cin>>u>>v;
        r[u]++;
        c[v]++;
        a[{u,v}]=1;
    }
    int t1=0,t2=0,ans=0;
    vector<int> d,d2;
    for (int i=1;i<=m;i++) t1=max(t1,r[i]);
    for (int i=1;i<=m;i++)
        if (r[i]==t1) d.push_back(i);
    for (int i=1;i<=n;i++) t2=max(t2,c[i]);
    for (int i=1;i<=n;i++)
        if (c[i]==t2) d2.push_back(i);
    for (int g : d)
        for (int h : d2)
    {
        if (a[{g,h}]==0)
            {
                ans=max(ans,r[g]+c[h]-a[{g,h}]);
                cout<<ans;
                return 0;
            }
            else ans=max(ans,r[g]+c[h]-a[{g,h}]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35008
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Storable as V

main=do
    n<-readLn::IO Int
    as<-V.fromList.sort.map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO(V.Vector Int)
    print $ tsearch as (0,n-1)

-- 三分探索 (最小値)
-- b<-[l..r]において最小のcalc bを求める
tsearch as (l,r)
    | (r-l)<3  = minimum $ map calc [l..r]
    | c1 < c2  = tsearch as (l,b2)
    | c1 == c2 = tsearch as (b1,b2)
    | c1 > c2  = tsearch as (b1,r)
    where
        c1 = calc b1
        c2 = calc b2
        b1 = l+(r-l)`div`3
        b2 = l+((r-l)`div`3)*2
        calc b = V.sum $ V.map (\a->abs $ a-e) as
            where e = as V.! b

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;
long long gcd(long long a, long long b) {
    return b != 0 ? gcd(b, a % b) : a;
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
long long extgcd(long long a, long long b, long long &x, long long &y) {
    long long g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int main() {
   int N,u,v;
   cin>>N>>u>>v;
   int A[N-1],B[N-1];
   for(int i=0;i<N-1;i++){
       cin>>A[i]>>B[i];
   }
   vector<vector<int> >graph(N+1);
   for(int i=0;i<N-1;i++){
       graph[A[i]].push_back(B[i]);
       graph[B[i]].push_back((A[i]));
   }
   int aoki[N+1];
   for(int i=0;i<N+1;i++){
       aoki[i]=-1;
   }
   aoki[0]=MAX;
   aoki[v]=0;

   queue<int>bfs;
   bfs.push(v);
   while(!bfs.empty()){
       int l=bfs.front();
       bfs.pop();
       for(int i=0;i<graph[l].size();i++){
           if(aoki[graph[l][i]]==-1){
               aoki[graph[l][i]]=aoki[l]+1;
               bfs.push(graph[l][i]);
           }
       }
   }


    int takahashi[N+1];
    for(int i=0;i<N+1;i++){
        takahashi[i]=-1;
    }
    takahashi[0]=MAX;
    takahashi[u]=0;
    bfs.push(u);
    while(!bfs.empty()){
        int l=bfs.front();
        bfs.pop();
        for(int i=0;i<graph[l].size();i++){
            if(takahashi[graph[l][i]]==-1){
                takahashi[graph[l][i]]=takahashi[l]+1;
                bfs.push(graph[l][i]);
            }
        }
    }
    pair<int,int>aokii[N+1];
    pair<int,int>takahashii[N+1];
    for(int i=0;i<N+1;i++){
        aokii[i]=make_pair(aoki[i],i);
        takahashii[i]=make_pair(takahashi[i],i);
    }
    sort(aokii,aokii+N+1);
    reverse(aokii,aokii+N+1);
    sort(takahashii,takahashii+N+1);
    reverse(takahashii,takahashii+N+1);
    int mokutekiti=-1;
    for(int i=0;i<N+1;i++){
        //cout<<aokii[i].first<<endl;
        //cout<<takahashi[aokii[i].second]<<endl;
        //cout<<aokii[i].second<<endl;
        //cout<<""<<endl;
        if(aokii[i].first==MAX||takahashi[aokii[i].second]==MAX){
           continue;
       }
        if(aokii[i].first>takahashi[aokii[i].second]){
            mokutekiti=aokii[i].second;
            //cout<<mokutekiti<<endl;
            break;
        }
    }
    if((aoki[mokutekiti]-takahashi[mokutekiti])%2==0&&takahashi[mokutekiti]!=0){
        cout<<aoki[mokutekiti]-1<<endl;
    }else{
        cout<<aoki[mokutekiti]-1<<endl;
        //cout<<mokutekiti<<endl;
    }












}


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

int main() {
  while (true) {
    int t, p, r;
    cin >> t >> p >> r;
    if (t == 0) return 0;

    int solved[t + 1], wrong[t + 1][p + 1], penalty[t + 1];
    for (int i = 0; i < t + 1; i++) {
      solved[i] = 0;
      penalty[i] = 0;
      for (int j = 0; j < p + 1; j++)
	wrong[i][j] = 0;
    }

    for (int i = 0; i < r; i++) {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      if (message == "CORRECT") {
	solved[tid]++;
	penalty[tid] += time + wrong[tid][pid] * 1200;
      } else {
	wrong[tid][pid]++;
      }
    }

    int rank[t + 1];
    for (int i = 1; i < t + 1; i++)
      rank[i] = i;
    
    for (int i = 1; i < t + 1; i++) {
      for (int j = i; j > 1; j--) {
	if (solved[j - 1] < solved[j]) {
	  swap(rank[j - 1], rank[j]);
	  swap(solved[j - 1], solved[j]);
	  swap(penalty[j - 1], penalty[j]);
	} else if (solved[j - 1] == solved[j] && penalty[j - 1] > penalty[j]) {
	  swap(rank[j - 1], rank[j]);
	  swap(solved[j - 1], solved[j]);
	  swap(penalty[j - 1], penalty[j]);
	}
      }
    }

    for (int i = 1; i < t + 1; i++) {
      cout << rank[i] << ' ' << solved[i] << ' ' << penalty[i] << endl;
    }
  }
}

Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define F first
#define S second
using namespace std;

int Q = 1e6, h1, h2, cut = 10;
int n, s, D, l, r, up, mx, cnt, mxx, xx, a[30], b[400][30], la[400], u[400], ans[400], o[400];
pair<int, int> c[400][30];
bool v[400][30];

int f(int p, int q1, int q2) {
	int sz = q2 - q1 + 1;
	return p * sz * (sz + 1) / 2;
}

int main()
{
	int i, j, k, t, x, t1, t2;
	srand(time(NULL));
	cin >> D;
	for (i = 0; i < 26; i++) {
		scanf ("%d", &a[i]);
	}
	for (i = 1; i <= D; i++) {
		mxx = -2e9;
		for (j = 0; j < 26; j++) {
			scanf ("%d", &b[i][j]);
		}
		for (j = 0; j < 26; j++) {
			cnt = b[i][j];
			for (k = 0; k < 26; k++) {
				if (k == j) continue;
				cnt -= (i - o[k]) * a[k];
			}
			if (cnt > mxx) {
				xx = j;
				mxx = cnt;
			}
		}
		o[xx] = i;
		ans[i] = u[i] = xx;
	}
//	for (i = 1; i <= D; i++) {
//		ans[i] = u[i] = 1;
//	}
//	for(i = 1; i <= D; i++) {
//		printf("%d\n", ans[i] + 1);
//	}

	for (i = 1; i <= D; i++){
//		scanf ("%d", &t);
		t = u[i];
		s += b[i][t];
		la[t] = i;

		for (j = 0; j < 26; j++) {
			s -= a[j] * (i - la[j]);
		}
		v[i][t] = 1;
	}
//	cout << s << endl;
//	cin >> Q;
	for (i =0; i < 26; i++) {
		v[0][i] = 1;
		v[D + 1][i] = 1;
	}
	mx = s;
	while (Q--) {
//		scanf ("%d %d", &t1, &t2);
		t1 = rand() % D + 1;
		t2 = rand() % 26;
		if (u[t1] == t2) t2 = (t2 + 1) % 26;
		x = u[t1];
		s -= b[t1][x];
		v[t1][x] = 0;
		v[t1][t2] = 1;
		u[t1] = t2;
		s += b[t1][t2];
		for (l = t1 - 1; l >= 0; l--) if (v[l][x]) break;
		for (r = t1 + 1; r <= D + 1; r++) if (v[r][x]) break;
		s += f(a[x], l + 1, t1 - 1);
		s += f(a[x], t1 + 1, r - 1);
		s -= f(a[x], l + 1, r - 1);
		for (l = t1 - 1; l >= 0; l--) if (v[l][t2]) break;
		for (r = t1 + 1; r <= D +1; r++) if (v[r][t2]) break;
		s += f(a[t2], l + 1, r - 1);
		s -= f(a[t2], l + 1, t1 - 1);
		s -= f(a[t2], t1 + 1, r - 1);
		if (s > mx) {
			up = 0;
			for (i = 1; i <= D; i++) {
				ans[i] = u[i];
			}
			mx = s;
		} else up++;
		if (up == cut) {
			up = 0;
			memset(v, 0, sizeof(v));
			for (i =0; i < 26; i++) {
				v[0][i] = 1;
				v[D + 1][i] = 1;
			}
			for (i = 1; i <= D; i++) {
				u[i] = ans[i];
				v[i][ans[i]] = 1;
			}
			s = mx;
		}
	}
	for (i = 1; i <= D; i++) {
		printf("%d\n", ans[i] + 1);
	}
    return 0;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    if(N%10==3) cout << "bon"<<endl;
    else if(N%10==0||N%10==1||N%10==6||N%10==8) cout<<"pon"<<endl;
    else cout << "hon" << endl;





}


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

int main(){
    string s;
    cin >> s;
    string ans = "CODEFESTIVAL2016";
    int n = 0;
    for(int i = 0; i < 16; i++){
        if(s[i] != ans[i]){
            n++;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int N,D;
  int ans=0;
  cin >>N>>D;
  while(N>0)
  {
    ans++;
    N-=2*D+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

S = list(stdin.readline().rstrip())
Q = int(stdin.readline().rstrip())

b = [""]
f = [""]

t = 0

for i in range(Q):
    T = stdin.readline().rstrip().split()
    if(len(T) == 1):
        t += 1
        continue
    else :
        F,C = int(T[1]),T[2]

    if t%2 == 0: #反転なし
        if F == 1:
            b.append(C)
        else :
            f.append(C)
    else: #反転あり
        if F == 1:
            f.append(C)
        else :
            b.append(C)



if(t%2 == 0):
    print(''.join(b[::-1] + S + f))
else:
    print(''.join(f[::-1] + S[::-1] + b))

    

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

int main(){
    int a,b;
    cin >> a >> b;
    if (a*b % 2 == 0) puts("Even");
    else puts("Odd");
    return 0;
}

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

int n,a[100005],b[100005],c[100005];
int f[100005][4];

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

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N+1),b(N+1),c;
    REP(i,1,N+1){
        cin >> a[i];
    }
    for(ll i=N;0<i;i--){
        ll sum = 0;
        ll ind = i;
        while(ind <= N){
            sum += b[ind];
            ind += i;
        }
        if((sum % 2) != a[i]){
            b[i] = 1;
            c.push_back(i);
        }
    }
    if(c.size()>0){
        cout << c.size() << endl;
        PR(c,c.size());
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 6004
#include <bits/stdc++.h>
#define LL long long

const int mod = 1e9 + 7;
const int N = 5e5 + 5;

int n, m, fac[N] = { 1 }, inv[N] = { 1 };
LL ans;

int mul(int ta, int tb) {
	int ret;
	__asm__ __volatile__ ("\tmull %%ebx\n\tdivl %%ecx\n":"=d"(ret):"a"(ta), "b"(tb), "c"(mod));
	return ret;
}

int qpow(int bas, int po) {
	int res = 1;
	while(po) {
		if(po & 1)
			res = mul(res, bas);
		bas = mul(bas, bas);
		po >>= 1;
	}
	return res;
}

int C(int tn, int tm) {
	return mul(fac[tn], mul(inv[tm], inv[tn - tm]));
}

int A(int tn, int tm) {
	return mul(fac[tn], inv[tn - tm]);
}

int32_t main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = qpow(fac[i], mod - 2);
	}
	for(int i = 0; i <= n; ++i) {
		int flg = (i & 1) ? -1 : 1;
		int tmp = mul(C(n, i), mul(A(m, i), qpow(A(m - i, n - i), 2)));
		ans += flg * tmp;
		ans %= mod, (ans += mod) %= mod;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 7588
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}

	cout << ans << endl;
}

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

#define FOR( i, m, n )   for( int i = m; i < n; i++ )
#define REP( i, n )      FOR( i, 0, n )
#define ALL( a )         (a).begin(), (a).end()

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

  int x, cnt = 0;
  REP( i, n ){
    cin >> x;
    if( x % 2 == 0 ) cnt++;

  }

  cout << cnt << endl;
}



Measured memory_bytes: 3100
from collections import deque
h, w = map(int, input().split())
maze = []
total_white_square = 0
for i in range(h):
    row = list(input())
    total_white_square += row.count('.')
    maze.append(row)
visited = [[False for i in range(w)] for j in range(h)]
queue = deque()
start = (0, 0)
end = (h - 1, w - 1)
queue.append((start, 1))
visited[0][0] = True
num_white_row = 0
while len(queue) > 0:
    curr, time = queue.popleft()
    if curr == end:
        num_white_row = time
        break
    x, y = curr
    if x - 1 >= 0 and not visited[x - 1][y] and maze[x - 1][y] == '.':
        visited[x - 1][y] = True
        queue.append(((x - 1, y), time + 1))
    if x + 1 <= h - 1 and not visited[x + 1][y] and maze[x + 1][y] == '.':
        visited[x + 1][y] = True
        queue.append(((x + 1, y), time + 1))
    if y - 1 >= 0 and not visited[x][y - 1] and maze[x][y - 1] == '.':
        visited[x][y - 1] = True
        queue.append(((x, y - 1), time + 1))
    if y + 1 <= w - 1 and not visited[x][y + 1] and maze[x][y + 1] == '.':
        visited[x][y + 1] = True
        queue.append(((x, y + 1), time + 1))
if num_white_row != 0:
    print(total_white_square - num_white_row)
else:
    print(-1)

Measured memory_bytes: 3316
//abc173_a.cpp
//Sun Jul  5 20:55:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	n = n%1000;

	if (n>0){
		cout << 1000-n<< endl;
	}else {
		cout << 0 << endl;
	}
//	printf("%.4f\n",ans);
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll N,M,K,Q;
ll dp[5001][5001];

int main(){
  cin>>N>>M>>K>>Q;
  dp[0][0]=1;
  rep(i,M){
    ll crtdp=0;
    rep(A,N){
      ll j=(N-A)%N;
      if((j/K)%2==0)(crtdp+=dp[i][A])%=mod;
    }
    rep(B,2*K){
      for(ll b=B;b<N;b+=2*K)dp[i+1][b]=crtdp;
      rep(j,N/K){
        ll a=(j*K+(B+1))%N;
        if(j%2==0) (crtdp+=dp[i][a])%=mod;
        else (crtdp+=mod-dp[i][a])%=mod;
      }
    }
  }

  while(Q--){
    ll a,b,c;
    cin>>a>>b>>c;
    c-=a;
    if(c<0)c+=N;
    cout<<dp[b][c]<<endl;
  }
  return 0;
}



Measured memory_bytes: 198452