akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  string s; cin>>s; int n=s.length();
  int memo=0;
  rep(i,n) if(s[i]!=s[n-i-1]) memo++;
  cout<<memo/2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i + 1; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i*i<=n;i++){
		if((n-i)%i==0&&(n-i)/i>i){
			ans+=(n-i)/i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n;

void dane() {
	cin>>n;
	int sum = 0;
	for(int i = n ; i >= 1 ; i--) {
		if(to_string(i).length() %2 ==1)sum++;
 	}
	cout<<sum<<endl;
}

int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ff first 
#define ss second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define testcase(t) int t;cin>>t;while(t--)
#define mp(x,y) make_pair(x,y)
#define in(x) insert(x)
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,a,b)  for (__typeof((b)) i=(b);i>=(a);i--)
#define PI 3.14159265358979323846
#define SP(x) setprecision(x)
#define reflex ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define M 1000000007
#define sz(a) (int)a.size()
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(x) x.resize(distance(x.begin(), unique(all(x))))
#define mem(arr,val) memset(arr,val,sizeof(arr)) //For "0" and "-1"                  
#define inp0(a,n) rep(i,0,n-1) cin>>a[i];
#define inp1(a,n) rep(i,1,n) cin>>a[i]; 
#define prll(x) printf("%lld",x)
#define nth_ele(v,n) nth_element(v.begin(), v.begin()+n ,v.end())//O(N)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUGV(x) for(auto IT:x) cout<<IT<<" "; cout<<endl;
#define minheap priority_queue <int, vector<int>, greater<int>>
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll gcd(ll n1, ll n2){if(n2!=0) return gcd(n2, n1%n2);else return n1;}
ll powerM(ll a,ll b){if(b==0) return 1;  if(b==1) return a%M; ll x=powerM(a,b/2)%M; if(b&1){return ((((a%M)*(x%M))%M)*(x%M))%M;}return ((x%M)*(x%M))%M;}
ll power(ll a,ll b){if(b==0) return 1;  if(b==1) return a; ll x=power(a,b/2); if(b&1){return ((((a)*(x)))*(x));}return ((x)*(x));}
 
const ll INF=1e18; 
const int SIZE = 100006;

int main(){
	ll h,w;
	cin>>h>>w;
	if(h==1 || w==1){
		cout<<1<<endl;
		return 0;
	}
	ll xx = h*w;
	if(xx%2LL==0){
		cout<<xx/2LL<<endl;
	}
	else cout<<(xx/2LL)+1LL<<endl;
}


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

using namespace std;

int main(){
	while(true){
		int a, b;
		cin >> a >> b;
		if(a==0){
			break;
		}
		for(int i = 0; i < a; i++){
			for (int j = 0; j < b; j++){
				cout << "#";
			}
			cout << "\n";
		}
		cout << "\n";
	}
}


Measured memory_bytes: 3056
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c in product(range(n[0]), range(n[1]), range(n[2])):
    tmp = b + c * 2 + (a + b + c) * w1
    if tmp > W:
        continue

    d = min(n[3] - 1, (W - tmp) // (w1 + 3))
    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        --a[i];
    }
    vector<int> x(n), y;
    for (int i = 0; i < n; ++i)
        x[i] = (i + 1) * 30000;
    y = x;
    reverse(y.begin(), y.end());
    for (int i = 0; i < n; ++i)
        y[a[i]] += i + 1;
    for (int i = 0; i < n; ++i)
        cout << x[i] << " ";
    cout << endl;
    for (int i = 0; i < n; ++i)
        cout << y[i] << " ";
        return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int d,t,s;
	cin >> d >> t >> s;

	if(d > t * s){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<vector> 
#include<map>
using namespace std ;
typedef  long long  ll ;
#define el "\n" 

int main(){
    ll n ; 
    cin >> n ; 
    cout << !n << el ;
    return 0 ;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define loop(I, N) for(int I = 1; I <= N; I++)
#define pool(I, N) for(int I = N; I >= 1; I--)
#define rep(I, N) for(int I = 0; I < N; I++)
#define per(I, N) for(int I = N - 1; I >= 0; I--)
#define FOR(I, L, R) for(int I = L; I <= R; I++)
#define FOD(I, R, L) for(int I = R; I >= L; I--)
#define SET(P, VAL) memset(P, VAL, sizeof(P));

int n, m, e[3][105], ans[3][105];
int main() {
    scanf("%d", &n);
    loop(i, n) scanf("%d", &e[1][i]);
    loop(i, n) scanf("%d", &e[2][i]);
    ans[1][1] = e[1][1];
    loop(i, n) {
        ans[1][i] = ans[1][i - 1] + e[1][i];
        ans[2][i] = max(ans[1][i], ans[2][i - 1]) + e[2][i];
    }
    printf("%d\n", ans[2][n]);
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] a = Enumerable.Range(0,N).ToArray();
		double tot = 0;
		double cnt = 0;
		do{
			double d = 0;
			for(int i=0;i<N-1;i++){
				d += Math.Sqrt((X[a[i]] - X[a[i+1]]) * (X[a[i]] - X[a[i+1]]) + (Y[a[i]] - Y[a[i + 1]]) * (Y[a[i]] - Y[a[i + 1]]));
			}
			//Console.WriteLine(d);
			tot += d;
			cnt++;
		} while(NextPermutation(a));
		//Console.WriteLine(cnt);
		Console.WriteLine(tot / cnt);
		
	}
	int N;
	int[] X,Y;
	public Sol(){
		N = ri();
		X = new int[N];
		Y = new int[N];
		for(int i=0;i<N;i++){
			var d = ria();
			X[i] = d[0];
			Y[i] = d[1];
		}
	}
	
	static public bool NextPermutation<T>(T[] A)where T:IComparable<T>{
		for(int i=A.Length-2;i>=0;i--){
			if(A[i].CompareTo(A[i+1])<0){
				int trgt=Array.FindLastIndex(A,x=>A[i].CompareTo(x)<0);
				Swap(ref A[i],ref A[trgt]);
				Array.Reverse(A,i+1,A.Length-(i+1));
				return true;
			}
		}
		Array.Reverse(A);
		return false;
	}
	static void Swap<T>(ref T x, ref T y){
		T t=x;x=y;y=t;
	}
	

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 15312
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define INF (1e8)
 
int N,K,T;
 
P dat[(1<<19)];
 
void compute(int k,P p){
  if(p==P(0,0))return;
  if(dat[k]==P(0,0)){
    dat[k]=p;
  }else if(dat[k].second+1==p.first){
    dat[k].second=p.second;
  }else{
    dat[k]=P(INF,INF);
  }
}
 
void add(int a,int b,int x,int k=0,int l=0,int r=(1<<18)){
  if(b<=l || r<=a)return;
  if(a<=l && r<=b){
    compute(k,P(x,x));
    return;
  }
   
   
  compute(k*2+1,dat[k]);
  compute(k*2+2,dat[k]);
  dat[k]=P(0,0);
  int m=(l+r)/2;
  add(a,b,x,k*2+1,l,m);
  add(a,b,x,k*2+2,m,r);
}
 
int main(){
  scanf("%d %d %d",&N,&K,&T);
  for(int i=0;i<T;i++){
    int l,r,x;
    scanf("%d %d %d",&l,&r,&x);
    add(l-1,r,x);
  }
  for(int i=0;i<N;i++){
    add(i,i+1,0);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int p=i+(1<<18)-1;
    if(dat[p]==P(1,K))ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 7320
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> sc(m);
    rep(i, m){ cin >> sc[i].first >> sc[i].second;}

    int min_n = 1;
    rep(i, n-1){
        min_n *= 10;
    }
    int max_n =min_n*10;

    int ans = -1;
    bool isbad = false;
    if (min_n == 1) min_n = 0;
    for (min_n; min_n < max_n; min_n++){
        isbad = false;
        rep(i, m){
            int keta = n - sc[i].first + 1;
            if (keta == 1){
                if(min_n%10 != sc[i].second) isbad = true; 
            } else if (keta == 2){
                if((min_n%100)/10 != sc[i].second) isbad = true; 
            } else {
                if(min_n/100 != sc[i].second) isbad = true; 
            }
        }
        if(!isbad) {ans = min_n; break;}
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[2];
		int B[] = new int[2];
		int C[] = new int[2];
		int D[] = new int[2];
		int E[] = new int[2];
		
		while(true){
			for(int i = 0; i < 2;i++){
				A[i] = sc.nextInt();
			}
			if(A[0] + A[1] == 0)break;
			for(int i = 0; i < 2;i++){
				B[i] = sc.nextInt();
			}
			if(B[0] + B[1] == 0)break;
			for(int i = 0; i < 2;i++){
				C[i] = sc.nextInt();
			}
			if(C[0] + C[1] == 0)break;
			for(int i = 0; i < 2;i++){
				D[i] = sc.nextInt();
			}
			if(D[0] + D[1] == 0)break;
			for(int i = 0; i < 2;i++){
				E[i] = sc.nextInt();
			}
			if(E[0] + E[1] == 0)break;
			
			int S[] = new int[5];
			
			S[0] = A[0] + A[1];
			S[1] = B[0] + B[1];
			S[2] = C[0] + C[1];
			S[3] = D[0] + D[1];
			S[4] = E[0] + E[1];
			
			int max = S[0];
			int idx = 0;
			
			for(int i = 1; i < 5;i++){
				if(max < S[i]){
					max = S[i];
					idx = i;
				}
			}
			
			
			if(idx == 0){
				System.out.println("A" + " " + max);
			}
			else if(idx == 1){
				System.out.println("B" + " " + max);
			}
			else if(idx == 2){
				System.out.println("C" + " " + max);
			}
			else if(idx == 3){
				System.out.println("D" + " " + max);
			}
			else if(idx == 4){
				System.out.println("E" + " " + max);
			}
			
			
			
		}
	}
}

Measured memory_bytes: 21268
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

#define chmax(x, y) x = max(x, y)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<tuple<int, int, int, i64>> blocks(N);
  REP(i, N) {
    int w, s, v;
    cin >> w >> s >> v;
    blocks[i] = {s + w, s, w, v};
  }
  sort(blocks.rbegin(), blocks.rend());

  const int SMAX = 1e4 + 5;
  vector<i64> dp(SMAX, -1);
  REP(i, N) {
    auto [_, s, w, v] = blocks[i];
    for (int s2 = w; s2 < SMAX; ++s2) {
      if (dp[s2] >= 0) {
        chmax(dp[min(s2 - w, s)], dp[s2] + v);
      }
    }
    chmax(dp[s], v);
  }
  i64 ans = 0;
  REP(s, SMAX) { chmax(ans, dp[s]); }
  cout << ans << endl;
}


Measured memory_bytes: 3720
#include <stdio.h>
 
int main(void){
	int  a, b, c, d;
	int p = 0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
    p = a*1000+b*100+c*10+d;
	if(p==1479||p==1497||p==1749||p==1794||p==1947||p==1974){
      printf("YES");
    }else if(p==4179||p==4197||p==4719||p==4791||p==4917||p==4971){
      printf("YES");
    }else if(p==7149||p==7194||p==7419||p==7491||p==7914||p==7941){
      printf("YES");
    }else if(p==9147||p==9174||p==9417||p==9471||p==9714||p==9741){
      printf("YES");
    }else{
      printf("NO");
    }
	return 0;
}

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

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

int main() {
   
    string s;
    deque<char> d;
    ll q;
    cin >> s >> q;
    for(ll i=0;i<s.length();i++){
        d.push_back(s[i]);
    }
    int flag = 0; // 0:top, 1:back
    for (ll i=0;i<q;i++){
        ll t;
        cin >> t;
        if(t == 1){
            flag = (flag + 1)%2;
            continue;
        }
        ll f;
        char c;
        cin >> f >> c;
        if(f == 1){
            if(flag == 0){
                d.push_front(c);
            }else{
                d.push_back(c);
            }
        }else{
            if(flag == 0){
                d.push_back(c);
            }else{
                d.push_front(c);
            }
        }
    }
    if(flag == 0){
        for (auto itr = d.begin(); itr != d.end() ;itr++){
            cout << *itr;
        }
        cout << endl;
    }else{
        for(auto itr = d.end()-1;itr != d.begin()-1;itr--){
            cout << *itr;
        }
        cout << endl;
    }
}

Measured memory_bytes: 896
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        long total = 0;
        for(int i = 0; i < n; i++){
            a[i] -= sc.nextInt();
            total += a[i];
        }
        if(total < 0){
            System.out.println(-1);
            return;
        }
        Arrays.sort(a);
        int l = 0;
        int r = n-1;
        boolean[] changed = new boolean[n];
        while(r >= 0 && l < n){
            if(a[l] >= 0){
                break;
            }else{
                changed[l] = true;
                changed[r] = true;
                if(-a[l] > a[r]){
                    a[l] += a[r];
                    a[r] = 0;
                    r--;
                }else{
                    a[r] += a[l];
                    a[l] = 0;
                    l++;
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(changed[i]){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 54984
import sys
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7


def f(index, l):
    if index == len(l):
        return 1
    if l[index] == '1':
        return ( 3 ** (len(l)-1-index) + 2 * f(index+1, l) ) % MOD
    else:
        return f(index+1, l) % MOD


def main():
    l = input()
    n = len(l)
    one = 0
    ans = 0
    for i in range(n):
        if l[i] == '1':
            ans += pow(2, one, MOD) * pow(3, n-1-i, MOD)
            ans %= MOD
            one += 1
    ans += pow(2, one, MOD)
    ans %= MOD
    print(ans)

main()

Measured memory_bytes: 3236
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main()
{
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;

    vi high;
    vi low;
    vector<bool> done(N);
    if (s[0] == '0')
        high.push_back(0);
    REP(i, N)
    {
        if (done[i])
            continue;
        char c = s[i];
        done[i] = true;
        int j = i + 1;
        int cnt = 1;
        while (j < N and s[j] == c)
        {
            cnt++;
            done[j] = true;
            j++;
        }
        if (c == '0')
            low.push_back(cnt);
        else
            high.push_back(cnt);
    }
    if (s[N - 1] == '0')
        high.push_back(0);

    // cerr << "high:";
    // for (auto x : high)
    //     cerr << " " << x;
    // cerr << endl;

    // cerr << "low:";
    // for (auto x : low)
    //     cerr << " " << x;
    // cerr << endl;

    if (low.size() <= K)
    {
        cout << s.size() << endl;
        return 0;
    }

    int total = 0;
    REP(i, K + 1)
    total += high[i];
    REP(i, K)
    total += low[i];

    int p = K;
    int res = total;
    while (p < low.size())
    {
        int diff = high[p + 1] - high[p - K] + low[p] - low[p - K];
        total += diff;
        res = max(res, total);
        p++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(j, k) {
        vector<int> b(n + 1, 0);
        rep(i, n) {
            int l = max(0, i - a[i]);
            int r = min(n, i + a[i] + 1);
            b[l]++;
            b[r]--;
        }
        rep(i, n) b[i + 1] += b[i];
        b.pop_back();
        if (a == b)
            break;
        a = b;
    }
    rep(i, n) cout << a[i] << endl;
}


Measured memory_bytes: 4796
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

flg=True
for i in range(1,N+1 ):
    if int(i*1.08) == N:
        print(i)
        flg=False
        break
if flg:
    print(":(")

Measured memory_bytes: 39408
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    char input[1200];
    cin.getline(input, sizeof(input));
    F(i, 0, 1200){
        if(input[i] == '\0')break;
        if(65 <= input[i] && input[i] <= 90){
            input[i] = tolower(input[i]);
        }else if(97<= input[i] && input[i] <= 122){
            input[i] = toupper(input[i]);
        }
    }
    cout << input << endl;
}



Measured memory_bytes: 3096
from math import atan2, pi, sqrt
from operator import itemgetter
import sys
input = sys.stdin.readline

n = int(input())
p = []
xa = ya = 0
for i in range(n):
    x, y = map(int, input().split())
    angle = atan2(y, x)
    p.append((x, y, angle))
    p.append((x, y, angle + 2 * pi))
    xa += x
    ya += y

p.sort(key=itemgetter(2))

r = 0
ans = 0
xs = ys = 0
for l in range(n):
    while p[r][2] < p[l][2] + pi:
        xs += p[r][0]
        ys += p[r][1]
        r += 1

    ans = max(ans, sqrt(xs**2 + ys**2), sqrt((xa - xs)**2 + (ya - ys)**2))

    xs -= p[l][0]
    ys -= p[l][1]

print(ans)


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010



int main(){
  int n;
  string s;

  cin >> n >> s;

  int ans = 0;

  for(int i=1;i<s.size();i++){
    bool u[26] = {};
    int sum = 0;
    string p = s.substr(0, i);
    string q = s.substr(i, n-i);

    for(char c : p) u[c-'a'] = true;
    for(char c : q) {
      sum += u[c-'a'];
      u[c-'a'] = false;
    }

    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]

def update(y, x, direction, d, q):
    next_y, next_x = (y + direction[0], x + direction[1])
    if (next_y < 0 or next_y >= H or next_x < 0 or next_x >= W): # 端なら
        return
    if (S[next_y][next_x] == '#') or (d[next_y][next_x] != -1): # 壁か既に訪問状態なら
        return 
    d[next_y][next_x] = d[y][x] + 1
    q.append((next_y, next_x))

def bfs(i, j):
    DIJ = ((-1, 0), (0, -1), (1, 0), (0, 1)) # (y, x):下, 左, 上, 右
    dist = [[-1] * W for _ in range(H)]
    dist[i][j] = 0 #始点は０

    queue = [(i, j)]
    while queue:
        cur_y, cur_x = queue.pop(0)
        for i in range(4):
            update(cur_y, cur_x, DIJ[i], dist, queue)
    return max(max(dd) for dd in dist)
    
max_results = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            max_results = max(bfs(i, j), max_results) 
print(max_results)

Measured memory_bytes: 3188
import math
 
N = int(input())
 
min_cand = 10**12
 
for i in range(1,(int(math.sqrt(N))+1)):
  if N % i == 0 and min_cand > (i + (N // i)):
    min_cand = (i + (N // i))
    
print(min_cand - 2)

Measured memory_bytes: 3060
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc079_a.cpp
 * time   : Wed Apr 29 22:50:20 2020
 * quest  : A - Good Integer
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a == b && b == c) || (b == c && c == d))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  double n;
  while(cin >>n){
    if(n<=48) cout <<"light fly"<<endl;
    else if(n<=51) cout <<"fly"<<endl;
    else if(n<=54) cout <<"bantam"<<endl;
    else if(n<=57) cout <<"feather"<<endl;
    else if(n<=60) cout <<"light"<<endl;
    else if(n<=64) cout <<"light welter"<<endl;
    else if(n<=69) cout <<"welter"<<endl;
    else if(n<=75) cout <<"light middle"<<endl;
    else if(n<=81) cout <<"middle"<<endl;
    else if(n<=91) cout <<"light heavy"<<endl;
    else cout <<"heavy"<<endl;
  }
  return 0;
}

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

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

    auto lengths = std::vector<int>();
    lengths.reserve(n);

    for(int i = 0; i < n; ++i) {
        int l;
        std::cin >> l;
        lengths.push_back(l);
    }

    std::sort(lengths.begin(), lengths.end());

    int answer = 0;

    const auto a_end = lengths.end() - 1;

    for(auto a = lengths.begin(); a != a_end; ++a) {
        for(auto b = a + 1; b != lengths.end(); ++b) {
            const auto lower = *b - *a + 1;
            const auto upper = *a + *b - 1;

            const auto lower_it = std::lower_bound(b + 1, lengths.end(), lower);
            const auto upper_it = std::upper_bound(b + 1, lengths.end(), upper);

            const int c = upper_it - lower_it;

            answer += c;
        }
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 256
import math
a,b,h,m=map(int, input().split())

jikan=h*60+m
bdeg=6*jikan
adeg=0.5*jikan
theta=(bdeg-adeg)/180.*math.pi

nagasa=math.sqrt(a**2+b**2-2*a*b*math.cos(theta))

print (nagasa)

Measured memory_bytes: 9592
#include<bits/stdc++.h>
typedef long long ll;
typedef double db;
typedef long double ld;
using namespace std;
const int N=2e5+11;
struct node
{
	ll x,y;
}a[N];
ll n,d,att,i,ans,k,nboom,tree[N];
bool cmp(node aa,node bb)
{
	return aa.x<bb.x;
}
ll find(ll w)
{
	ll l,r,mid,maxnum,bo;
	l=w; r=n;
	maxnum=a[w].x+d;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (a[mid].x<=maxnum)
		{
			bo=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	return bo;
}
ll lowbit(ll x)
{
	return x&(-x);
}
void upnum(ll x,ll y)
{
	ll i;
	for (i=x;i<=n+1;i+=lowbit(i))
	tree[i]+=y;
}
ll getnum(ll x)
{
	ll i,anss;
	anss=0;
	for (i=x;i>0;i-=lowbit(i))
	anss+=tree[i];
	return anss;
}
int main()
{
	cin>>n>>d>>att;
	d=2*d;
	for (i=1;i<=n;i++)
	scanf("%lld%lld",&a[i].x,&a[i].y);
	sort(a+1,a+1+n,cmp);
	for (i=1;i<=n;i++)
	{
		nboom=a[i].y-getnum(i)*att;
		if (nboom<=0) continue;
		if (nboom%att==0) nboom=nboom/att;
		else nboom=nboom/att+1;
		ans+=nboom;
		k=find(i);
		upnum(i,nboom);
		upnum(k+1,-nboom);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
def gi() gets.to_i end
def gs() gets.chomp end
def gim() gets.split.map(&:to_i) end
def gsm() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end
#####

n = gi
hs = gim

dp = Array.new(n, Float::INFINITY)
dp[0] = 0

dp[1] = [dp[1],dp[0]+(hs[1]-hs[0]).abs].min

(2..n-1).each do |i|
  dp[i] = [dp[i],dp[i-1]+(hs[i]-hs[i-1]).abs].min
  dp[i] = [dp[i],dp[i-2]+(hs[i]-hs[i-2]).abs].min
end
puts dp[-1]

Measured memory_bytes: 11404
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>

#define F1(x,y,z) for(int x=(y);x<(z);x++)
#define F2(x,y,z) for(int x=(y);x<=(z);x++)
#define F3(x,y,z) for(int x=(y);x>(z);x--)
#define F4(x,y,z) for(int x=(y);x>=(z);x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 53
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;

int n;
char x[MAX];

int main(){
	scanf("%s",x);
	n=strlen(x);
	printf(((n%2)^(x[0]!=x[n-1]))?"Second\n":"First\n");
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	String b=scan.next();
	long ans=1;
	long alpha[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
	for(int i=0;i<b.length();i++) {
		char ch=b.charAt(i);
		alpha[ch-'a']++;
	}
	for(int i=0;i<26;i++) {
		ans*=alpha[i];
		ans%=1000000007;
	}
	System.out.println(ans-1);
	scan.close();
	}
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    string s;
    cin >> s;

    int ans = 9999999;
    REPinit(i, 0, s.size() - 2) {
        ans = min(abs(stoi(s.substr(i, 3)) - 753), ans);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,m,n,l[33000333],o[300000],e[3333],k,i,d[200010],dx[10]={0,-2,-1,0,1,2};
long long x,y,z;
char iop;
stack<int> s;
struct P
{
    int x,y;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};

string r;
vector<int> v[200010];


/*
6 16
................
..xxxx....xxx...
...xxxx....xx...
.xxxx......xxx..
........xxxxx...
..xxx....xxx....

*/
//131072


int main()
{
    scanf("%d %lld %lld",&a,&x,&y);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    for(int t=2;t<=a;t++)
        if(x*(o[t]-o[t-1])>y)
        z+=y;
    else z+=x*(o[t]-o[t-1]);
    printf("%lld",z);
    return 0;
}

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

int64_t n, m;

uint64_t check(uint64_t min, uint64_t max)
{
    if (min == 1 && max == 1) return 1;
    if (min == 1) return max-2;
    if (min == 2) return 0;
    return (min-2) * (max-2);
}

int main(void)
{

    std::cin >> n >> m;

    std::cout << check(std::min(n,m), std::max(n,m)) << std::endl;

    return 0;
}

Measured memory_bytes: 256
flag = 0
X = int(input())
for A in range(1000):
    if flag!=0:
        break
    for B in range(1000):
        if A**5 - B**5 == X:
            print(str(A) + " " + str(B))
            flag=1
            break
        elif A**5 + B**5 == X:
            print(str(A) + " " + str(-B))
            flag=1
            break

Measured memory_bytes: 9136
#include <iostream>
#include <string.h>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;

#define ll long long

int main () {
  ll n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] == b[i] && a[i] == c[i]) {
      // no  
    }  
    if (a[i] == b[i] && b[i] != c[i]) {
      ans++;  
    }
    if (a[i] != b[i] && b[i] == c[i]) {
      ans++;  
    }
    if (a[i] == c[i] && b[i] != c[i]) {
      ans++;  
    }
    if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
      ans += 2;  
    }
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
/*In the name of Allah*/
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011



int a[MAX];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	int cur = 0;
	for(int i = 0; i < n ; i++){
		cin>>a[i];
		if(a[i] < cur){
			cout<<"No";
			exit(0);
		}
		cur = max(cur,a[i] - 1);
	}
	cout<<"Yes";	
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a[1001];
int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf ("%d", &a[i]);
    sum += a[i];
  }
  int ans = 0x7fffffff, now = 0;
  for (int i = 1; i <= n; i++) {
    now += a[i];
    ans = min(ans, abs(sum - now - now));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int[] s = new int[m];
    int[] p = new int[m];
    int k;
    int i,j,l;
    int sum = 0;
    for(i=0;i<m;i++){
      k = Integer.parseInt(sc.next());
      for(j=0;j<k;j++){
        s[i]+=1<<(Integer.parseInt(sc.next())-1);
      }
    }
    for(i=0;i<m;i++){
      p[i] = Integer.parseInt(sc.next());
    }
    int count = 0;
    int tmp;
    
    for(i=0;i<(1<<n);i++){
      for(j=0;j<m;j++){
        tmp = i&s[j];
        count = 0;
        for(l=0;l<n;l++){
          if((tmp&1)==1)count++;
          tmp>>=1;
        }
        if((count%2)!=p[j])break;
      }
      if(j==m)sum++;
    }
    System.out.print(sum);
    System.out.flush();
  }
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)

ll N;
ll A[100005];
ll cnt;
ll ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

rep(i,N){
	cin>>A[i];
	if(A[i]<0){
		cnt++;
	}
}

if(cnt%2==0){
	rep(i,N){
		ans+=abs(A[i]);
	}
}else{
	ll s=0;
	rep(i,N){
		s+=abs(A[i]);
	}
	rep(i,N){
		if(A[i]<0){
			ans=max(ans,s+2*A[i]);
		}else{
			ans=max(ans,s-2*A[i]);
		}
	}
}

cout<<ans<<endl;

}
	


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<deque>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
int main(void)
{
	int n,count = 0;
	double d,x,y;
	std::cin >> n >> d;
	for(int i = 0; i < n; i++)
	{
		std::cin >> x >> y;
		if(x*x + y*y <= d*d)
		{
			count ++;
		}
	}
	std::cout << count <<std::endl;
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
int n ;
cin >> n;
for (int i = 0;i<15;i++){
  for (int j = 0 ; j<26 ;j++){
    if (n == 4*j + 7 *i) {cout << "Yes" << endl;
      return 0;}
  }
}
cout << "No" <<endl;
   }


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, M;
    cin >> N >> M;
    Vec<pair<bool, i32>> q(N + 1, make_pair(false, 0));
    i32 sum_a = 0;
    for (u32 i = 0; i < M; i++) {
        i32 p;
        string S;
        cin >> p >> S;
        if (!q[p].first) {
            if (S == "AC") {
                q[p].first= true;
                sum_a++;
            } else {
                q[p].second++;
            }
        }
    }
    i32 sum_w = 0;
    for (auto&& x: q) {
        if (x.first) sum_w += x.second;
    }
    cout << sum_a << " " << sum_w << endl;


}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cassert>
#include<cstring>
using namespace std;

const int INF = 1e7;

namespace NetFlow
{
	const int N = 2e5+2;
	const int M = 4e5;
	struct Edge
	{
		int v,w,nxt,rev;
	} e[(M<<1)+3];
	int fe[N+3];
	int te[N+3];
	int dep[N+3];
	int que[N+3];
	int n,en,s,t;
	int dfscnt;
	void addedge(int u,int v,int w)
	{
		assert(u!=v);
//		printf("addedge %d %d %d\n",u,v,w);
		en++; e[en].v = v; e[en].w = w;
		e[en].nxt = fe[u]; fe[u] = en; e[en].rev = en+1;
		en++; e[en].v = u; e[en].w = 0;
		e[en].nxt = fe[v]; fe[v] = en; e[en].rev = en-1;
	}
	bool bfs()
	{
		for(int i=1; i<=n; i++) dep[i] = 0;
		int head = 1,tail = 1; que[1] = s; dep[s] = 1;
		while(head<=tail)
		{
			int u = que[head]; head++;
			for(int i=fe[u]; i; i=e[i].nxt)
			{
				int v = e[i].v;
				if(e[i].w>0 && dep[v]==0)
				{
					dep[v] = dep[u]+1;
					if(v==t)return true;
					tail++; que[tail] = v;
				}
			}
		}
		return false;
	}
	int dfs(int u,int cur)
	{
		if(u==t||cur==0) {return cur;}
		int rst = cur;
		for(int &i=te[u]; i; i=e[i].nxt)
		{
			dfscnt++; assert(dfscnt<=500000000);
			int v = e[i].v;
			if(e[i].w>0 && rst>0 && dep[v]==dep[u]+1)
			{
				int flow = dfs(v,min(rst,e[i].w));
				if(flow>0)
				{
					e[i].w -= flow;	
					rst -= flow;
					e[e[i].rev].w += flow;
					if(rst==0) {return cur;}
				}
			}
		}
		if(rst==cur) {dep[u] = -2;}
		return cur-rst;
	}
	int dinic(int _n,int _s,int _t)
	{
		n = _n,s = _s,t = _t;
		assert(n<=200002&&en<=400000);
		int ret = 0;
		while(bfs())
		{
			for(int i=1; i<=n; i++) te[i] = fe[i];
			memcpy(te,fe,sizeof(int)*(n+1));
			ret += dfs(s,INF);
		}
		return ret;
	}
}
using NetFlow::addedge;
using NetFlow::dinic;

const int N = 1e5;
int a[N+3],b[N+3];
int ca[N+3],cb[N+3];
int n,cnta,cntb;

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),a[i]++;
	for(int i=1; i<=n; i++) scanf("%d",&b[i]),b[i]++;
	for(int i=1; i<=n; i++)
	{
		if(!ca[i])
		{
			cnta++;
			int x = i;
			do
			{
				ca[x] = cnta;
				x = a[x];
			} while(x!=i);
		}
	}
	for(int i=1; i<=n; i++)
	{
		if(!cb[i])
		{
			cntb++;
			int x = i;
			do
			{
				cb[x] = cntb;
				x = b[x];
			} while(x!=i);
		}
	}
//	printf("ca: "); for(int i=1; i<=n; i++) printf("%d ",ca[i]); puts("");
//	printf("cb: "); for(int i=1; i<=n; i++) printf("%d ",cb[i]); puts("");
	int ans = n;
	for(int i=1; i<=n; i++)
	{
		if(a[i]==i && b[i]==i) {ans--;}
		else if(a[i]==i) {addedge(1,cb[i]+cnta+2,1);}
		else if(b[i]==i) {addedge(ca[i]+2,2,1);}
		else
		{
			addedge(ca[i]+2,cb[i]+cnta+2,1);
			if(a[i]==b[i]) {addedge(cb[i]+cnta+2,ca[i]+2,1);}
		}
	}
	ans -= dinic(2+cnta+cntb,1,2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
#define pb push_back
#define rep(a,b,c) for(int a=(int)b;a<(int)c;a++)
#define repe(a,b,c) for(int a=(int)b;a<=(int)c;a++)
#define repk(a,b,c,k) for(int a=(int)b;a<(int)c;a+=(int)k)
#define comeback std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define ful(a) a.begin(),a.end()
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
using namespace std;
int em(int x,int n)
{
    if(n==0)
    return 1;
    else if(n%2==0)
    return em((x%mod*x%mod)%mod,n/2);
    else
    return (x%mod*em((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int dp[3001][3001];
//int a[3001];
/*int fun(int lo,int hi){
	if(lo==hi)
		return a[lo];
	if(dp[lo][hi]!=-1)
		return dp[lo][hi];
	int ans=0;
	ans=max(a[lo]-fun(lo+1,hi),a[hi]-fun(lo,hi-1));
	return dp[lo][hi]=ans;
}*/
signed main()
{
	comeback
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output1.txt","w",stdout);
	#endif*/
		int n,m,i,j,k,l;
		cin>>n;
		int a[n+1];
		repe(i,1,n)
		cin>>a[i];
		memset(dp,0,sizeof(dp));
		for(i=1;i<=n;i++)
			dp[i][i]=a[i];
		//cout<<fun(1,n);
		for(i=n;i>=1;i--){
			for(j=i+1;j<=n;j++)
				dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
		cout<<dp[1][n];
}

Measured memory_bytes: 70656
#include<iostream>
using namespace std;
int main(){
	int a[1000], n, i, j, t, c=0;	cin>>n;
	for(i = 0;i < n;i++) cin >> a[i];
	for(i = 0;i < n;i++){
	for(j = n - 1;j > i;j--){
	if(a[j] < a[j - 1]){
	t = a[j];
	a[j] = a[j - 1];
	a[j - 1] = t;
	c++;
	}
	}
	}
	for(i = 0;i < n;i++){
	    if(i)cout<<" ";cout<<a[i];
	}
	cout << '\n' << c << endl;
	return 0;
}



Measured memory_bytes: 3104
H, W = map(int, input().split())
S = [input() for i in range(H)]

for h in range(H):
    new_s = ''
    for w in range(W):
        if S[h][w] == '#': 
            new_s += '#'
            continue
        count = 0
        ary = [-1, 0, 1]
        for i in ary:
            for j in ary:
                if h+i < 0 or h+i >= H or w+j < 0 or w+j >=W: continue
                if S[h+i][w+j] == '#':
                    count += 1
        new_s += str(count)
    
    S[h] = new_s

for s in S:
    print(s)

Measured memory_bytes: 9136