akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define ll long long int
ll ma(ll n)
{
    if (n%2==0)return n/2;
    else return n/2+1;
}
ll maxn(ll a,ll b)
{
    return a>b?a:b;
}
ll minn(ll a,ll b)
{
    return a<b?a:b;
}
int main()
{
    ll H,M;
    while (scanf("%lld %lld",&H,&M)==2)
    {
        ll cur;
        if (H%3==0||M%3==0)printf("0\n");
        else
        {
           // cur=10000000000;
            //cur=maxn(maxn(1*M,(H-1)*(M/2)),(H-1)*((M+1)/2))-minn(minn(1*M,(H-1)*(M/2)),(H-1)*((M+1)/2));//@@@@1
            cur=minn(H,M);
            for (ll i=1;i<H;i++)
            {
                cur=minn(maxn(maxn(i*M,(H-i)*(M/2)),(H-i)*((M+1)/2))-minn(minn(i*M,(H-i)*(M/2)),(H-i)*((M+1)/2)),cur);
            }
            ll t=H;H=M;M=t;
         //   cur=minn(maxn(maxn(1*M,(H-1)*(M/2)),(H-1)*ma(M))-minn(minn(1*M,(H-1)*(M/2)),(H-1)*ma(M)),cur);
            for (ll i=1;i<H;i++)
            {
                cur=minn(maxn(maxn(i*M,(H-i)*(M/2)),(H-i)*((M+1)/2))-minn(minn(i*M,(H-i)*(M/2)),(H-i)*((M+1)/2)),cur);
            }
            printf("%lld\n",cur);
        }
    }
    return 0;
}
//注意点@@@@1
//循环不到H


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main()
{
  int h,w;
  int dp[1005][1005] = {};
  char mas[1005][1005];
  cin >> h >> w;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> mas[i][j];
    }
  }

  dp[1][1] = 1;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(mas[i][j] != '#'){
	dp[i][j] += dp[i-1][j] % MOD + dp[i][j-1] % MOD;
      }
    }
  }

  cout << dp[h][w] % MOD << endl;
  return 0;
}


Measured memory_bytes: 5120
n, k = map(int, input().split())
C = list(map(int, input().split()))
D = []

for i in range(n - k + 1):
    l = C[i]
    r = C[i + k -1]
    route1 = abs(l) - l + r
    route2 = abs(r) - l + r
    dist = min(route1, route2)
    D.append(dist)
    
print(min(D))

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

int mod;
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 { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= 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) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

ll b, ten;

mint f(ll l) {
  if (l == 0) return 0;
  if (l%2 == 1) {
    ll pl = l-1;
    mint x = f(pl);
    return x*ten + 1;
  } else {
    ll pl = l/2;
    mint x = f(pl);
    return x*mint(ten).pow(pl) + x;
  }
}
mint g(ll l) {
  if (l == 0) return 0;
  if (l%2 == 1) {
    ll pl = l-1;
    mint x = g(pl);
    return x*ten + mint(b)*pl;
  } else {
    ll pl = l/2;
    mint x = g(pl);
    return x*mint(ten).pow(pl) + x + mint(b)*pl*f(pl);
  }
}

int main() {
  ll L, a;
  cin >> L >> a >> b >> mod;
  ten = 10;
  ll last = a + b * (L - 1);
  mint ans = 0;
  for (int i = 1; i <= 18; ++i, ten *= 10) {
    ll l = ten/10, r = ten - 1;
    if (a > r) continue;
    if (last < l) continue;
    ll na = 0, nl = 0, nlast = 0;
    {
      if (a >= l) na = a;
      else {
        na = ( l-a + b-1 )/b * b + a;
      }
    }
    {
      if (last <= r) nlast = last;
      else {
        nlast = (r - a)/b * b + a;
      }
      nl = (nlast - na)/b + 1; 
    }
    ans *= mint(ten).pow(nl);
    ans += f(nl)*na;
    ans += g(nl);
  }
  cout << ans << endl;
  return 0;  
}

Measured memory_bytes: 3624
import bisect

def main():
    s = input()
    qc = int(input())
    front = ""
    back = ""
    direct = 1
    for _ in range(qc):
        t = input()
        if t[0] == "1":
            direct = 2 if direct == 1 else 1
        else:
            _,f,c = t.split()
            if f == "1":
                if direct == 1:
                    front += c
                else:
                    back += c
            else:
                if direct == 1:
                    back += c
                else:
                    front += c
    if direct % 2 == 0:
        print((s+back)[::-1] + front)
    else:
        print(front[::-1]+s+back)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 4340
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N = xs[0];
   let K = xs[1];
   
   if((N+1)/2 >= K){
     console.log('YES');
   }else{
     console.log('NO');
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  100000000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll dp[2010];
ll dst[100100];
ll v[2010];
int main(){
	ll n,m,l;
	cin >> n >> m >> l;
	vector<ll> k(n),s(m);
	rep(i,n){
		cin >> k[i];
		k[i]--;
	}
	rep(i,m){
		cin >> s[i];
	}
	sort(k.begin(),k.end());
	dst[0] = 0;
	for(int i=1;i<=m;i++){
		dst[i] = dst[i-1] + s[i-1];
	}
	v[1] = (dst[k[1]+1]-dst[k[0]])/l;
	for (int i=2;i<n;i++){
		v[i] = v[i-1] + (dst[k[i]+1]-dst[k[i-1]])/l;
	}
	
	dp[n-1] = (dst[k[n-1]+1]-dst[k[n-2]])/l;
	for(int i=n-2;i>0;i--){
		dp[i] = inf;
		for(int j=i+1;j<n;j++){
			if(j==(i+1)){
				dp[i] = min(dp[i],(dst[k[j]+1]-dst[k[i-1]])/l+dp[j]);
				if(j==n-1){
					dp[i] = min(dp[i],(dst[k[j]+1]-dst[k[i]])/l+(dst[k[j]+1]-dst[k[i-1]])/l);
				}
			}else{
				dp[i] = min(dp[i],(dst[k[j]+1]-dst[k[i-1]])/l+v[j-1]-v[i]+dp[j]);
				dp[i] = min(dp[i],(dst[k[j]+1]-dst[k[i]])/l+(dst[k[i+1]+1]-dst[k[i-1]])/l+v[j-1]-v[i+1]+dp[j]);
			}
		}
	}

	ll mi = inf;
	for(int i=1;i<n;i++){
		mi = min(mi,dp[i]+(dst[k[i]+1]-dst[k[0]])/l+v[i-1]);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 4492
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut c = 1;
    let mut b = 1;
    for i in 0..n {
        b *= 3;
        if a[i] % 2 == 0 {
            c *= 2;
        }
    }
    println!("{}", b - c);
}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    map <int,int> mp;

    mp[1]++;
    mp[4]++;
    mp[9]++;
    mp[7]++;

    REP(i,4){
        int x;cin >> x;
        mp[x]++;
    }

    if(mp[1]==2&&mp[9]==2&&mp[4]==2&&mp[7]){
        cout << "YES" <<endl;
    }else{
        cout << "NO" <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int N, M;
    cin>>N>>M;
    double a[N], sum=0;
    rep(i, N){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a, a+N, greater<double>());
    if(a[M-1]<sum/(4*M)){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int>v;
    int sum = 0;
    while(N--){
        int a;
        cin >> a;
        v.push_back(a);
        sum += a;
    }
    double low = (double)sum /(4 * M);
    sort(v.rbegin(),v.rend());
    for(int i = 0;i < M;i++){
        if(v[i] < low){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main() {
  int n;
  cin >> n;
  bool b = false;
  for (int i = 0; i < n / 4 + 1; i++) {
    for (int j = 0; j < n / 7 + 1; j++) {
      if (n == i * 4 + j * 7) b = true;
    }
  }
  if (b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		puts([&] {
			if (A < B || B > D) return false;
			if (C >= B) return true;
			ll st = (A - B) % B;
			if (C < st) return false;
			ll g = gcd(B, D);
			ll mn = (st + (C + 1 - st + g - 1) / g * g) % B;
			return mn <= C;
		}() ? "Yes": "No");
	}
	return 0;
}


Measured memory_bytes: 256
import math

def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]


prime = primes(55555)
N = int(input())
print(' '.join((map(str,list(filter(lambda n:n%5==1, prime))[:N]))))

Measured memory_bytes: 5272
#include <iostream>
using namespace std;
int main(){
	int a = 0;
	int b = 0;
	int c = 0;
	int Ans = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++){
		if (c % i==0){
			Ans++;
		}
	}
	cout <<Ans<< endl;
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>

using namespace std;

char A, B;

void solve()
{
	if (A < B) cout  <<"<\n";
	if (A > B) cout << ">\n";
	if (A == B) cout << "=\n";
}

int main()
{
	cin >> A >> B;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int H,W;
  cin>>H>>W;
  vector<string> s(H);
  REP(i,H){
    cin>>s[i];
  }
  bool used[H][W]={};
  int dx[]={1,0,-1,0};
  int dy[]={0,1,0,-1};
  pair<int,int> p;
  int x,y,nx,ny;
  long long b,w;
  long long ans=0;
  REP(i,H){
    REP(j,W){
      if(used[i][j])continue;
      used[i][j] = true;
      b = 0;
      w = 0;
      if(s[i][j]=='#'){
        b++;
      }else{
        w++;
      }
      queue<pair<int,int>> q;
      q.push(make_pair(i,j));
      while(!q.empty()){
        p = q.front();
        q.pop();
        x = p.first;
        y = p.second;
        REP(k,4){
          nx = x + dx[k];
          ny = y + dy[k];
          if(0<=nx && nx<H && 0<=ny && ny<W && !used[nx][ny] && s[x][y]!=s[nx][ny]){
            used[nx][ny] = true;
            q.push(make_pair(nx,ny));
            if(s[nx][ny]=='#'){
              b++;
            }else{
              w++;
            }
          }else{
            continue;
          }
        }
      }
      ans += b*w;
    }
  }
  
  cout<<ans<<endl;    
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int kei(int,int); 
int main(){
  int x,y,i,a,an;
  scanf("%d%d",&x,&y);
  if(x<1,y>10000000000)exit(1);
  printf("%d\n",kei(x,y));
  return 0;
}
int kei(int x,int y){
    if(y==0)return x;
    if(x<y)return kei(x,y%x);
    else return kei(y,x%y);
}



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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        for (int i=0; i<b; i++) {
            cout << a;
        }
        cout << endl;
    } else {
        for (int i=0; i<a; i++) {
            cout << b;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans = 0;
    let mut i = 0;
    while i < n {
        if a[i] > 0 {
            let mut f = a[i];
            for j in i + 1..n + 1 {
                if j == n || a[j] == 0 {
                    ans += f;
                    for k in i..j {
                        a[k] -= f;
                    }
                    break;
                }
                f = std::cmp::min(f, a[j]);
            }
        } else {
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
s = input()
s_sort = ''.join(sorted(s))
s1 = s[0]
s1cnt = s_sort.count(s1)
if s1cnt == 2:
    s2 = s[2]
    s2cnt = s_sort.count(s2)
    if s2cnt == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
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;}
constexpr long long INF = 1e18;

signed main(){
	int N,M,P;
	cin >> N >> M >> P;
	vector<pair<int,int>>g[2525];
	REP(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		g[a].emplace_back(b,P-c);
	}
	vector<int>dist(N,INF);
	dist[0]=0;
	REP(i,N){
		REP(now,N){
			if(dist[now]==INF)continue;
			for(auto e:g[now]){
				CHMIN(dist[e.first],dist[now]+e.second);
			}
		}
	}
	int ans = dist[N-1];
	REP(i,N){
		REP(now,N){
			for(auto &e:g[now]){
				if(dist[now]==INF)continue;
				if(CHMIN(dist[e.first],dist[now]+e.second)){
					e.second = -INF;
					//cout<<now<<" "<<e.first<<endl;
				}
			}
		}
	}
	if(ans!=dist[N-1])cout<<-1<<endl;
	else cout<<max(0ll,-ans)<<endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int w, h, x, y, r;

int main(){
	cin >> w >> h >> x >> y >> r;
	if (0 <= x - r&&x + r <= w && 0 <= y - r&&y + r <= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1156
r=input().split()
N=int(r[0])
D=int(r[1])
d=[[int(s) for s in input().split()] for i in range(N)]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        dis=0
        for k in range(D):
            dis+=(d[i][k]-d[j][k])**2
        ans_pre=dis**(1/2)
        if type(ans_pre)==int or ans_pre.is_integer()==True:
            ans+=1
print(ans)

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

string s;
lli b;
lli ans;


int main(){
  cin >> s;
  for(char c : s){
    if(c == 'B') b++;
    else ans += b;
  }
  cout << ans << endl;



}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(init, i, n) for (int i = init; i < (n); i++)
#define ll long long
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
//コード自動整形 Shift + Option + F @vscode
using namespace std;

/////main/////
int main()
{
    string S, T;
    cin >> S >> T;

    ll Ss = S.length();
    ll Ts = T.length();

    ll output = 1000;
    ll temp = 0;
    rep(0,i,Ss-Ts+1){
        rep(0,j,Ts){
            if(S.at(i+j)!=T.at(j)){
                temp++;
            }

        }
        output = min(output,temp);
        temp = 0;

    }
    cout<<output<<endl;
}
/////main/////

/////function/////

Measured memory_bytes: 3620
from heapq import heapify, heappush, heappop

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * -1, input().split()))
heapify(A)

for _ in range(m):
    tmp = -1 * heappop(A)
    heappush(A, -1 * (tmp // 2))

print(-sum(A))

Measured memory_bytes: 14180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String str, s[];
		
		int n, q, date[];
		x : while(!(str = reader.readLine()).equals("0 0")){
			s = str.split(" ");
			n = Integer.valueOf(s[0]);
			q = Integer.valueOf(s[1]);
			
			date = new int[110];
			for(int i = 0; i < n; i++){
				s = reader.readLine().split(" ");
				for(int j = 1; j <= Integer.valueOf(s[0]); j++){
					date[Integer.valueOf(s[j])]++;
				}
			}
			for(int i = n; i >= q; i--)
				for(int j = 1; j < date.length; j++){
					if(date[j] == i){
						System.out.println(j);
						continue x;
					}
				}
			System.out.println(0);
		}
		reader.close();
	}
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

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

int main() {
    int n, p[52];

    cin >> n;
    int cnt = 0;
    for(int i=1; i<=n; i++) {
        cin >> p[i];
        if (p[i] != i) cnt ++;
    }

    if (cnt == 0 || cnt == 2) cout << "YES" <<endl;
    else cout << "NO" <<endl;

}



Measured memory_bytes: 256
# C
X = int(input())
import math

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

for i in range(X, 10**9):
    if (is_prime(i)):
        print(i)
        break

Measured memory_bytes: 38896
#include <stdio.h>
#include <algorithm>

int main() {
	int n, t[100001], x[100001], y[100001];
	t[0] = x[0] = y[0] = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d%d", t + i, x + i, y + i);
	for (int i = 1; i <= n; i++) {
		int dif = std::abs(x[i] - x[i - 1]) + std::abs(y[i] - y[i - 1]);
		int timed = t[i] - t[i - 1];
		if (((dif ^ timed) & 1) || timed < dif) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 1280
N=int(input())
list1=list(map(int, input().split()))

K=0

for i in range(N-2):
    if list1[i]>list1[i+2]:
        if list1[i]>list1[i+1] and list1[i+1]>list1[i+2]:
            K+=1
            
    else:
        if list1[i]<list1[i+1] and list1[i+1]<list1[i+2]:
            K+=1

print(K)

Measured memory_bytes: 3060
n = gets.chomp
n = n.to_i
vals = []
(0..(n - 1)).each do |i|
  name_p = gets.chomp.split(" ")
  vals[i] = {name: name_p[0], p: name_p[1].to_i, idx: i + 1}
end

vals.sort! do |a, b|
  if a[:name] > b[:name]
    1
  elsif a[:name] < b[:name]
    -1
  else
    if a[:p] < b[:p]
      1
    else
      -1
    end
  end
end

vals.each do |val|
  puts val[:idx]
end


Measured memory_bytes: 1788
a,b = map(int,input().split()) #白黒
grid = []
for i in range(50):
    whiteline = ["." for k in range(100)]
    grid.append(whiteline)
for i in range(50):
    blackline = ["#" for k in range(100)]
    grid.append(blackline)

b += -1
check = 1
x = 1
y = 1
while b > 0:
    grid[y][x] = "#"
    b += -1
    if x+2 < 50:
        x += 2
    else:
        check = check * (-1)
        if check == 1:
            x = 2
        else:
            x = 1
        y += 2

a += -1
check = 1
x = 1
y = 55
while a > 0:
    grid[y][x] = "."
    a += -1
    if x+2 < 50:
        x += 2
    else:
        check = check * (-1)
        if check == 1:
            x = 2
        else:
            x = 1
        y += 2

print(100,100)
for i in range(100):
    for k in range(100):
        if k != 99:
            print(grid[i][k],end = "")
        else:
            print(grid[i][k])

Measured memory_bytes: 4596
<?php
$haveCardNum = trim(fgets(STDIN));
$cardCheckList = createCardCheckList();
  
for ($i = 0; $i < $haveCardNum; $i++) {
    list($mark, $num) = getSpacesByExplodeTrimInput();
    $cardCheckList[$mark][$num] = 'check';
}
  
foreach ($cardCheckList as $mark => $value) {
    for ($cardNum = 1; $cardNum <= 13; $cardNum++) {
        if (! isset($cardCheckList[$mark][$cardNum])) {
            echo $mark.' '.$cardNum, PHP_EOL;
        }
    }
}
  
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}
  
function createCardCheckList()
{
    return array(
        "S" => array_fill(1, 13, null),
        "H" => array_fill(1, 13, null),
        "C" => array_fill(1, 13, null),
        "D" => array_fill(1, 13, null)
    );
}

Measured memory_bytes: 15380
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	ll x, k, d, xTemp, kTemp;
	cin >> x >> k >> d;
	ll ans = 0;
	if (x < 0) {
		// xは正の数だけ考えればよい
		x = abs(x);
	}
	else;

	if (k  <= x/d) {
		
		ans = abs(x - k * d);
	}

	else {
		ll e;
		e = x / d;
		xTemp =x- e*d;
		kTemp =k- e;
		if (kTemp %2== 0) {
			ans = xTemp;
		}
		else {
			if (xTemp >= 0) {
				ans = xTemp - d;
			}
			else {
				ans = xTemp + d;
			}
		}
	}
	ans = abs(ans);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3572
N,M = map(int,input().split())
*A, = map(int,input().split())

def gcd(x,y):
    if y==0:return x
    return gcd(y,x%y)

def main():
    if sum([a%2 for a in A])>0:
        print(0)
        return
    n = 1
    a = A[0]
    while a%2==0:
        n*=2
        a//=2
    for a in A:
        if not(a%n==0 and a%(n*2)!=0):
            print(0)
            return
    B = [a//2 for a in A]
    lcm = B[0]
    for b in B[1:]:
        g = gcd(lcm,b)
        lcm = lcm*b//g
    ans = M//lcm
    if ans%2:
        ans = ans//2 + 1
    else:
        ans = ans//2
    print(ans)
main()

Measured memory_bytes: 14428
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;
    cin >> N;

    vector<ll> a(N);
   
    ll cnt = 0;

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

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

    bool ans = false;

    if (cnt == N) {
        ans = true;
    }
    else if (N % 3 == 0) {
        if (cnt == N / 3) {
            ans = true;
            repl(i, N / 3, N) {
                if (a[i] != a[N / 3]) {
                    ans = false;
                    break;
                }
            }
        }
        else if (((a[0] ^ a[N / 3]) ^ a[2 * N / 3]) == 0) {
            ans = true;
            rep(i, 3) {
                repl(j, i * N / 3, (i + 1) * N / 3) {
                    if (a[j] != a[i * N / 3]) {
                        ans = false;
                        break;
                    }
                }
            }
        }
    }

    if(ans){
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 4048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

int N;
vector<vector<int>> A,G;
vector<int> dist;
vector<bool> seen;
bool ok = false;
int dfs(int v) {
    if (dist[v] != -1) return dist[v];
    seen[v] = true;
    int res = 0;
    for (auto nv : G[v]) {
        if (seen[nv] && dist[nv] == -1) ok = true;
        else chmax(res,dfs(nv)+1);
    }
    return dist[v] = res;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    A.resize(N, vector<int>(N-1));
    rep(i,N) {
        rep(j,N-1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    map<pii, int> dic;
    int k = 0;
    rep(i,N-1) {
        for (int j = i+1; j < N; j++) {
            dic.emplace(make_pair(i,j),k);
            k++;
        }
    }
    G.resize(k);
    rep(i,N) {
        rep(j,N-2) {
            int p = dic[minmax(i,A[i][j])];
            int q = dic[minmax(i,A[i][j+1])];
            G[p].emplace_back(q);
        }
    }
    dist.assign(k,-1);
    seen.assign(k,false);
    int ans = 0;
    rep(i,k) chmax(ans,dfs(i));

    cout << (ok ? -1 : ans+1) << endl;
}

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

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

	int sum = 0;
	int ans = 700;

	if (S[0] == 'o') sum++;
	if (S[1] == 'o') sum++;
	if (S[2] == 'o') sum++;

	cout << ans + 100*sum << endl;
}

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

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

    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = 0; i + d < 25; i++)
        cout << " Eve";
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, m, temp;
	int t[100001], p[100001], x[100001];
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%d",&t[i]);
	}
	scanf("%d",&m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d",&p[i],&x[i]);
	}

	for (int i = 0; i < m; i++) {
		int lap = 0;
		temp = t[p[i] - 1];
		t[p[i] - 1] = x[i];
		for (int j = 0; j < n; j++) {
			lap += t[j];
		}
		printf("%d\n",lap);
		t[p[i] - 1] = temp;
	}
	return 0;
}

Measured memory_bytes: 128
N, K = [int(x) for x in input().split()]
R, S, P = [int(x) for x in input().split()]
T = input()

# 相手に勝つ時に得られる点数
def rsp(hand):  # hand : 相手の手
    if hand == 'r':
        ret = P
    elif hand == 's':
        ret = R
    else:
        ret = S
    return ret

ans = 0
for i in range(K):
    Ti = T[i : : K]
    cnt = 0
    for j in range(len(Ti)):
        if j == 0 or Ti[j] == Ti[j - 1]:
            cnt += 1
        else:
            ans += rsp(Ti[j - 1]) * ((cnt + 1) // 2)
            cnt = 1
    ans += rsp(Ti[-1]) * ((cnt + 1) // 2)

print(ans)

Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll x;
    cin>>x;
    if(x<=6)
    {
        cout<<"1"<<endl;

    }
    else if(x<=11)
    {
        cout<<"2"<<endl;
    }
    else
    {
        ll ans=x/11;
        ans*=2;
        ll rem=x%11;
        if(rem>=1 && rem<=6)
            ans++;
        else if(rem >6)
            ans+=2;

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


Measured memory_bytes: 3660
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int N; cin >> N;
    vector<int> p(N); REP(i, N) cin >> p.at(i);
    sort(ALL(p), greater<int>());

    int sum = 0;
    REP(i, N){
        if(i == 0){
            sum += p.at(i) / 2;
            continue;
        }
        sum+=p.at(i);
    }

    cout << sum;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int data[100001];
    int ans = 0, temp=0;

    rep(i, n)cin >> data[i];

    rep(i, n-1){
        if(data[i]>=data[i+1]){
            temp++;
        }else{
            ans = max(ans,temp);
            temp=0;
        }
    }

    ans = max(ans,temp);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
def dfs(g, s, u):
    s.add(u)
    if len(s) == len(g):
        return True
    for v in g[u]:
        if v not in s:
            if dfs(g, s, v):
                return True
    return False

n, m = map(int, input().split())
e = []
for _ in range(m):
    a, b = map(int, input().split())
    e.append((a - 1, b - 1))
c = 0
for i in range(m):
    g = [list() for _ in range(n)]
    for j in range(len(e)):
        if j == i: continue
        a, b = e[j]
        g[a].append(b)
        g[b].append(a)
    if not dfs(g, set(), 0): c += 1
print(c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PI 3.14159265358979323846
#define MOD 1000000007
#define INF (int)1e9

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int N, A[100000][3];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i][0] >> A[i][1] >> A[i][2];
	int dp[100000][3];
	for(int i = N - 1; i >= 0; i--)
		for(int j = 0; j < 3; j++)
			if(i == N - 1) dp[i][j] = A[i][j];
			else if(j == 0) dp[i][j] = A[i][j] + max(dp[i + 1][1], dp[i + 1][2]);
			else if(j == 1) dp[i][j] = A[i][j] + max(dp[i + 1][0], dp[i + 1][2]);
			else dp[i][j] = A[i][j] + max(dp[i + 1][0], dp[i + 1][1]);
	cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << "\n";
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
/*
int dfs(int foo, int timer)
{
    //foo is node number
    if (finds[foo].first != -1)
        return timer;
    finds[foo].first = ++timer;
    int result = timer;
    if (data[foo].size() != 0)
    {
        rep(i, data[foo].size())
        {
            result = dfs(data[foo][i], result);
        }
    }
    finds[foo].second = ++result;
    return result;
}
*/

int main()
{
    int n, m;
    while (true)
    {
        cin >> n >> m;
        if (n == 0 || m == 0)
            break;
        vector<string> a;
        vector<int> b;
        rep(i, n)
        {
            string c;
            int d;
            cin >> c >> d;
            a.push_back(c);
            b.push_back(d);
        }
        int ans = 0;
        rep(i, m)
        {
            string num;
            cin >> num;
            rep(j, a.size())
            {
                string foo = a[j];
                rep(k, foo.size())
                {
                    if (foo[k] == '*')
                    {
                        foo[k] = num[k];
                    }
                }
                if (foo == num)
                    ans += b[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j<= N; j++) {
			if (10000 * i + 5000 * j + (N - i - j) * 1000 == Y){
				if ((N - (i + j)) < 0)continue;
				cout << i << " " << j << " " << N - i - j;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1";
}

Measured memory_bytes: 384
/**************************************************
  Solution to: ABC 174 A - Air Conditioner
  Writer: InvisibleCyclist
  By/Based on: 
**************************************************/
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n>=30){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll gcd(ll x, ll y)
{
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		string s; cin >> s; if (s == "#") break;
		ll bunsi = 0;
		ll bunbo = 1;
		reverse(s.begin(), s.end());
		int i = 0;
		if (s[i] == 'h') i += 5;
		else bunsi = 90, i += 4;
		for (; i < s.size(); i++) {
			if (s[i] == 'h') {
				bunsi = bunsi * 2 - 90;
				bunbo *= 2;
				i += 4;
			}
			else {
				bunsi = bunsi * 2 + 90;
				bunbo *= 2;
				i += 3;
			}
		}

		ll g = gcd(bunsi, bunbo);
		bunsi /= g;
		bunbo /= g;
		if (bunbo == 1) {
			cout << bunsi << "\n";
		}
		else {
			cout << bunsi << "/" << bunbo << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3188
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex;

void main(){
	auto n=readln.chomp.to!int;
	if(n%2==0)writeln(n);
	else writeln(2*n);	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b;
    char c;
    cin >> a >> c >> b;
    int ans = 0;
    if (c=='+') ans = a+b;
    else ans = a-b;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}

bool isSym(const char m[300][300],ll a,ll b,ll c,ll d){
    char inner[b-a][b-a];
    rep(i,b-a) rep(j,b-a){
        inner[i][j] = m[i+a][j+c];
    }
    rep(i,b-a) rep(j,b-a){
        if(inner[i][j] != inner[j][i]){
            return false;
        }
    }
    return true;
};
bool isSym2(const char m[300][300],ll i,ll n){
    return true;
};

int main() {
    ll n;
    cin>>n;
    char mat[300][300];
    rep(i, n) rep(j,n){
        cin>>mat[i][j];
    }
    ll sum=0;
    rep(i, n){
        bool a = isSym(mat,0,n-i,i,n);
        bool b = isSym(mat,n-i,n,0,i);
//        bool c = isSym2(mat,i,n);
        bool c = true;
        fr(ii, 0, n-i) {
            fr(jj, 0, i){
                if(mat[ii][jj]!=mat[n-i+jj][i+ii]){
                    c=false;
                    break;
                }
            }
            if(!c) break;
        }
        if(a&&b&&c) sum+=n;
    }
//    pr(mat[0][1]);
    pr(sum);
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	string s;
	cin>>s;
	if(s=="SUN")cout<<7<<endl;
	else if(s=="MON")cout<<"6"<<endl;
	else if(s=="TUE")cout<<"5"<<endl;
	else if (s=="WED")cout<<"4"<<endl;
	else if(s=="THU")cout<<"3"<<endl;
	else if(s=="FRI")cout<<2<<endl;
	else cout<<1<<endl;
	return 0;
}/*『你强归你强，我永不示弱』*/




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
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;
}
 
const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 305;
 
int N, M, L, A, B, C, Q, S, T;
vector<l_l> graph[MX];
 
vector<ll> refills[MX], gas[MX];
void dijkstra(int s,vector<ll> &r, vector<ll> &g) {
	r.assign(MX, INF);
	g.assign(MX, -1);
	vector<bool> u(N, false);
	
    r[s] = 0;
    g[s] = L;
    for (int i = 0; i < N; i++) {
        int v = -1;
        for (int j = 1; j <= N; j++) {
            if (!u[j]) {
				if (v == -1) v = j;
				else if (r[j] < r[v]) v = j;
				else if (r[j] == r[v] && g[j] > g[v]) v = j;
			}
        }
		
        if (r[v] == INF)
            break;
 
        u[v] = true;
        for (auto edge : graph[v]) {
            int to = edge.first;
            int len = edge.second;
			
			if (g[v] < len) {
				if (r[v] + 1 < r[to] || (r[v] + 1 == r[to] && L - len > g[to])) {
					r[to] = r[v] + 1;
					g[to] = L - len;
				}
			} else {
				if (r[v] < r[to] || (r[v] == r[to] && g[v] - len > g[to])) {
					r[to] = r[v];
					g[to] = g[v] - len;
				}
			}
        }	
	}
}
 
void solve() {
    cin >> N >> M >> L;
    
    for (int i = 0; i < M; i++) {
		cin >> A >> B >> C;
		if (C > L) continue;
		graph[A].push_back({B, C});
		graph[B].push_back({A, C});
	}
	
	for (int i = 1; i <= N; i++) {
		dijkstra(i, refills[i], gas[i]);
	}
	
	cin >> Q;
	// DJIKSTRA
	while (Q--) {
		cin >> S >> T;
		refills[S][T] == INF ? cout << "-1\n" : cout << refills[S][T] << "\n";
	}
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll testCases = 1; // cin >> testCases;
    while (testCases--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}
 
/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

int main() {
    std::string str;
    std::stringstream ss;
    int q;
    std::cin >> str >> q;
    for (int i=0;i<q;++i) {
        std::string cmd;
        std::cin >> cmd;
        if (cmd == "print") {
            int a, b;
            std::cin >> a >> b;
            ss << str.substr(a, b-a+1) << std::endl;
        }
        if (cmd == "reverse") {
            int a, b;
            std::cin >> a >> b;
            std::reverse(str.begin() + a, str.begin() + b + 1);
        }
        if (cmd == "replace") {
            int a, b;
            std::string p;
            std::cin >> a >> b >> p;
            str.replace(a, b-a+1, p);
        }
    }
    std::cout << ss.str();

    return 0;
}


Measured memory_bytes: 3232
# -*- coding: utf-8 -*-

A,B,C,D,E,F = map(int, input().split())

alpha = E/(100.0+E) # 最大濃度（これを超えて終了することはできない）

#water = sugar = 0
sugar_limit = 0 # 水が100入るとEだけ増える（1入るとE/100増える），砂糖をn入れるとn減る

a = b = c = d = 0
a_max = F // (100*A)
b_max = F // (100*B)
#c_max = F // C
#d_max = F // D

water_pattern = []
for i in range(a_max+1):
    for j in range(b_max+1):
        water_pattern.append(100*A*i + 100*B*j)

# 溶かせるだけ溶かした場合の最大濃度を記憶
max_density = -1.0
ans_water = 0.0
ans_sugar = 0.0
for water_amount in water_pattern:
    if water_amount > F:
        continue
    sugar_limit = water_amount * (E/100)
    # 制限を超えない範囲でできるだけたくさんの砂糖を加える
    c_max = (F-water_amount) // C
    d_max = (F-water_amount) // D
    max_sugar_amount = -1.0
    sugar_pattern = []
    '''
    for i in range(c_max+1):
        for j in range(d_max+1):
            sugar_pattern.append(C*i + D*j)
    for sugar_amount in sugar_pattern:
        if sugar_amount > sugar_amount
    '''
    for i in range(c_max+1):
        for j in range(d_max+1):
            sugar_amount = C*i + D*j
            if sugar_amount > sugar_limit or (sugar_amount+water_amount) > F:
                continue
            max_sugar_amount = max(max_sugar_amount, sugar_amount)
    density = -1.0
    if water_amount+max_sugar_amount > 0:
        density = (100*max_sugar_amount) / (water_amount+max_sugar_amount)
    else:
        continue
    if max_density < density:
        max_density = density
        ans_water = water_amount
        ans_sugar = max_sugar_amount

print((ans_water+ans_sugar), ans_sugar)    

Measured memory_bytes: 3064
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

s = ns()
n = len(s)
for i in range(n):
    s = s[:-1]
    if len(s) % 2 == 0:
        m = len(s) // 2
        count = 0
        for j in range(m):
            if s[j] == s[j + m]:
                count += 1
        if count == m:
            print(2 * m)
            exit()


Measured memory_bytes: 3064