akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int count = 0, n;
  string s;
  cin >> n >> s;
  int max_count = 0;

  for(char c : s) {
    if(c == 'I') {
      count++;
      if(count >= max_count) {
        max_count = count;
      }
    }
    else if(c == 'D'){
      count--;
    }
  }
  cout << max_count << endl;
}

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

using namespace std;

bool IsPrime(int n)
{
	if (n < 2)
	{
		return false;
	}
	else if (n == 2)
	{
		return true;
	}


	if (n % 2 == 0)
	{
		return false;
	}

	for (int i = 3; i <= n / i; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	const int Max = 100000;
	vector<int> table(Max);

	int count = 0;
	for (int i = 0; i < Max; i++)
	{
		if (IsPrime(i) && IsPrime((i + 1) / 2))
		{
			count++;
		}

		table[i] = count;
	}

	int Q;
	int l, r;

	cin >> Q;

	vector<int> ans(Q);

	for (int i = 0; i < Q; i++)
	{
		cin >> l >> r;
		ans[i] = table[r] - table[l];

		if (table[l - 1] < table[l])
		{
			ans[i]++;
		}
	}

	for (int i = 0; i < Q; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int partition(int*,int,int);

int main(){
  int n,i,k;
  scanf("%d",&n);

  int A[n];

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  
  k=partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else if(i==k) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }

  return 0;
}

int partition(int *A,int p,int r){
  int x=A[r],i=p-1,j,m;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      m=A[j];
      A[j]=A[i];
      A[i]=m;
    }
  }
    m=A[i+1];
    A[i+1]=A[r];
    A[r]=m;
    return i+1;
}




Measured memory_bytes: 2244
private const val ACTIVITY_COUNT = 3
fun main() {
    val days = readLine()!!.toInt()
    val h = mutableListOf<List<Int>>()
    val dp = Array(days) { IntArray(ACTIVITY_COUNT) { 0 } }
    for (i in 0 until days) {
        val input = readLine()!!.split(" ").map { it.toInt() }
        h.add(input)
    }
    dp[0][0] = h[0][0]
    dp[0][1] = h[0][1]
    dp[0][2] = h[0][2]

    for (i in 1 until days) {
        for (j in 0 until ACTIVITY_COUNT) {
            val a = Math.floorMod(j + 1, 3)
            val b = Math.floorMod(j + 2, 3)
            dp[i][j] = h[i][j] + Math.max(dp[i-1][a], dp[i-1][b])
        }
    }

    val ans = Math.max(dp[days-1][0], Math.max(dp[days-1][1], dp[days-1][2]))
    println(ans)
}

Measured memory_bytes: 73860
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(M)]

T = [1 for _ in range(N)]
for a,b in AB:
    if H[a-1] >= H[b-1]:
        T[b-1] = 0
    if H[a-1] <= H[b-1]:
        T[a-1] = 0

print(sum(T))


Measured memory_bytes: 31944
#include <stdio.h>

int main()
{
    int N,cnt=0,cnt_a=0,i,j;
    scanf("%d",&N);
    for(i=N;i>0;i--){
        for(j=N;j>0;j--){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            if(i%2!=0){
                cnt_a++;
            }
            
        }
        cnt=0;
    }
    
    printf("%d\n",cnt_a);

    return 0;
}

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

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

  int cur = 0;
  for(int i=0;i<100;i++){
    if(cur%60 <= c && c <= cur%60+a){
      cout << cur/60*60 + c << endl;
      return 0;
    }
    cur += a+b;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll a[N];
int main()
{
	ll n, x;
	cin >> n >> x ;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	ll s = 0, i = 0;
	for(i = 1; i <= n; i ++)
	{
		if(a[i] + s > x)
			break;
		s += a[i];
	}
	i --;
	if(i == n)
	{
		if(x - s > 0)
			i --;
	}
	cout << i;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main() {
  int N;
  cin >> N;
  int ma = -100000, mi = 1<<30;
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    ma = max(ma, a);
    mi = min(mi, a);
  }
  cout << ma - mi << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>
int main(){
  int x,y;
  for(;;){
    scanf(" %d %d",&x,&y);
    if(x==0&&y==0){
      return 0;
    } else if (x<y){
      printf("%d %d\n",x,y);
    } else if (x>y){
      printf("%d %d\n",y,x);
    } else if(x==y){
      printf("%d %d\n",x,y);
    }
  }
}

Measured memory_bytes: 2660
import itertools
import math
from functools import reduce
K = int(input())
n = list(range(1, K+1))
def gcd(numbers):
  return reduce(math.gcd, numbers)
ans = 0
for x in itertools.combinations_with_replacement(n, 3):
  if x[0] == x[1] == x[2]: ans += gcd(x)
  elif x[0] != x[1] and x[0] != x[2] and x[1] != x[2]:
    ans += gcd(x) * 6
  else: ans += gcd(x) * 3
print(ans)

Measured memory_bytes: 9644
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String ans = "";

    for (int i = 0; i < 3; i++) {
      String s = sc.next();
      ans += s.charAt(0);
    }
    
    System.out.println(ans);

  }
}

Measured memory_bytes: 38928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), copyA(n); rep(i, n) cin >> A[i];
  copy(all(A), copyA.begin());
  sort(all(copyA));
  rep(i, n) {
    if(A[i] == copyA[n-1]) cout << copyA[n-2] << endk;
    else cout << copyA[n-1] << endk;
  }
  return 0;
}


Measured memory_bytes: 6368
A, B, C = list(map(int, input().split()))

# B - 1 >= C なら、美味しいクッキーはすべて食べられる
if B - 1 >= C:
  print(B + C)
else:
  # A <= C- Bなら、残りの美味しいクッキーも全て食べられる
  if A >= C - B:
    print(B + C)
  else:
    # そうでなければ、C - B 枚の中から最大 A 枚の美味しいクッキーを食べられる
    print(A + 2*B + 1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    string in;
    cin >> n;
    cin >> in;
    long long cntW = 0;
    long long cntR = 0;
    for(long long i = 0; i<in.length(); i++){
        if(in[i]=='W')cntW++;
        if(in[i]=='R')cntR++;
    }
    string target = in;
    for(long long i = 0; i<target.length(); i++){
        if(i < cntR){
            target[i]='R';
        }else{
            target[i]='W';
        }
    }
    long long ans = 0;
    for(long long i = 0; i<target.length(); i++){
        if(in[i]!=target[i])ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
	int n;
	int a[1000];
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}


	for (i = 0; i < n; i++)
	{
		if (a[i] % 2 != 0)
		{
			continue;
		}
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				printf("DENIED\n");
				return 0;
			}
	}
	
	printf("APPROVED\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
 
//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
 
#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
 
//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;
 
 
int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}
 
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};
 
 
 
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
 
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}
 
 
 
 
int main(){
 
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, T;
    ll sum = 0;
    cin >> N >> T;

    vll t(N+1);
    rep(i, N){
        cin >> t[i];
    }
    t[N] = LLONG_MAX;
    rep(i, N){
        if(t[i+1]-t[i] >= T){
            sum += T;
        }
        else{
            sum += t[i+1]-t[i];
        }


    }

    ppp(sum);






 
    return 0;
}

Measured memory_bytes: 1792
N,M = map(int,input().split())
Stlist = [1]*N
for i in range(M):
    breakstair = int(input())
    Stlist[breakstair-1] = 0
Comb = [1,2]
if N == 1:
    Comb = Stlist
else:
    if Stlist[0] == 0:
        Comb[0] = 0
        Comb[1] = 1
    if Stlist[1] == 0:
       Comb[1] = 0
    for i in range(2,N):
        Comb.append((Comb[i-1] + Comb[i-2])%(10**9+7))
        if Stlist[i] == 0:
            Comb[i] = 0
print(Comb[-1])

Measured memory_bytes: 13372
#include <cstdlib>
#include <iostream>
#include <numeric>
using namespace std;

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

	int s[10];
	for(auto &e : s) cin >> e;
	cout << accumulate(s, s + 10, 0) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
           int n,m,p=0;
           cin>>n;
            m=n;
            while(m){
                p+=m%10;
                m/=10;
            }
            if(n%p)cout<<"No";
           else cout<<"Yes";

           return 0;

        }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)-(b)) < EPS)
using namespace std;
typedef long double D;
typedef complex<D> P;
typedef pair<int,int> pii;
typedef pair<D, pii> data;
typedef vector<int> vi;

const D EPS = 1e-10;
const D PI = acos(-1);
const D INF = 1e15;

int n;
string name[110];
D T,r,x[110],y[110],t[110][1100];
D vx[110][1100], vy[110][1100];

vector<D> cal(int a, int b){
  vector<D> res;

  P pa = P(x[a],y[a]), pb = P(x[b],y[b]);
  if( abs(pa-pb)<r+EPS )res.push_back(0);

  int ta=1, tb=1;
  D cur = 0, nxt = min(t[a][ta],t[b][tb]);
  while(!EQ(cur,T)){
    D tx = pa.real() - pb.real(), ty = pa.imag() - pb.imag();
    D tvx = vx[a][ta] - vx[b][tb], tvy = vy[a][ta] - vy[b][tb];
    D A = tvx*tvx + tvy*tvy, B = 2*tvx*tx + 2*tvy*ty, C = tx*tx + ty*ty - r*r;
    D d = B*B - 4*A*C;
    vector<D> sol;

    if(EQ(A,0)){
      if(!EQ(B,0))sol.push_back(-C/B);
    }else if(EQ(d,0)){
      sol.push_back(-B/2/A);
    }else if(d>EPS){
      sol.push_back( (-B - sqrt(d))/2/A );
      sol.push_back( (-B + sqrt(d))/2/A );
    }

    rep(i,sol.size()){
      if(sol[i]+EPS < 0 || nxt-cur+EPS < sol[i])continue;
      res.push_back(cur + sol[i]);
    }

    D dif = nxt - cur;
    pa += P(vx[a][ta]*dif, vy[a][ta]*dif);
    pb += P(vx[b][tb]*dif, vy[b][tb]*dif);

    cur = nxt;
    if(EQ(t[a][ta],cur))ta++;
    if(EQ(t[b][tb],cur))tb++;
    nxt = min(t[a][ta],t[b][tb]);
  }
  return res;
}

bool prop[110];
void dfs(int u, const vector<vi> &g){
  prop[u] = true;
  rep(i,g[u].size()){
    if(!prop[g[u][i]])dfs(g[u][i],g);
  }
}

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  while(cin >> n >> T >> r){
    if(n==0)break;
   
    rep(i,n){
      cin >> name[i];
      cin >> t[i][0] >> x[i] >> y[i];
      for(int j=0;;j++){
	cin >> t[i][j+1] >> vx[i][j+1] >> vy[i][j+1];
	if(EQ(t[i][j+1], T))break;
      }
    }

    vector<data> event;
    rep(i,n)rep(j,i){
      vector<D> sub_event = cal(i,j);
      for(D d : sub_event){
	event.push_back(data(d, pii(i,j)));
      }
    }
    sort(all(event));
    
    memset(prop,0,sizeof(prop));
    prop[0] = true;
    vector<vi> graph(n,vi());

    rep(i,event.size()){
      if(event[i].first>T+EPS)break;
      int a = event[i].second.first, b = event[i].second.second;
      bool f = true;
      rep(j,graph[a].size()){
	if(graph[a][j] == b){ f = false; break; }
      }

      if(f){
	graph[a].push_back(b);
	graph[b].push_back(a);
	prop[a] |= prop[b];
	if(prop[a])dfs(a,graph);
      }else{
	rep(j,graph[a].size()){
	  if(graph[a][j] == b)graph[a].erase(graph[a].begin()+j);
	}
	rep(j,graph[b].size()){
	  if(graph[b][j] == a)graph[b].erase(graph[b].begin()+j);
	}
      }	
    }
    
    vector<string> ans;
    rep(i,n){
      if(prop[i])ans.push_back(name[i]);
    }
    sort(all(ans));
    for(string s : ans)cout << s << endl;
  }
}

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

          using namespace std;
          typedef long long ll;
          int fdf[43434], gfgf[4343];
          int main()
          {
            int n;
            cin >> n;
            for(int i = 1; i <= n; i ++)
            {
              int k;
              cin >> k;
              if(k % 2 == 0)
                if(k % 3 != 0 && k % 5 != 0)
                  return cout << "DENIED", 0;
            }
            cout << "APPROVED";
          }

Measured memory_bytes: 256
a = int(input())
b = list(map(int,input().split()))


for i in range(a - 1):
    #print(b[i],b[i+1])
    if b[i + 1] - b[i] >= 0:
        if b[i + 1] - b[i] >= 1:
            b[i + 1] -= 1
    else:
        print('No')
        exit()

print('Yes')

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

using namespace std;
const int nax = 2e3+2;
int a[nax][nax];
int col_up[nax][nax], col_dw[nax][nax], row_lf[nax][nax], row_rt[nax][nax];
int main(){
  int H, W;
  cin >> H >> W;
  for(int i=1; i<=H; ++i)
    for(int j=1; j<=W; ++j){
      char c; cin >> c;
      if(c == '#')
        a[i][j] = 1;
    }
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      row_lf[i][j] = (a[i][j-1] || j-1 == 0) ? 0 : row_lf[i][j-1] + 1;
    }
    for(int j=W; j>=1; --j){
      row_rt[i][j] = (a[i][j+1] || j+1 > W) ? 0 : row_rt[i][j+1] + 1;
    }
  }
  for(int j=1; j<=W; ++j){
    for(int i=1; i<=H; ++i){
      col_dw[i][j] = (a[i-1][j] || i-1 == 0) ? 0 : col_dw[i-1][j] + 1;
    }
    for(int i=H; i>=1; --i){
      col_up[i][j] = (a[i+1][j] || i+1 > H) ? 0 : col_up[i+1][j] + 1;
    }
  }
  int res = 0;
  for(int i=1; i<=H; ++i){
    for(int j=1; j<=W; ++j){
      if(!a[i][j])
      res = max(res, row_lf[i][j] + row_rt[i][j] + col_up[i][j] + col_dw[i][j]);
    }
  }
  cout << res+1 << "\n";
  return 0;
}


Measured memory_bytes: 78464
import sys
from collections import defaultdict


s = str(input())
n = len(s)
p = 2019

a = []
t = 1
for i in range(n-1, -1, -1):
    a.append((ord(s[i])-ord("0")) * t % p)
    t = t * 10 % p
cum = [0]
for v in a:
    cum.append((cum[-1] + v) % p)

dic = defaultdict(int)
ans = 0
for v in cum:
    ans += dic[v]
    dic[v] += 1
print(ans)


Measured memory_bytes: 96372
#include<stdio.h>
 
int main(){
  int A[100];
  int i,j,n,temp,m;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
   
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
    temp=A[j];
    A[j]=A[j-1];
    A[j-1]=temp;
    m = m + 1;
      }
    }
  }
 
   for(i=0;i<n-1;i++){
     printf("%d ",A[i]);
 
    
    }
 
   printf("%d\n",A[i]);
  printf("%d\n",m);
 
 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string s; cin>>s;
	bool ok=true;
	if(s.size()%2==1){
		ok=false;
	}
	rep(i,0,s.size()){
		if(i%2==0){
			if(s[i]!='h'){
				ok=false;
			}
		}else{
			if(s[i]!='i'){
				ok=false;
			}
		}
	}
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Print_a_Chessboard
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> all = new List<int>();

            //入力
            while (true)
            {
                string input = Console.ReadLine();
                if (input.Equals("0 0"))
                {
                    break;
                }

                string[] temp = input.Split(' ');
                all.Add(int.Parse(temp[0]));
                all.Add(int.Parse(temp[1]));
            }

            //処理
            for (int i = 0; i < all.Count; i += 2)
            {
                for (int j = 0; j < all[i]; ++j)
                {
                    if (j % 2 == 0)
                    {
                        for (int k = 0; k < all[i + 1]; ++k)
                        {
                            if (k % 2 == 1)
                            {
                                Console.Write(".");
                            }
                            else
                            {
                                Console.Write("#");
                            }
                        }
                        Console.WriteLine();
                    }
                    else
                    {
                        for (int k = 0; k < all[i + 1]; ++k)
                        {
                            if (k % 2 == 1)
                            {
                                Console.Write("#");
                            }
                            else
                            {
                                Console.Write(".");
                            }
                        }
                        Console.WriteLine();
                    }
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 17916
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
	int N, M;
	scanf("%d %d", &N, &M);

	int A = M + 2;
	int B = M + 1;
	int C = 2*M + 2;
	for(int i=1, j=0; j < M; i++){
		printf("%d %d\n", i, A - i);
		if(++j < M){
			printf("%d %d\n", B + i, C - i);
			j++;
		}
	}
	return 0;
}

Measured memory_bytes: 1732
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int r[105],c[105],dp[105][105]={0};
int main(){
	int i,j,k,n,len;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d",&r[i],&c[i]);
	for(i=0;i<n-1;i++)
		dp[i][i+1]=r[i]*c[i]*c[i+1];
	for(len=3;len<=n;len++){
		for(i=0;i<n-len+1;i++){
			j=i+len-1;
			dp[i][j]=2147483647;
			for(k=i;k<j;k++){
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+r[i]*c[k]*c[j]);
			}
		}
	}
	printf("%d\n",dp[0][n-1]);
}



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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
double a[maxn];
void run_case()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    double ans = a[1];
    for (int i = 2; i <= n; i++)
    {
        ans = (ans + a[i]) / 2;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3804
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S;
    int K;
    cin >> S >> K;

    int n = S.length();


    vector<int> cnts(27, 0);
    vector<int> A(n, 0);
    iota(A.begin(), A.end(), 0);
    vector<int> tmp(n, 0);

    auto index = [&](int beg, int pos) {
        if (beg + pos >= n) {
            return 0;
        } else {
            return S[beg + pos] - 'a' + 1;
        }
    };

    string res;
    function<bool(int,int,int,int&,int)> dfs = [&](int len, int l, int r, int& idx, int K) -> bool {
        if (l >= r) {
            return false;
        }
        if (++idx == K) {
            res = S.substr(A[l], len);
            return true;
        }
        // cout << idx << ": " << S.substr(A[l], len) << endl;
        fill(cnts.begin(), cnts.end(), 0);
        for (int i = l; i < r; ++i) {
            int x = A[i];
            ++cnts[index(x, len)];
        }
        for (int i = 1; i < cnts.size(); ++i) {
            cnts[i] += cnts[i - 1];
        }

        for (int i = l; i < r; ++i) {
            int x = A[i];
            tmp[l + (--cnts[index(x, len)])] = x;
        }
        for (int i = l; i < r; ++i) {
            A[i] = tmp[i];
        }

        for (int i = l; i < r; ++i) {
            int x = A[i];
            int ch = index(x, len);
            int ll = i;
            while (i + 1 < r && index(A[i + 1], len) == ch) {
                ++i;
            }
            int rr = i + 1;

            if (ch == 0) {
                continue;
            }

            if (dfs(len + 1, ll, rr, idx, K)) {
                return true;
            }
        }

        return false;
    };

    int idx = -1;
    dfs(0, 0, n, idx, K);

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

Measured memory_bytes: 256
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)

#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


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


const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);


#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define pb push_back
#define fir first
#define scn second
#define ednl endl


#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  ll n,m,l;cin>>n>>m>>l;
  ll A[n][m];
  ll B[m][l];
  for(int i = 0; n > i; i++){
    for(int j = 0; m > j; j++){
      cin>>A[i][j];
    }
  }
  for(int i = 0; m > i; i++){
    for(int j = 0; l > j; j++){
      cin>>B[i][j];
    }
  }
  for(int i = 0; n > i; i++){
    for(int j = 0; l > j; j++){
      ll a = 0;
      for(int k = 0; m > k; k++){
        a += A[i][k]*B[k][j];
      }
      cout << a;
      if(j+1!=l)cout << " ";
    }
    cout << endl;
  }
  
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 105
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int N,sumE,head[MAXN],A[MAXN],B[MAXN],dep[MAXN],ch[MAXN],x[MAXN];
void add(int u,int v) {
    E[++sumE].to = v;E[sumE].next = head[u];head[u] = sumE;
}
int Calc(int u,int fa) {
    int res = dep[u];
    ch[u] = 0;
    for(int i = head[u] ; i ; i = E[i].next) {
	int v = E[i].to;
	if(v != fa) {
	    ch[u]++;
	    dep[v] = dep[u] + 1;
	    res = max(res,Calc(v,u));
	}
    }
    return res;
}
void Solve() {
    read(N);
    if(N == 1) {
	puts("1 2");return;
    }
    for(int i = 1 ; i < N ; ++i) {
	read(A[i]);read(B[i]);
	add(A[i],B[i]);add(B[i],A[i]);
    }
    int D = 0;
    for(int i = 1 ; i < N ; ++i) {
	dep[A[i]] = dep[B[i]] = 0;
	D = max(D,Calc(A[i],B[i]) + Calc(B[i],A[i]) + 1);
    }
    out(D / 2 + 1);space;
    if(D & 1) {
	int64 ans = 9e18;
	for(int i = 1 ; i < N ; ++i) {
	    dep[A[i]] = dep[B[i]] = 0;
	    int64 tmp = 2;
	    if(Calc(A[i],B[i]) == D / 2 && Calc(B[i],A[i]) == D / 2) {
		memset(x,0,sizeof(x));
		for(int j = 1 ; j <= N ; ++j) x[dep[j]] = max(x[dep[j]],ch[j]);
		for(int k = 0 ; k < D / 2 ; ++k) tmp = tmp * x[k];
		ans = min(ans,tmp);
	    }
	    
	}
	out(ans);enter;
    }
    else {
	int64 ans = 9e18;
	for(int i = 1 ; i < N ; ++i) {
	    dep[A[i]] = dep[B[i]] = 0;
	    int64 tmp = 1;
	    int x0 = Calc(A[i],B[i]),x1 = Calc(B[i],A[i]);
	    if(x0 > x1) {swap(x0,x1),swap(A[i],B[i]);}
	    if(x0 == D / 2 - 1 && x1 == D / 2) {
		dep[B[i]] = 0;
		Calc(B[i],0);
		memset(x,0,sizeof(x));
		for(int j = 1 ; j <= N ; ++j) x[dep[j]] = max(x[dep[j]],ch[j]);
		for(int k = 0 ; k < D / 2 ; ++k) tmp = tmp * x[k];
		ans = min(ans,tmp);
	    }
	    
	}
	
	for(int i = 1 ; i < N ; ++i) {
	    dep[A[i]] = dep[B[i]] = 0;
	    int x0 = Calc(A[i],B[i]),x1 = Calc(B[i],A[i]);
	    if(max(x0,x1) <= D / 2) {
		memset(x,0,sizeof(x));
		int64 tmp = 2;
		for(int j = 1 ; j <= N ; ++j) x[dep[j]] = max(x[dep[j]],ch[j]);
		for(int k = 0 ; k <= D ; ++k) {
		    if(x[k]) tmp *= x[k];
		}
		ans = min(ans,tmp);
	    }
	}
	
	out(ans);enter;
    }
    
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a;
    int str1=a.size();
    int h=0;
    for(int i=0;i<str1;i++)
    {
    	if(a[i]=='B')
    	{
    		h++;
    		a[i-h*2+1]='2';
		}
		else
		h=0;
    }
    for(int i=0;i<str1;i++)
    {
    	if(a[i]=='1'||a[i]=='0')
    	cout<<a[i];
    }
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned 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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll x,y; cin>>x>>y;
  ll ans=0;
  for(ll i=x; i<=y; i*=2){
    ans++;
  }
  cout<<ans<<endl;
}


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

int main() {
	int N;
	cin >> N;
	string ans = "No";
	for (int i = 0; i < N / 4 + 1; i++)
	{
		if ((N- i * 4) % 7 == 0)
		{
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int d[N];
  int i, j;
  for(i=0; i<N; i++)
    cin >> d[i];

  int sum_value = 0;
  for(i=0; i<N-1; i++)
    for(j=i+1; j<N; j++)
    sum_value += d[i]*d[j];
  
  cout << sum_value << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, ans = 0;
  scanf("%lld%lld", &n, &k);
  if(k == 1) {
    printf("0");
    return 0;
  }
  ll sum[n + 1], a[n];
  sum[0] = 0;
  set< pair<ll, ll> > s;
  set< pair<ll, ll> >::iterator it;
  pair<ll, ll> p;
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]), sum[i + 1] = (sum[i] + --a[i]) % k;
  if(k <= n) {
    for(i = 1; i < k; ++i) {
      p = make_pair(sum[i], 1);
      if((it = s.lower_bound(p)) != s.end() && (*it).first == sum[i]) p.second = (*it).second + 1, s.erase(it);
      s.insert(p);
    }
    for(i = 0; i < n; ++i) {
      p = make_pair(sum[i], 1);
      if((it = s.lower_bound(p)) != s.end() && (*it).first == sum[i]) ans += (*it).second;
      p = make_pair(sum[i + 1], 1);
      it = s.lower_bound(p);
      p.second = (*it).second - 1;
      s.erase(it);
      if(p.second) s.insert(p);
      if(i + k <= n) {
        p = make_pair(sum[i + k], 1);
        if((it = s.lower_bound(p)) != s.end() && (*it).first == sum[i + k]) p.second = (*it).second + 1, s.erase(it);
        s.insert(p);
      }
    }
  } else {
    for(i = 1; i <= n; ++i) {
      p = make_pair(sum[i], 1);
      if((it = s.lower_bound(p)) != s.end() && (*it).first == sum[i]) p.second = (*it).second + 1, s.erase(it);
      s.insert(p);
    }
    for(i = 0; i < n; ++i) {
      p = make_pair(sum[i], 1);
      if((it = s.lower_bound(p)) != s.end() && (*it).first == sum[i]) ans += (*it).second;
      p = make_pair(sum[i + 1], 1);
      it = s.lower_bound(p);
      p.second = (*it).second - 1;
      s.erase(it);
      if(p.second) s.insert(p);
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 15872
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char s[] = str.toCharArray();
		str = sc.nextLine();
		char t[] = str.toCharArray();
		sc.close();
		int n = s.length;
		int ans = 0;
		for (int i=0; i<n; i++) {
			if (s[i]!=t[i]) ans++;
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  long long n;
  cin >> n;
  vector<long long> tt(5);
  for (auto &t : tt) cin >> t;
  long long mn = *min_element(tt.begin(), tt.end());
  cout << setprecision(16) << ceil((double)n / mn) + 4 << endl;

  return 0;
}



Measured memory_bytes: 256
n=gets.to_i
h=Hash.new(0)
n.times do
  s=gets.chomp
  h[s[0]] += 1
end

ans=0
march=['M','A','R','C','H']
(0..4).each do |i|
  (i+1..4).each do |j|
    (j+1..4).each do |k|
      ans+=h[march[i]]*h[march[j]]*h[march[k]]
    end
  end
end
puts ans

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

  ll N;
  vector<ll> a(5);
  cin >> N >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  sort(a.begin(), a.end());

  ll ans = ((N-1) / a[0]) + 5;

  cout << ans << endl;


}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

using namespace std;

int f(int n) {
  int ret = 0;
  while (n % 2 == 0) {
    ret++;
    n /= 2;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += f(a);
  }
  cout << ans << '\n';
  return 0;
}


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


int main(){
    
    ll n ,t ;
    string r ,s ;
    cin >> n>>t ;
    if (n==t)
        cout << "Yes\n" ;
    else
        cout << "No\n";
    
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>

typedef long long ll;

constexpr long long INFLL = 1e18;

using namespace std;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> data(h, vector<char>(w));

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> data.at(i).at(j);
        }
    }

    vector<int> y;
    vector<int> t;

    int count = 0;
    int ans = 0;

    for (int tmp = 0; tmp < (1 << h + w + 2); tmp++)
    {
        y.clear();
        t.clear();
        count = 0;

        bitset<6 + 6 + 2> s(tmp);
        for (int i = 0; i < h + 1; i++)
        {
            if (s.test(i) == 0)
            {
                y.push_back(i);
            }
        }
        for (int i = h + 1; i < h + w + 2; i++)
        {
            if (s.test(i) == 0)
            {
                t.push_back(i - h - 1);
            }
        }

        bool check = false;

        for (const auto &e : y)
        {
            if (e == 0 || check == true)
            {
                break;
            }
            for (const auto &d : t)
            {
                if (d == 0)
                {
                    check = true;
                    break;
                }
                if (data.at(e - 1).at(d - 1) == '#')
                {
                    count++;
                }
            }
        }

        if (count == k)
        { /*
            for (const auto &e : y)
            {
                cout << "y:" << e;
            }
            cout << endl;
            for (const auto &d : t)
            {
                cout << "t:" << d;
            }
            cout << endl;
            */

            ans++;
            // cout << "ans:" << ans << endl;
        }
    }

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

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#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 all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int m; cin >> m;
    cout << 48-m << endl;
}

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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    int len = 0;
    for (int i = 1, sum = 26, p = 26; ; i++) {
        if (sum >= n) {
            len = i;
            break;
        }
        p *= 26;
        sum += p;
    }
    vector<int> ans(len, 0);
    int p = 26;
    while (n) {
        if (n <= p) {
            --n;
            for (int i = 0; i < len; i++, n /= 26)
                ans[i] = n % 26;
            break;
        }
        n -= p;
        p *= 26;
    }
    reverse(ans.begin(), ans.end());
    for (auto i: ans)
        cout << char(i + 'a');
}

Measured memory_bytes: 3644
S=input()

n=0
l=len(S)
if l%2 == 0:
    for i in range(0,l//2):
        if S[0+i] != S[-1-i]:
            n+=1

else:
    for i in range(0,(l-1)//2):
        if S[0+i] != S[-1-i]:
         n+=1

print(n)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;
int N;
int A[MAX_N];
int sumA[2][MAX_N];
int preSumA[2][MAX_N];
int pre[MAX_N];

void preSolve()
{
  reverse(A, A+N);
  memset(preSumA, 0, sizeof(preSumA));
  REP(n,N) {
    preSumA[0][n+1] = preSumA[0][n];
    preSumA[1][n+1] = preSumA[1][n]; 
    preSumA[n%2][n+1] += A[n];
  }

  int l = 0, r = 0;
  for(int n = 0; n < N-1; n += 2) {
    int tmp1 = l+r+A[n+1];
    int tmp2 = preSumA[0][n] + A[n+1];
    int tmp3 = preSumA[0][n+2];
    if (tmp2 <= tmp1 && tmp3 <= tmp1) {
      r += A[n+1];
      pre[N-(n+2)] = tmp1;
    } else if(tmp1 <= tmp2 && tmp3 <= tmp2) {
      l = preSumA[0][n];
      r = A[n+1];
      pre[N-(n+2)] = tmp2;
    } else {
      l = preSumA[0][n+2];
      r = 0;
      pre[N-(n+2)] = tmp3;
    }
  }

  reverse(A, A+N);
}

int solve()
{
  memset(sumA, 0, sizeof(sumA));
  REP(n,N) {
    sumA[0][n+1] = sumA[0][n];
    sumA[1][n+1] = sumA[1][n]; 
    sumA[n%2][n+1] += A[n];
  }

  preSolve();
  if (N%2 == 0) {
    return pre[0];
  }

  int ans = -INF_LL;

  for(int n = 0; n < N; n += 2) {
    if (n+1 < N) {
      ans = max(ans, sumA[0][n] + pre[n+1]);
    }
    if (n+2 < N) {
      ans = max(ans, sumA[0][n] + sumA[0][N] - sumA[0][n+2]);
    }
  }
  ans = max(ans, sumA[0][N-1]);
  ans = max(ans, sumA[0][N] - sumA[0][2]);

  for(int n = 1; n < N; n += 2) {
    if (n+1 < N) {
      ans = max(ans, sumA[1][n] + sumA[0][N] - sumA[0][n]);
    }
  }
  ans = max(ans, sumA[1][N]);

  return ans;
}

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  int ans = solve();

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12956
#include<iostream>
#include<string>
using namespace std;
int main() {
    int N, x=0;
    cin >> N;
    int t = N;
    for(int i = 0; i < 9; i++){
        x += t % 10;
        t /= 10; 
    }  

    if(N % x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
for q in range(12000):
    a, b = input().split()
    if a[0] is '0' and b[0] is '0':
        break

    hit = 0
    for i in range(4):
        if a[i] is b[i]:
            hit = hit + 1

    blow = 0
    for j in range(4):
        for i in range(4):
            if (b[j] is a[i]) and (a[i] is not b[i]) and (a[j] is not b[j]):
                blow = blow + 1

    print(hit, blow)

Measured memory_bytes: 7392
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
  
struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};
  
typedef struct node * Node;
Node root;
 
main(){
  int n, i, x;
  char str[20];
 
  scanf("%d",&n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s",str);
  
    if (str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if (str[0]=='p'){
      Inorder(root);
      printf("\n");
        
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
 
void insert(int k){
  Node a=NIL;
  Node b=root;
  Node new;
  
  new = malloc(sizeof(struct node));
  new->key=k;
  new->l=NIL;
  new->r=NIL;
    
  while(b!=NIL){
    a=b;
    if(new->key < b->key) b=b->l;
    else b=b->r;
  }
  new->p=a;
    
  if(a==NIL) root=new;
  else if(new->key < a->key) a->l=new;
  else a->r=new;
}
 
void Preorder(Node t){
  printf(" %d",t->key);
  if(t != NIL){
    if(t->l != NIL)Preorder(t->l);
    if(t->r != NIL)Preorder(t->r);
  }
}
  
void Inorder(Node t){
    
  if(t != NIL){
    if(t->l != NIL){
      Inorder(t->l);
      }
    printf(" %d",t->key);
      
    if(t->r != NIL){
      Inorder(t->r);
      }
  }
}

Measured memory_bytes: 24040
import itertools

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]  # (H, W)


def is_valid(xs, ys):
    k = 0
    for i in range(1, H + 1):
        if i in ys:
            continue
        for j in range(1, W + 1):
            if j in xs:
                continue
            if C[i - 1][j - 1] == '#':
                k += 1
    return k == K


ans = 0
for i in range(0, H + 1):
    for j in range(0, W + 1):
        for ys in itertools.combinations(range(1, H + 1), i):
            for xs in itertools.combinations(range(1, W + 1), j):
                if is_valid(xs, ys):
                    ans += 1

print(ans)


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

using namespace std;

int main() {
	int n;
	vector<int> a;
	int min = 0,max = 0;

	
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i; j < n; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

	cout << a[n - 1] - a[0];

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;

bool isgoal(vi &v,vi &w,int m){
    for(int i=0;i<v.size();i++){
        if(w[i]-v[i]+1>=m){
            return false;
        }
    }
    return true;
}

int main(void) {

    int n,m;
    cin>>n>>m;
    string s;
    vi v,w;
    
    cin>>s;
    reverse(all(s));
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            int maxpos=i;
            v.push_back(i);
            while(s[i+1]=='1'){
                maxpos=i+1;
                i++;
            }
            w.push_back(maxpos);
        }
    }
    if(!isgoal(v,w,m)){
        fin(-1);
        return 0;
    }
    int pos=0;
    vi pass;
    while(pos!=n){
        auto nextpos=lower_bound(all(v),pos+m);
        if(nextpos==v.end()){}
        else if(*nextpos!=pos+m&&nextpos!=v.begin()){
            nextpos--;
        }
        // cout<<m+pos<<" "<<*nextpos<<" "<<*(abs(distance(nextpos,v.begin()))+w.begin())<<endl;
        // cout<<distance(nextpos,v.begin())<<endl;
        if(m+pos>=n){
            // cout<<"A"<<endl;
            pass.push_back(n-pos);
            pos=n;
        }
        else if(nextpos!=v.end()&&m+pos>=*nextpos&&*(abs(distance(nextpos,v.begin()))+w.begin())>=m+pos){
            // cout<<"B"<<endl;
            pass.push_back(*nextpos-1-pos);
            pos=*nextpos-1;
        } else {
            // cout<<"C"<<endl;
            pass.push_back(m);
            pos+=m;
        }
    }
    reverse(all(pass));
    rep(i,pass.size()){
        if(i==0)cout<<pass[i];
        else cout<<" "<<pass[i];
    }
    cout<<endl;
}


Measured memory_bytes: 1144