akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> cnt(100010);
    rep(i,0,N){
        int a;
        cin >> a;
        cnt[a]++;
    }
    int cnt1 = 0,cnt2 = 0;
    rep(i,1,100001){
        if(cnt[i]){
            if(cnt[i] % 2)cnt1++;
            else cnt2++;
        }
    }
    
    //cout << cnt1 << " " << cnt2 << endl;
    if(cnt2 % 2 == 1)cnt1--;
    cnt1 += cnt2;
    cout << cnt1 << endl;
}

Measured memory_bytes: 640
# 参考:https://drken1215.hatenablog.com/entry/2020/04/26/193500 #
from math import pi
from math import atan2
a,b,x = map(int,input().split())
x /= a
if x > a * b / 2:
    print(atan2(2 * (a * b - x),(a ** 2)) * 180 / pi)
if x <= a * b / 2:
    print(atan2((b ** 2),2 * x) * 180 / pi)

Measured memory_bytes: 9328
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N,0),B(N,0),p(N);
  rep(i,N){
    cin >> p.at(i);
    A.at(p.at(i)-1)=i;
    B.at(p.at(i)-1)=i;
  }
  rep(i,N){
    if(i==0){
      A.at(i)=1+A.at(i);
      B.at(N-1-i)=1+B.at(N-1-i);
    }else{
      A.at(i)=A.at(i-1)+1+A.at(i);
      B.at(N-1-i)=B.at(N-i)+1+B.at(N-1-i);
    }
  }
  rep(i,N){
    cout << A.at(i) << " ";
  }
  cout << endl;
  rep(i,N){
    cout << B.at(i) << " ";
  }
  cout << endl;
}
      

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<utility>
#include<vector>

using namespace std;

int timeAbs(string t1,string t2);

main(){
  vector<pair<string,int> > vec;
  int ans=0;
  int n,t;
  cin>>n>>t;
 
  string st_time[n],st_name[n],ar_time[n],ar_name[n];
  for(int i=0;i<n;i++)
    cin>>st_time[i]>>st_name[i]>>ar_time[i]>>ar_name[i];

  for(int i=0;i<n-1;i++){
    int time;
    if(timeAbs(ar_time[i],st_time[i+1])>=t){
      vec.push_back(make_pair(ar_name[i],timeAbs(ar_time[i],st_time[i+1])));
      ans++;
    }
  }
  cout<<ans<<endl;

  for(int i=0;i<vec.size();i++)
    cout<<vec[i].first<<" "<<vec[i].second<<endl;

  return 0;
}

int timeAbs(string s,string e){
  /*return t2 - t1 
    format: HH:MM */
  int s_min,s_hour,e_min,e_hour;
  int ans;
  if(s.size()!=5 || e.size()!=5)
    return -1;

  s_min=atoi(s.substr(3,2).c_str());
  s_hour=atoi(s.substr(0,2).c_str());
  e_min=atoi(e.substr(3,2).c_str());
  e_hour=atoi(e.substr(0,2).c_str());

  ans=(e_hour*60 + e_min)-(s_hour*60 + s_min);

  return ans;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A;
    cin >> A;
    rep(i,1,A+1){
        int x = i * 108 / 100;
        if(x == A){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int k;
double r,l,p,e,t;
double f(double r,double l,double u,double v,int k)
{
	if(k==0)return (r+l)/2>=u&&(r+l)/2<=v;
	if(u<=r&&l<=v)return 1;
	else if(l<u||v<r)return 0;
	double m=(r+l)/2;
	return f(r,m,u,v,k-1)*(t>m?p:1-p)+f(m,l,u,v,k-1)*(t>m?1-p:p);
}
main()
{
	cin>>k>>r>>l>>p>>e>>t;
	cout<<fixed<<setprecision(15)<<f(r,l,t-e,t+e,k)<<endl;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  string s; cin >> s;
  int maxcd=(c>d)?c:d;
  bool empflag=false,sflag=true;
  if(c<d) empflag=true;
  for(int i=a;i<=maxcd;++i){
    if(i==n-1) break;
    if(b<=i && i<=d){
      if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') empflag=true;
    }
    if(s[i]=='#' && s[i+1]=='#') sflag=false;
  }
  if(empflag && sflag) cout << "Yes";
  else cout << "No";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 640
num=list(map(int, input().split()))
n=num[0]
k=num[1]
h=list(map(int, input().split()))
DP=[]
for i in range(n):
  DP.append(0)
DP[0]=0
DP[1]=abs(h[1]-h[0])
for j in range(2,n):
  DP[j]=DP[j-1]+abs(h[j-1]-h[j])
  for l in range(2,k+1):
    if l>j:
      continue
    if DP[j]>DP[j-l]+abs(h[j-l]-h[j]):
      DP[j]=DP[j-l]+abs(h[j-l]-h[j])
#print(DP)
print(DP[n-1])
  

Measured memory_bytes: 56032
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
int main(){
    ll N,M;
    cin >> N >> M;
    vector<vector<char>> field(N,vector<char>(M));
    rep(i,N)
    rep(j,M)cin >> field[i][j];
    rep(i,N){
        rep(a,2){
            rep(j,M){
                cout << field[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

ll a[100000];
ll memo[100000];

int main(){
  int n; cin >> n;
  REP(i,n) cin>>a[i];
  sort(a, a+n, greater<ll>());
  ll ans = 0;

  for(int i = 0; i + 5 < n; i++){
    int arr[6] = {0, 0, 0, 1, 1, 1};
    ll *aa = &a[i];
    do{
      ll t1[3]; int tt1 = 0;
      ll t2[3]; int tt2 = 0;

      REP(i,6){
        if(arr[i] == 0)
          t1[tt1++] = aa[i];
        else
          t2[tt2++] = aa[i];
      }

      if(t1[0] - t1[1] < t1[2] && t2[0] - t2[1] < t2[2]){
        ans = 0;
        REP(j,6) ans += aa[j];
        goto end;
      }
    }while(next_permutation(arr, arr+6));
  }

 end:;
  for(int i = 0; i + 2 < n; i++){
    ll *aa = &a[i];

    if(aa[0] - aa[1] < aa[2]){
      memo[i] = aa[0] + aa[1] + aa[2];
    }else{
      memo[i] = 0;
    }
  }

  for(int i = 0; i + 5 < n; i++){
    if(memo[i] != 0){
      for(int j = i + 3; j + 2 < n; j++){
        if(memo[j] != 0){
          ans = max(ans, memo[i] + memo[j]);
          goto end2;
        }
      }
    }
  }
 end2:

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

Measured memory_bytes: 2292
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
  cin >> h >> w;
  rep(i,h){
    rep(j,w){
      string s;
      cin >> s;
      if(s == "snuke"){
        cout << (char)('A'+j) << i+1 << endl;
      }
    }
  }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int p=1e9+7;
int main()
{
     int h,w;
     cin>>h>>w;
     char a[h][w];
     for(int i=0;i<h;i++)
     {
         for(int j=0;j<w;j++)
         {
             cin>>a[i][j];
         }
     }
     int dp[h][w];
     for(int i=0;i<h;i++)
     {
         fill(dp[i],dp[i]+w,0);
     }
     for(int i=0;i<w;i++)
     {  if(a[0][i]=='#')
          {
             break;
          }
         dp[0][i]=1;
     }
     for(int j=0;j<h;j++)
     {
         if(a[j][0]=='#')
           break;
           dp[j][0]=1;
     }
     for(int i=1;i<h;i++)
     {
         for(int j=1;j<w;j++)
         {
             if(a[i][j]=='#')
              continue;
              else{
                  dp[i][j]=(dp[i-1][j]%p+dp[i][j-1]%p)%p;
              }
         }
     }//h-1
     cout<<dp[h-1][w-1]<<endl;





}

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

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size()<=k){
        cout << s << endl;
    }
    else{
        for(int i=0; i<k; ++i){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
/*  ex9_2
    potter0723sw  */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}

int main(void){
    int i = 0,ans = 0;
    //入力を受け取る配列をヌル文字分まで確保
    char color,tmp[SIZE + 1];
    //最初のノードの指す先
    node *first = NULL;
    scanf("%s", tmp);
    //tmpを順番に見ていってもしスタックに何も入っていないかスタックの先頭と同じ色だったらスタックに入れていく。
    while(tmp[i] != '\0'){
        if(first == NULL || first->elem == tmp[i]){
            push(&first, tmp[i]);
        }else{
            pop(&first);
            ans += 2;
        }
        i++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4916
#include <stdio.h>
#include <algorithm>
using namespace std;
int r[86401], n, h1, m1, s1, h2, m2, s2;
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			scanf("%02d:%02d:%02d %02d:%02d:%02d", &h1, &m1, &s1, &h2, &m2, &s2);
			r[h1 * 3600 + m1 * 60 + s1]++;
			r[h2 * 3600 + m2 * 60 + s2]--;
		}
		int ret = 0, sum = 0;
		for (int i = 0; i < 86400; i++) {
			sum += r[i]; r[i] = 0;
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    map<int, int> mp;
    set<int> s;
    rep(i, N) {
        int a; cin >> a;
        s.insert(a);
        mp[a] ++;
    }
    int ans = 0;
    for(auto i : s) {
        if(mp[i] < i) ans += mp[i];
        if(mp[i] > i) ans += (mp[i] - i);
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9344
#include <stdio.h>

typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int main(){
    int n;
    int l[1000];

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

    quicksort(l, 0, n-1);

    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            for(int k = 0; k < j; ++k){
                if(l[k] != l[j] && l[j] != l[i] && (l[k] + l[j]) > l[i]) ans++;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	cout << (N+1)/2 << endl;
}


Measured memory_bytes: 256
import numpy as np
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

arr = []
for i in range(1, n + 1):
    for j in range(a[i - 1]):
        arr.append(i)

arr = np.array(arr)
arr = arr.reshape(h, -1)

for i in range(h):
    if i % 2 == 0:
        print(*arr[i])
    else:
        print(*arr[i][::-1])

Measured memory_bytes: 13264
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;
typedef std::pair<P, P> PP;

long n, m;
std::string field[2005];
PP count[2005][2005];//first:横(first:前, second,あと)

int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 0; i <= m+1; i++){
		field[0].push_back('#');
		field[n+1].push_back('#');
	}
	for(int i = 1; i <= n; i++){
		std::string s;
		std::cin >> s;
		field[i].push_back('#');
		field[i] += s;
		field[i].push_back('#');
	}
	/*
	for(int i = 0; i <= n+1; i++){
		std::cout << field[i] << std::endl;
	}
	//*/
	for(int i = 1; i <= n; i++){
		long cnt = 0;
		for(int j = 1; j <= m; j++){
			count[i][j].first.first = cnt;
			if(field[i][j] == '.'){
				cnt++;
			}else{
				cnt = 0;
			}
		}
		cnt = 0;
		for(int j = m; j > 0; j--){
			count[i][j].first.second = cnt;
			if(field[i][j] == '.'){
				cnt++;
			}else{
				cnt = 0;
			}
		}
	}
	for(int j = 1; j <= m; j++){
		long cnt = 0;
		for(int i = 1; i <= n; i++){
			count[i][j].second.first = cnt;
			if(field[i][j] == '.'){
				cnt++;
			}else{
				cnt = 0;
			}
		}
		cnt = 0;
		for(int i = n; i > 0; i--){
			count[i][j].second.second = cnt;
			if(field[i][j] == '.'){
				cnt++;
			}else{
				cnt = 0;
			}
		}
	}
	long ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			long res = count[i][j].first.first + count[i][j].first.second + count[i][j].second.first + count[i][j].second.second + 1;
			//printf("(%d %d), %ld\n", i, j, res);
			if(field[i][j] == '.'){
				ans = std::max(ans, res);
			}
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 133504
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            label:
            var a = A();
            if (a == null)
            {
                WriteLine(-1);
            }
            else
            {
                foreach(var n in a)
                {
                    WriteLine(n);
                }
            }
        }

        static List<int> A()
        {
            var list = new List<int>();
            ReadLine();
            var li2 = ReadLine().Split(' ').Select(int.Parse).ToList();
            while (li2.Count > 0)
            {
                int i = li2.Count - 1;
                for (; 0 <=i; --i)
                {
                    if (li2[i] == i + 1)
                    {
                        list.Add(i + 1);
                        li2.RemoveAt(i);
                        break;
                    }
                }
                if (i < 0) return null;
            }
            list.Reverse();
            return list;
        }
    }
}


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

int a, b, c, x, y;

int main(){

    cin >> a >> b >> c >> x >> y;

    int price = 0, a_half, b_half, diff;
    diff = abs(x-y);

    if (a+b >= 2*c){
        price += min(x, y)*c*2;

        if (min(x, y) == x){
            if (b >= 2*c){
                price += diff*c*2;
            }
            else{
                price += diff*b;
            }
        }
        else{
            if (a >= 2*c){
                price += diff*c*2;
            }
            else{
                price += diff*a;
            }
        }
    }
    else{
        if (b >= 2*c){
            price += y*c*2;
        }
        else{
            price += y*b;
        }
        if (a >= 2*c){
            price += x*c*2;
        }
        else{
            price += x*a;
        }
    }

    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int[] arr = new int[N];
        arr[0] = scanner.nextInt()-1;
        for(int i = 1; i < N; i++) {
            int next = scanner.nextInt();
            if (next > arr[i-1]) arr[i] = next-1;
            else arr[i] = next;
        }
        boolean bad = false;
        for(int i = 1; i < N; i++) {
            if (arr[i-1] > arr[i]) bad = true;
        }
        if (bad) out.println("No");
        else out.println("Yes");
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 40152
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    ss=readline().rstrip()
    tt=readline().rstrip()

    if (len(ss)+1)==len(tt):
        a=0
    else:
        print("No")
        return
    for i in range(len(ss)):
        if ss[i]!=tt[i]:
            print("No")
            return
    print("Yes")
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16132
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        for(;;){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if ((h == 0) && (w == 0)) break;
            sc.nextLine();
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if ((i+j) % 2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

using namespace std;

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

    int n;
    cin>>n;

    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];

    int q;
    cin>>q;

    while(q--)
    {
        int a,b,c;
        cin>>a>>b>>c;

        swap_ranges(arr.begin()+a,arr.begin()+b,arr.begin()+c);
    }

    for(int i=0;i<n;i++) cout<<arr[i]<<(i==n-1?'\n':' ');

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

inline double SQ (double d) {
    return d * d;
}

int main (void) {
    int n;
    double x1, x2, x3, y1, y2, y3;
    cin >> n;
    while (n--) {
        cin >> x1; cin >> y1;
        cin >> x2; cin >> y2;
        cin >> x3; cin >> y3;
        double x, y;
        x = ((y1 - y2) * (SQ(x1) - SQ(x3) + SQ(y1) - SQ(y3)) -
             (y1 - y3) * (SQ(x1) - SQ(x2) + SQ(y1) - SQ(y2))) /
            (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3));
        y = ((x1 - x2) * (SQ(y1) - SQ(y3) + SQ(x1) - SQ(x3)) -
             (x1 - x3) * (SQ(y1) - SQ(y2) + SQ(x1) - SQ(x2))) /
            (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3));
        double r = sqrt(SQ(x1- x) + SQ(y1 - y));
        cout << setprecision(3) << fixed << x << ' ' << y << ' ' << r << endl;
    }
    return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, a[100100], ans=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        a[i]--;
    }
    for(i=0;i<n;i++){
        if(a[i]!=-1){
            if(a[a[i]]==i){
                ans++;
                a[a[i]]=-1;
            }
        }
    }
    cout << ans <<endl;
}



Measured memory_bytes: 1024
n = int(input())

talk = []
for i in range(n):
    a = int(input())
    talk += [[list(map(int, input().split())) for _ in range(a)]]
    
ans = 0

for i in range(2**n):
    result = [True] * n
    
    for j in range(n):
        if ((i >> j) & 1):
            result[n-1-j] = False
    check = 1
    for k in range(n):
        for x, y in talk[k]:
            if result[k] == True:
                if result[x - 1] == y:
                    continue
                else:
                    check = 0
                    break
        else:
            continue
        break
    if check == 1:
        ans = max(ans, sum(result))
        
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int GCD(int a, int b)
{
    if(a < b) {
        return GCD(b, a);
    }
    
    if(b == 0) {
        return a;
    }
    
    return GCD(a % b, b);
}

int main() {
	int a = 0;
	int b = 0;
	
	scanf("%d", &a);
	scanf("%d", &b);
	printf("%d\n", GCD(a, b));
    return 0;
}


Measured memory_bytes: 2148
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint dp[100005][2];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	rep(i,n){
		if(s[i] == '0'){
			dp[i+1][0] = dp[i][0];
			dp[i+1][1] = dp[i][1] * 3;
		}
		else{
			dp[i+1][0] = dp[i][0] * 2;
			dp[i+1][1] = dp[i][0] + dp[i][1] * 3;
		}
		//cout << dp[i+1][0].x << " " << dp[i+1][1].x << endl;
	}
	mint ans = dp[n][0] + dp[n][1];
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    for(int i = 0; i< M;i++){
        cin >> a.at(i);
    }
    int count = 0;
    for(int i = 0; i< M;i++){
        count += a.at(i);
    }
    if(count > N){
        printf("-1\n");
    }
    else{
        printf("%d\n", N-count);
    }
    
}

Measured memory_bytes: 3760
X, N = map(int, input().split())
pn = list(map(int, input().split()))
diff = 100
ans = X
if pn:
    for i in range(min(pn)-1, max(pn)+2):
        if i in pn:
            continue
        if abs(X-i) < diff:
            diff = abs(X-i)
            ans = i
print(ans)


Measured memory_bytes: 9124
while 1:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    P = []
    K = []
    for i in range(N):
        k, *S = map(int, input().split())
        P.append(list(zip(S[::2], S[1::2])))
        K.append(k)
    INF = 10**18
    memo = {}
    def dfs(i, j, k):
        key = i, j, k
        if key in memo:
            return memo[key]
        if i == N-2 and k < M:
            return 0
        if i == N-1:
            return 0
        res = INF
        xi, di = P[i][j]
        for p in range(K[i+1]):
            xj, dj = P[i+1][p]
            res = min(res, dfs(i+1, p, k) + abs(xi - xj)*(di + dj))
        if i+2 < N and k < M:
            for p in range(K[i+2]):
                xj, dj = P[i+2][p]
                res = min(res, dfs(i+2, p, k+1) + abs(xi - xj)*(di + dj))
        memo[key] = res
        return res
    ans = INF
    for i in range(K[0]):
        ans = min(ans, dfs(0, i, 0))
    if 0 < M:
        for i in range(K[1]):
            ans = min(ans, dfs(1, i, 1))
    print(ans)



Measured memory_bytes: 16340
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int[][] a = new int[H][W];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) a[i][j] = scanner.nextInt();

    final StringBuilder sb = new StringBuilder();
    int size = 0;

    for (int i = 0; i < H * W - 1; i++) {
      int y = i / W;
      int x = y % 2 == 0 ? i - y * W : (y + 1) * W - i - 1;
      if (a[y][x] % 2 == 1) {
        int ny = (i + 1) / W;
        int nx = ny % 2 == 0 ? (i + 1) - ny * W : (ny + 1) * W - i - 2;
        a[ny][nx]++;
        size++;
        sb.append(String.format("%d %d %d %d\n", y + 1, x + 1, ny + 1, nx + 1));
      }
    }

    System.out.println(size);
    System.out.print(sb.toString());
  }
}


Measured memory_bytes: 170048
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<=n;i++){
		string x=tostring(i);
		if(x.length()%2!=0)
			cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







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

struct TCard
{
    char Suit;
    int  Num;
    bool operator==(const TCard& C)const
    {
        return Suit == C.Suit && Num == C.Num;
    }
    bool operator <(const TCard& C)const
    {
      return Num < C.Num;
    }
};
typedef std::vector<TCard> TList;

int partition(TList& A, int p, int r)
{
  int x = A[r].Num;
  int i = p - 1;
  for(int j = p; j < r; ++j){
    if(A[j].Num <= x){
      i = i + 1;
      std::swap(A[i],A[j]);
    }
  }
  std::swap(A[i+1],A[r]);
  return i+1;
}

void quickSort(TList& A, int p, int r)
{
  if(p < r){
    int q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i].Suit;
        std::cin >> List[i].Num;
    }
    return List;
}
void Output(const TList& List)
{
    TList::const_iterator It = List.begin();
    std::cout << It->Suit << " " << It->Num;
    for(++It; It != List.end(); ++It){
        std::cout << "\n" << It->Suit << " " << It->Num;
    }
    std::cout << std::endl;
}
void Check(const TList& List, const TList& Stable)
{
    // if(std::equal(List.begin(), List.end(), Stable.begin())){
    if(List == Stable){
        std::cout << "Stable" << std::endl;
    }else{
        std::cout << "Not stable" << std::endl;
    }
}

int main()
{
    const TList List = Input();
    TList StableList = List;
    std::stable_sort(StableList.begin(), StableList.end());

    TList QuickList = List;
    quickSort(QuickList, 0, QuickList.size() - 1);
    Check(QuickList, StableList);
    Output(QuickList);
    return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  string s;
  cin>>s;
  int ans = 0;
  string t, p = "";
  rep(i,sz(s)) {
    t += s[i];
    if (t == p) continue;
    p = t;
    t = "";
    ++ans;
  }
  cout<<ans<<endl;
  return 0;
}



















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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
//#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define DMP(x) 0

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}
const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

const int inf=LLONG_MAX/3;

const int Nmax=114;
int buf[2][Nmax][Nmax];

signed main(){
	int n=read();
	vi a;
	REP(i,2*n-1)a.PB(read()-1);
	sort(ALL(a));
	vi pos(2*n-1,-1);
	REP(i,2*n-1)if(abs(i-(n-1))<abs(pos[a[i]]-(n-1)))
		pos[a[i]]=i;
	vi use(2*n-1);
	REP(i,2*n-1)use[i]=(i==pos[a[i]]);
	int cur=0;
	buf[cur][1][0]=1;
	FOR(i,1,n){
		int x=use[n-1-i],y=use[n-1+i];
		DMP(x);
		DMP(y);
		int nx=cur^1;
		memset(buf[nx],0,sizeof(buf[nx]));
		FOR(j,1,2*n-1+1)REP(k,j)
			buf[nx][j+x+y][k+x]=buf[cur][j][k];
		swap(cur,nx);
		memset(buf[nx],0,sizeof(buf[nx]));
		FOR(j,1,2*n-1+1)REP(k,j)if(buf[cur][j][k])
			REP(to,j){
				DMP(j);
				DMP(k);
				DMP(to);
				if(to<=k)
					add(buf[nx][j-max(0LL,k-to-1)][to],buf[cur][j][k]);
				else
					add(buf[nx][j-max(0LL,to-k-1)][k+1],buf[cur][j][k]);
			}
		swap(cur,nx);
	}
	int ans=0;
	FOR(j,1,2*n-1+1)REP(k,j){
		DMP(cur<<" "<<j<<" "<<k<<" "<<buf[cur][j][k]);
		add(ans,buf[cur][j][k]);
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n, m;
    cin >> n >> m;
    int sx, sy;
    cin >> sx >> sy;
    int dx, dy;
    cin >> dx >> dy;
    var(sx, sy, dx, dy);
    // return;
    vector<vector<char>> a(n, vector<char>(m));
    for (auto &it: a) {
        for (auto &ch: it) {
            cin >> ch;
        }
    }
    deque<array<int, 3>> q;
    // return;

    --sx, --sy;
    --dx, --dy;
    q.push_back({0, sx, sy});
    vector<vector<bool>> vis(n, vector<bool> (m));
    const int inf = 1e9;
    vector<vector<int>> dist(n, vector<int> (m, inf));
    var(sx, sy);
    while (!q.empty()) {
        auto it = q.front();
        q.pop_front();
        int r = it[1], c = it[2], cost = it[0];
        for (int x = -2; x <= 2; ++x) {
            for (int y = -2; y <= 2; ++y) {
                    int new_r = x + r;
                    int new_c = y + c;
                    if (new_c < 0 or new_c >= m or new_r < 0 or new_r >= n) {
                        continue;
                    }
                    int cost = ((abs(r - new_r) + abs(c - new_c)) > 1);
                    int &ref = dist[new_r][new_c];
                    if (a[new_r][new_c] == '.' && ref > cost + it[0]) {
                        ref = cost + it[0];
                        if (cost)
                            q.push_back({ref, new_r, new_c});
                        else
                            q.push_front({ref, new_r, new_c});
                    }
                }
        }
    }
    stl(dist);
    assert(dist[sx][sy] == 0);
    cout << (dist[dx][dy] == inf ? -1 : dist[dx][dy]) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}


Measured memory_bytes: 12820
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	string S;
	cin >> S;
	int N = S.size();
	int tigau = 0;

	char C = S[0];
	rep(i, N) {
		if (C != S[i]) tigau = 1;
	}
	if (!tigau) {
		co(N);
		co(1);
		return 0;
	}

	int Z[500000];
	Z[0] = N;
	int i = 1;
	int j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	bool mae[500000] = {};
	rep1(i, N - 1) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			mae[j] = 1;
		}
	}
	if (!mae[N - 1]) {
		co(1);
		co(1);
		return 0;
	}
	Z[0] = N;
	i = 1;
	j = 0;
	while (i < N) {
		while (i + j < N && S[N - 1 - j] == S[N - i - j - 1]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}

	bool ato[500000] = {};
	rep1(i, N - 1) {
		for (int j = i + i - 1; j < Z[i] + i; j += i) {
			ato[N - j - 1] = 1;
		}
	}
	int kotae = 0;
	rep(i, N - 1) {
		if (!mae[i] && !ato[i + 1]) kotae++;
	}
	co(2);
	co(kotae);


	Would you please return 0;
}

Measured memory_bytes: 3740
n = int(input())
if n == 3:
    print(2, 5, 63)
    quit()
if n == 4:
    print(2, 5, 20, 63)
    quit()
if n == 5:
    print(2, 5, 20, 30, 63)
    quit()
s = set()
num = ssum = 0
for i in range(2, 30001):
    if i%2 == 0 or i%3 == 0:
        s.add(i)
        ssum += i
        num += 1
    if num == n:
        if ssum % 6 == 2:
            s.discard(8)
            s.add((i//6+1)*6)
        if ssum % 6 == 3:
            s.discard(9)
            s.add((i//6+1)*6)
        if ssum % 6 == 5:
            s.discard(8)
            s.add((i+3)//6*6+3)
        break
print(" ".join(map(str, s)))

Measured memory_bytes: 5472
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    int N, A, B;
    string S;
    cin >> N >> A >> B;
    cin >> S;
    int count = 0;
    int countB = 0;
    for(int i = 0; i < S.length(); ++i) {
        if(S[i] == 'c') {
            printf("No\n");
        }
        else if(S[i] == 'b') {
            if(count < A + B && countB < B) {
                printf("Yes\n");
                ++count;
                ++countB;
            }
            else {
                printf("No\n");
            }
        }
        else {
            if(count < A + B) {
                printf("Yes\n");
                ++count;
            }
            else {
                printf("No\n");
            }
        }
    }
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ll N,K,a;
cin >> N >> K;
a=N%K;
if(N%K==0){
  cout << "0" << endl;
}else{
if(K/2>N){
  cout << N << endl;
}else{
  if(a<K){
    cout << K-a << endl;
  }else{
    cout << N%K << endl;
  }
}
}
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int sum=0,l;
  cin>>s;
  l = s.length();
  for(int i =0 ; i < l/2 ; i++)
    {
		if(s[i]!=s[l-1-i])
          sum = sum +1;
        else
        continue;
    }
  cout<<sum;
  return 0;
}
    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  n++;
  vector<int> a(n);
  vector<int64_t> s(n,0);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    s.at(0)+=a.at(i);
  }
  for(int i=1;i<n;i++)
    s.at(i)=s.at(i-1)-a.at(i-1);
  vector<int64_t> c(n);
  c.at(0)=1;
  int64_t x=1-(a.at(0));
  bool f=1;
  for(int i=1;i<n;i++){
    x=min(x*2,s.at(i));
    if(x>=a.at(i)){
      c.at(i)=x;
      x-=a.at(i);
    }else{
      f=0;
      break;
    }
  }
  if(x==0&&f){
    int64_t v=0;
    for(int i=0;i<n;i++)
      v+=c.at(i);
    cout<<v<<endl;
  }else
    cout<<-1<<endl;
}

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

typedef long long ll;
const int N = 17;

int n, a[N][N], b[N], cnt;
ll f[1 << N], val[1 << N];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
	}
	for(int S = 1; S < (1 << n); ++S) {
		cnt = 0;
		for(int i = 0; i < n; ++i) {
			if((S >> i) & 1) b[++cnt] = i;
		}
		for(int i = 1; i <= cnt; ++i) {
			for(int j = i + 1; j <= cnt; ++j) val[S] += a[b[i]][b[j]];
		}
	}
	for(int S = 1; S < (1 << n); ++S) {
		for(int S1 = S; S1; S1 = (S1 - 1) & S) {
			f[S] = max(f[S], f[S ^ S1] + val[S1]);
		}
	}
	printf("%lld\n", f[(1 << n) - 1]);
}

Measured memory_bytes: 1280
x, n = (int(x) for x in input().split())
p_list = list(map(int, input().split()))

ans = 0

max_ = 0
min_ = 0

# 増える側
for i in range(x, 102, 1) :

    # print('i+')
    # print(i)

    if i not in p_list:
        # print('確定')
        max_ = i
        break

# 減る側
for j in reversed(range(x + 1)) :

    # print('j-')
    # print(j)

    if j not in p_list:
        # print('確定')
        min_ = j
        break

# print('min')
# print(min_)
# print('max')
# print(max_)


# print(abs (x - min_))
# print(abs (x - max_))

if abs (min_ - x) <= abs(max_ - x) :
    ans = min_
else : 
    ans = max_

print(ans)


Measured memory_bytes: 9088
#include <iostream>

using namespace std;

class Mat
{
public:
    Mat(int sr,int sc)
    {
        r = sr;
        c = sc;
        n = new long long int*[r];
        for(int i = 0;i < r;i++)
        {
            n[i] = new long long int[c];
        }
    }

    long long int** n;
    int r;
    int c;
};


int main()
{
    int n,m,l;
    cin >> n >> m >> l;
    Mat mat1(n,m);
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            int t;
            cin >> t;
            mat1.n[i][j] = t;
        }
    }
    Mat mat2(m,l);
    for(int i = 0;i < m;i++)
    {
        for(int j = 0;j < l;j++)
        {
            int t;
            cin >> t;
            mat2.n[i][j] = t;
        }
    }

    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < l;j++)
        {
            long long int s = 0;
            for(int k = 0;k < m;k++)
            {
                s += mat1.n[i][k] * mat2.n[k][j];
            }
            if((j + 1) == l)
            {
                cout << s;
            }
            else
            {
                cout << s << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;


int main() {
        int N,X;
        int m[110];
        int Min=1000;

        cin >> N >> X;
        for(int i=0; i<N; i++) {
                cin >> m[i];
                X-=m[i];
                Min=min(Min,m[i]);
        }

        cout << N+X/Min <<endl;

        return 0;
}

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

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

  int n = s.size();
  int flag = 0;

  string s2 = s;
  rep(i,n){
    s2.at(i) = s.at(n - i - 1);
  }

  rep(i,n){
    if (s.at(i) != s2.at(i))
      flag++;
  }

  cout << flag/2;
}


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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    ll ansSum = 0;
    ll ans = sum;
    rep(i, n) {
        ansSum += a[i];
        sum -= a[i];
        ans = min(ans, abs(sum-ansSum));
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792