akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    val n = s.length
    var b1 = true
    var b2 = true
    var b3 = true
    for (i in 0 until n / 2) {
        if (s[i] != s[n - 1 - i]) b1 = false
    }
    for (i in 0 until n / 4) {
        if (s[i] != s[(n - 1) / 2 - 1 - i]) b2 = false
    }
    for (i in 0 until n / 4) {
        if (s[n - 1 - i] != s[(n + 1) / 2 + i]) b3 = false
    }
    println(if (b1 && b2 && b3) "Yes" else "No")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31388
n, q = map(int, input().split())
a = list(map(int, input().split()))
x = [int(input()) for _ in range(q)]
sort_x = sorted(x)
ans = {}
if n%2== 1:
    small_position = 0
    border_position = int((n-1)/2)
else:
    small_position = 1
    border_position = int(n/2)
sum_all = sum(a[border_position:])
a.append(10000000000)
a.append(10000000000)
x_index = 0
flag = False
for compare in a[border_position:]:
    compare_x = sort_x[x_index]
    small_a = a[small_position]
    while 2*sort_x[x_index] - small_a <= compare:
        ans[sort_x[x_index]] = sum_all
        x_index += 1
        if x_index == q:
            flag = True
            break
    sum_all = sum_all + small_a - compare
    small_position += 2
    if flag:
        break

for x_i in x:
    print(ans[x_i])


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

int main() {
  int N, K, Q;
  std::cin >> N >> K >> Q;

  std::vector<int> scores(N, K - Q);  // 1回も正解できなかった場合の点数で初期化する
  for (int i = 0; i < Q; ++i) {
    int A;
    std::cin >> A;
    scores[A - 1]++;  // 正解分を加点
  }

  for (auto score : scores) {
    std::cout << (score > 0 ? "Yes" : "No") << '\n';
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


int main(){
	int n,q,a,b;
	cin>>n>>q;
	rep(i,0,q){
		cin>>a>>b;
		int ans=min(a,min(b,min(n+1-a,n+1-b)))%3;
		if(ans==0) ans=3;
		o(ans);
	}	
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int sum = 100 * a + 10 * b + c;
        String ans = (sum % 4 == 0)? "YES" : "NO";
        System.out.println(ans);
    }    
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <numeric>

std::vector<size_t> solve(const std::string s){
	std::vector<size_t> ponds;
	size_t sum = 0;
	size_t end = 0;
	for(size_t i = 0; i < s.size(); ++i){
		if(i >= end && sum != 0){ponds.push_back(sum);sum=0;}
		if(s[i] == '\\'){
			int depth = -1;
			for(size_t j = i+1; j < s.size(); ++j){
				switch(s[j]){
					case '\\':
						--depth;
						break;
					case '/':
						++depth;
						if(depth == 0){
							sum += j-i;
							if(end < j) end = j;
							goto END;
						}
						break;
				}
			}
			END:;
		}
	}

	if(end == s.size()-1 && sum != 0) ponds.push_back(end);

	return ponds;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::string s;
	std::cin >> s;
	auto ret = solve(s);
	std::cout << std::accumulate(ret.begin(),ret.end(),size_t(0)) << std::endl;
	std::cout << ret.size();
	for(auto&& v : ret){
		std::cout << ' ' << v;
	}
	std::cout << std::endl;
}

Measured memory_bytes: 3276
alp = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
nalp = []
n = int(input())
str = input()
chars = list(str)

for i in range(len(chars)):
  num = alp.index(chars[i])
  if n+num>=26:
      num -= 26
  nalp.append(alp[n+num])

mojiretu = ''
 
for x in nalp:
    mojiretu += x
print(mojiretu)


Measured memory_bytes: 3188
def main():
    N = int(input())
    A = list(map(int,input().split()))
    c = [0]*(N)
    c[0] = A[0]%(1000000007)
    for i in range(1,N,1):
        c[i] = c[i-1]+( A[i]%(1000000007) )
        c[i] = c[i]%(1000000007)
    ans = 0
    for i in range(0,N-1,1):
        A[i] = A[i]%(1000000007)
        tmp = (A[i]*(c[N-1]-c[i]))%(1000000007)
        ans += tmp

    return ans%(1000000007)

print(main())


Measured memory_bytes: 31588
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  long n, k;
  cin >> n >> k;

  long h[n];
  long count = 0;
  for (long i = 0; i < n; i++)
  {
    cin >> h[i];
    if(h[i] >= k){
      count++;
    }
  }
  cout << count << endl;
  

}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	int sum = 0;
	for(int i= 1;i<=N;i++){
		int digitSum = 0;
		int temp = i;
		while (temp != 0){
			digitSum = digitSum + temp % 10;
			temp /= 10;
		}
		if (digitSum >= A && digitSum <= B){
			sum += i;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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 main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << ' ' << max(A+B-N, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll a;
    cin >> a;

    string s;
    cin >> s;
    int n = s.size();

    ll b = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') continue;
        b *= 10;
        b += s[i] - '0';
    }

    ll r = a * b / 100;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3648
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
ans=[0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      n=i*i+j*j+k*k+i*j+j*k+k*i
      if n<10050:
        ans[n]+=1
for i in range(1,N+1):
  print(ans[i])

Measured memory_bytes: 9096
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

anslist = p[:x] + q[:y]
anslist.sort()
for i, num in enumerate(r):
    if i >= x+y:
        break
    if num > anslist[i]:
        anslist[i] = num

print(sum(anslist))

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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
ll n;
const int MAXN= 105;
const int m = 100005;
const ll inf = 1e15;
ll dp[MAXN][m];
ll val[MAXN];
ll we[MAXN];
ll solve(int pos,ll want){
    if(want < 0) return inf;
    if(pos==n){
        if(want==0)return 0;
        return inf;
    }
    ll &r = dp[pos][want];
    if(r!=-1) return r;
    ll a = solve(pos+1,want-val[pos])+we[pos];
    ll b = solve(pos+1,want);
    r = min(a,b);
    return r;
}
int main() {FIN;
    memset(dp,-1,sizeof(dp));
    ll weight;cin>>n>>weight;
    fore(i,0,n) cin>>we[i]>>val[i];
    ll ans = 0;
    fore(i,0,m){
        if(solve(0,i)<=weight)
            ans=i;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 82304
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int d = sc.nextInt();

		if(d ==25){
			System.out.println("Christmas");

		}else if(d == 24){
			System.out.println("Christmas Eve");

		}else if(d == 23){
			System.out.println("Christmas Eve Eve");

		}else{
			System.out.println("Christmas Eve Eve Eve");

		}





	}

}

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

int main() {
int N ;
string S;  
    cin >> N >> S ;
int sum=1;
  for (int i = 0; i < N-1; i++) {
	if (S.at(i)!=S.at(i+1)) sum++;
  }
 cout << sum << endl;  
}


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

template<class T>
struct FordFulkerson{
	struct Edge{
		int to,rev;
		T cap;
		Edge(int to,T cap,int rev) : to(to),rev(rev),cap(cap){}
	};

	vector<vector<Edge>> G;
	vector<bool> used;

	FordFulkerson(int n) : G(n),used(n){}

	void addEdge(int from,int to,T cap,bool isDirected = true){
		G[from].emplace_back(to,cap,G[to].size());
		G[to].emplace_back(from,isDirected ? 0 : cap,G[from].size() - 1);
	}

	T dfs(int v,int t,T f){
		if(v == t) return f;
		used[v] = true;
		for(auto &e : G[v]){
			if(!used[e.to] && e.cap){
				T d = dfs(e.to,t,min(f,e.cap));
				if(d){
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	T flow(int s,int t){
		T ret = 0;
		while(1){
			fill(used.begin(),used.end(),0);
			T f = dfs(s,t,numeric_limits<T>::max());
			if(!f) return ret;
			ret += f;
		}
	}
};

void dfs(int v,bool *visit,FordFulkerson<int> &ff,bool isRev){
	visit[v] = true;
	for(auto &e : ff.G[v]){
		if((isRev ^ e.cap) && !visit[e.to]) dfs(e.to,visit,ff,isRev);
	}
}

int n,m,s,t;

void solve(){
	bool visits[2][1010] = {};
	s--; t--;
	FordFulkerson<int> ff(n);
	int a[10010],b[10010];
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i]; a[i]--;b[i]--;
		ff.addEdge(a[i],b[i],1);
	}
	int flow = ff.flow(s,t),ans = 0;
	dfs(s,visits[0],ff,false);
	dfs(t,visits[1],ff,true);
	for(int i = 0;i < m;i++){
		if(visits[1][a[i]] && visits[0][b[i]]) ans++; 
	}
	cout << flow + !!ans << " " << ans << endl;
}

signed main(){
	while(cin >> n >> m >> s >> t,n) solve();
}


Measured memory_bytes: 3424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String inputStr1 = scan.next();
		String inputStr2 = scan.next();

		scan.close();

		System.out.println(inputStr2 + inputStr1);
	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> t(N+1), x(N+1), y(N+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 1; i <= N; i++) cin >> t[i] >> x[i] >> y[i];

    for(int i = 1; i <= N; i++) {
        int tt = t[i] - t[i-1];
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if(tt < dist || (tt-dist) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#define MAX 30000
using namespace std;
vector<int> prime;
bool isprime[30001];
typedef pair<int,int> P;
typedef pair<P,int> Pi;

void sieve()
{
  int n = MAX;
  int p = 0;
  for(int i=0;i<=n;i++)
    isprime[i] = true;

  isprime[0] = isprime[1] = false;

  for(int i=2;i<=n;i++)
    {
      if(isprime[i])
	{
	  prime.push_back(i);
	  for(int j=2*i;j<=n;j+=i)
	    isprime[j] = false;
	}
    }
}

bool isTriangle(int a,int b,int c)
{
  if(a >= b+c || b >= a+c || c >= a+b)
    return false;
  return true;
}

int main()
{
  sieve();
  int T;
  while(cin >> T,T)
    {
      int cnt = 0;
      for(int i=0;i<prime.size() && prime[i] < T;i++)
	for(int j=i;j<prime.size() && prime[i]+prime[j] < T;j++)  
	  if(T-(prime[i]+prime[j]) >= prime[j] && isprime[T-(prime[i]+prime[j])] && isTriangle(prime[i],prime[j],T-(prime[i]+prime[j])))
	    cnt++;
	    
      cout << cnt << endl;
    }
  return 0;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()

int main(){
	string s;
	cin >> s;
	string ret = "No";

	if (s[0] == s[2]) ret = "Yes";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<cctype>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int sum=0;
        for(int i=n;i<=m;i++)
        {
            int s=i;
            int flag=1;

            int cnt=0;
            int a[6];
            while(s)
            {
                a[cnt]=s%10;
                s=s/10;
                cnt++;
            }
            int p=0,q=cnt-1,t=cnt/2;
            if(cnt%2==0)
            {
                while(t--)
                {
                    if(a[p]!=a[q]){
                        flag=0;
                        break;
                    }
                    p++;q--;
                }
            }
            else
            {

                while(p!=q)
                {
                    if(a[p]!=a[q])
                    {
                        flag=0;
                        break;
                    }
                    p++;q--;
                }
            }
            if(flag==1)
                sum++;


        }
        cout<<sum<<endl;
    }
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back
#define INF 100100100
//const int INF = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

int main()
{
  int n;
  cin >> n;
  vector<ll> a;
  vector<ll> b;
  rep(i,n) {
    ll tmp;
    cin >> tmp;
    a.pb(tmp);
  }
  //b = a;
  sort(ALL(a));
  
  ll mmax = a[n-1];
  double half = (double)a[n-1]/2;
  double gosa = LLONG_MAX;
  int index = 0;

  rep(i,n-1) {
    if (gosa > (double)( abs(half-(double)a[i]) ) ) {
      gosa = (double)abs(half-(double)a[i]);
      index = i;
    } 
  }
  cout << mmax << " " << a[index] << endl;


}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'


vector<vector<int>> adj;
vector<int> p;
int ans;
int n,m;

bool check(string s){
	int total =0;
	for(int i = 0; i < m; i++){
		int cont =0;
		for(int v: adj[i]){
			if(s[v-1] == '1')
				cont++;
		}
		if(cont % 2 == p[i] % 2)
			total++;
	}
	if(total == adj.size())
		return true;
	return false;
}

void recur(int pos,string s){
	if(pos == n){
		if(check(s)){
			ans++;
		}
	}
	else{
		recur(pos+1,s+'1');
		recur(pos+1,s+'0'); 
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ans=0;
	cin >> n >> m;
	int k,x;
	p.resize(m);
	adj.resize(m);
	for(int i=0; i < m; i++){
		cin >> k;
		for(int j=0; j <k; j++){
			cin >> x;
			adj[i].push_back(x);
		}
	}
	for(int i=0; i < m; i ++){
		cin >> x;
		p[i] = x;
	}
	recur(0,"");
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int i,j;
	while(h!=0||w!=0){
		int flg=1;
		for(i=0;i<h;i++){
			int m=flg;
			for(j=0;j<w;j++){
				if(flg){
					printf("#");
					flg=0;
				}
				else{
					printf(".");
					flg=1;
				}
			}
			flg=!m;
			printf("\n");
		}
		printf("\n");
		
		scanf("%d%d",&h,&w);
	}
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;

void input(vector<int> & V);

int main()
{
    vector<int> V;
    input(V);

    //法1

    int q, k;
    cin >> q;

    while (q--)
    {
        cin >> k;
        // vector<int>::iterator it = V.begin();
        // while (*it < k && it != V.end()) 
        // {
        //     it++;
        // }
        // if (it != V.end())
        //     cout << distance(V.begin(), it);
        // else 
        //     cout << V.size();

        //也可以循环体中根据条件break
        // while (it != V.end())
        // {
        //     if (*it >= k)
        //         break;
        //     it++;
        // }
        cout << lower_bound(V.begin(), V.end(), k) - V.begin() << endl;    



    }

}

void input(vector<int> & V)
{
    int n;
    cin >> n;

    int a;
    while (n--)
    {
        cin >> a;
        V.push_back(a);
    }
}


Measured memory_bytes: 3448
#include<bits/stdc++.h>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  ll n,m,k; cin >> n >> m >> k;
  vector<ll> a(n+1),b(m+1);
  rep(i,n) cin >> a[i+1];
  rep(i,m) cin >> b[i+1];

  rep(i,n) a[i+1] += a[i];
  rep(i,m) b[i+1] += b[i];

  ll ans = 0, j = m;
  rep(i,n+1){
    if(k < a[i]) break;
    else{
      while(k < a[i] + b[j]) j--;
      chmax(ans,i+j);
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6424
S = input()

for i in range(1,len(S)+1):
    if i % 2 == 1 and S[i-1] not in 'RUD':
        print('No')
        break
    if i % 2 == 0 and S[i-1] not in 'LUD':
        print('No')
        break
else:
    print('Yes')
        


Measured memory_bytes: 2940
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 3e5+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N,M,T;
int row[maxn],col[maxn];
set<pii> st;
void solve(){
	int mxrow = 0,idr = 0,mxcol = 0,idl = 0;
	for(int i =1;i<=N;i++){
		if(row[i] > mxrow){
			mxrow = row[i];
			idr = i;
		}
	}
	for(int i = 1;i<=M;i++){
		if(col[i] > mxcol){
			mxcol = col[i];
			idl = i;
		}
	}
	int ans = 0;
	for(int j = 1;j<=M;j++){
		if(st.find({idr,j}) != st.end()){
			ans = max(ans,row[idr] + col[j] - 1);
		}else{
			ans = max(ans,row[idr] + col[j]);
		}
	}
	for(int i =1;i<=N;i++){
		if(st.find({i,idl}) != st.end()){
			ans = max(ans,row[i] + col[idl] - 1);
		}else{
			ans = max(ans,row[i] + col[idl]);
		}
	}
	cout<<ans<<'\n';
}
int main(){
	// debug;
	ios;

	cin>>N>>M>>T;
	for(int i = 1;i<=T;i++){
		int x,y;cin>>x>>y;
		row[x]++;
		col[y]++;
		st.insert({x,y});
	}

	solve();
	
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int mi = Inf, res = 0;
	rep (i, n) {
	  int p;
	  cin >> p;
	  if (mi > p) {
		res++;
		mi = min(mi, p);
	  }
	}
	cout << res << endl;
    
    return 0;
}



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

//-------------------------------

int listening(float a, float b, float c){
	int ans;
    float total_cost = a*c;

    if(b >= total_cost){
        ans = (int) c;
    }else{
        ans = (int) floor(b/a);
    };

	return ans;
}


int main() {
    float A, B, C;
    int out;

    cin >> A >> B >> C;
    out = listening(A, B, C);
    cout << out << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    string s;
    cin >> s;
    rep(i, s.size()) cout << "x";
    cout << endl;
}

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

namespace ConsoleApp9
{   
    class Program
    {
        public static void Main(string[] args) {
            long a = long.Parse(Console.ReadLine());
            long[] sss = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Array.Reverse(sss);
            for (int b = 0; b < a; b++)
            {   if(b+1==a)
                Console.Write("{0}", sss[b]);
                else
                Console.Write("{0} ",sss[b]);
                
            }
            Console.Write("\n");

        }
    }
    }

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    rep(i,h) rep(j,w){
        cin>>a[i][j];
        a[i][j]%=2;
    }
    vector<pair<int,int>> x,y;
    rep(i,h) rep(j,w){
        if(i==h-1&&j==w-1)break;
        if(a[i][j]==1){
            a[i][j]=0;
            if(j==w-1){
                a[i+1][j]=a[i+1][j]^1;
                x.push_back(make_pair(i+1,j+1));
                y.push_back(make_pair(i+2,j+1));
            }
            else{
                a[i][j+1]=a[i][j+1]^1;
                x.push_back(make_pair(i+1,j+1));
                y.push_back(make_pair(i+1,j+2));
            }
        }
    }
    cout<<(int)x.size()<<endl;
    for(int i=0;i<x.size();++i){
        cout<<x[i].first<<" "<<x[i].second<<" "<<y[i].first<<" "<<y[i].second<<endl;
    }
}



Measured memory_bytes: 5228
n,k=map(int,input().split())
w=[0 for _ in range(100001)]
for i in range(n):
    w[i]=int(input())

#最大積載量pとした時のチェック
def check(p):
    sumw=0
    idx=0

    for i in range(k):
        sumw=0
        while(w[idx]+sumw<=p):
            sumw+=w[idx]
            idx+=1
            if(idx==n):
#                print("{0}台で運べる:w[{1}]まで、 積載量{2} 最大積載量{3} ".format(i+1,idx,sumw,p))
                return True
#            print("runT:{0} {1} {2} k={3}".format(idx,sumw,p,i))
#        print("{0}台目:w[{1}]まで、 積載量{2} 最大積載量{3}".format(i+1,idx-1,sumw,p))
#    print("運べない:w[{0}]でアウト 積載量{1} 最大積載量{2} k={3}".format(idx,sumw,p,k-1))
    return False

left=0
right=100000*10000

while(right - left > 1):
    mid = (left + right)//2
#    print("最大積載量p:{0}".format(mid))
    if(check(mid)):
        right=mid
    else:
        left=mid
#    print("main:left:{0} right:{1} mid:{2}".format(left,right,mid))

print(right)



Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, A, B, C, D;
  cin >> n >> A >> B >> C >> D;
  string str;
  cin >> str;
  A--;
  B--;
  C--;
  D--;
  auto solve = [&] () {
    for (int i = A; i < C; i++) {
      if (str[i] == '#' && str[i - 1] == '#') {
        return false;
      }
    }
    for (int i = B; i < D; i++) {
      if (str[i] == '#' && str[i - 1] == '#') {
        return false;
      }
    }
    if (C < D) {
      return true;
    }
    for (int i = B; i <= D; i++) {
      if (i && i != n - 1 && str[i] == '.' && str[i - 1] == '.' && str[i + 1] == '.') {
        return true;
      }
    }
    return false;
  };
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 592
N = int(input())
h = list(map(int, input().split()))
ans = [0] * N
ans[0] = 0
ans[1] = abs(h[0]-h[1])
for i in range(2, N):
    ans[i] = min(ans[i-1]+abs(h[i-1]-h[i]), ans[i-2]+abs(h[i-2]-h[i]))
print(ans[-1])

Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	ll N;	cin>>N;
	vl A(N);
	rep(i,0,N){
		cin>>A[i];
	}
	bool buyF=1;
	vl buy(N);
	vl sell(N);
	ll j=0;
	buy[j]=A[0];
	rep(i,0,N){
		if(buyF){
			if(buy[j]>A[i]){
				buy[j]=A[i];
			}
			else if(buy[j]<A[i]){
				sell[j]=A[i];
				buyF=0;
			}
		}
		else{
			if(sell[j]<A[i]){
				sell[j]=A[i];
			}
			else if(sell[j]>A[i]){
				j++;
				buy[j]=A[i];
				buyF=1;
			}
		}
	}
	ll money=1000;
	rep(i,0,j+1){
		if(buy[i]>0&&sell[i]>0){
			DBG(i,buy[i],sell[i],"");
			ll kabu;
			kabu=money/buy[i];
			money-=kabu*buy[i];
			money+=kabu*sell[i];
		}
	}
	cout<<money<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll N,lw,le,rw,re,ans=3000000;
string S;

int main(void){
    cin >> N >> S;
    rep(i,N){
        if(S[i]=='W')rw++;
        else re++;
    }
    rep(i,N){
        if(S[i] == 'W')rw--;
        else re--;
        //cout << lw << " " <<re << endl;
        ans = min(ans,lw+re);
        if(S[i] == 'W')lw++;
        else le++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    int n_a = [](int n, int k) -> int {
        for(int i = 0;i <=n;i++){
            if(pow(2, i) > k){
                return i;
            }
        }
    }(n, k);
    std::cout<<(pow(2, n_a) + k * (n - n_a))<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")    
    #include <bits/stdc++.h>
    #define int long long
    #include<math.h>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    const int mod =1e9+7;
   


void  solve()
{
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }

  vector<int>dp(n,0);
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  int cost=0;

  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   
  }

  //arrive either from stone i-1 or stone i-2


  cout<<dp[n-1]<<endl;
 

 

 return;
  
}
 



int32_t main()
{
  int tc;
  tc=1;
  while(tc--){
    solve();
  }
  
  




  return 0;
}













 
 

 


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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  vector<vector<pair<int,int>>> P(N);   //P[i]はi番目の人の証言を格納
  
  
  rep(i,N){
    int num;
    cin >> num;
    rep(j,num){
      int a,b;
      cin >> a >> b;
      a--;
      P[i].PB(MP(a,b));
     // cout << a<<' '<< b<< endl;
    }
  }
  //cout << endl;

  int ans = 0;
  
  bool flag = false;
        
  for(int bit = 0;bit < (1<<N);++bit){
    vector<int> fact(N,0); //正直者かどうかを整理
    bool flag = false;
    int tmp = 0;   //正直者の人数
    
    rep(i,N){
      if(bit & (1<<i)){   //i番目が正直者だとすると
        fact[i] = 1;
        tmp++;
      }
    }
    
    /*rep(i,N){
      cout << fact[i] <<' ';
    }
    
    cout << endl;*/
    
    rep(i,N){
      if(fact[i]){   //i番目が正直者だとすると
        rep(j,sz(P[i])){
          //cout << i << j  << endl;
          //cout << fact[P[i][j].first] <<' '<< P[i][j].second<<endl;
          if(fact[P[i][j].first] != P[i][j].second){ //矛盾あり
            flag = true;
            break;
          }
        }
        if(flag)break;
      }
      if(flag)break;
    }
    if(flag)continue;
    
    
    //矛盾なしなのでok
    ans = max(ans,tmp);
    
  }

  cout << ans << endl;
    


}

Measured memory_bytes: 256
#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 main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
  return 0;
}


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

int main(){
int N;
double smoney = 0;
cin >> N;
vector<double> money(N);
vector<std::string> coin(N); 


for(int i =0 ; i< N; i++){
cin >> money[i] >> coin[i];
}

for(int i = 0;i<N;i++){
	if(coin[i] == "JPY"){
	smoney+=money[i];
	}else if(coin[i] == "BTC"){
	smoney += money[i]*380000;
	}
}
cout << smoney;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    long long n,count;
    scanf("%lld",&n);
    long long num[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&num[i]);
        while(num[i]%2==0){
            count=count+1;
            num[i]=num[i]/2;
        }
    }
    printf("%lld\n",count);
}

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

int main() {
  string s;
  cin >> s;
  int ans = (int)1e9;
  for (char c = 'a'; c <= 'z'; c++) {
    string t = s;
    if (t.find(c) != string::npos) {
      int cnt = 0;
      int mx = 0;
      for (int i = 0; i < t.size(); i++) {
        if (t[i] == c) {
          mx = max(cnt, mx);
          cnt = 0;
        } else {
          cnt++;
        }
      }
      mx = max(cnt, mx);
      ans = min(ans, mx);
    }
  }

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

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

int main(){
    int N;
    cin >> N;
    vector<pair<long long, pair<long long, long long>>> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i].second.first >> A[i].second.second;
        A[i].first = A[i].second.first + A[i].second.second;
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    long long ans = 0;
    for (int i = 0; i < N; i++){
        if(i % 2 == 0){
            ans += A[i].second.first;
        }else{
            ans -= A[i].second.second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

/*

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();

        // int[] A = new int[N];
        // int[] B = new int[M];

        int count = 0;
        for (int i = L; i <= R; i++) {
            // A[i] = sc.nextInt();
            if (i % d == 0) {
                count++;
            }
        }
       System.out.println(count);
    }
}

Measured memory_bytes: 35612
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define mod 1000000007
using namespace std;

ll n, m;

ll path(vector< vector<char> > &g,
        ll i, ll j,
        vector< vector<ll> > &dp) {
	if (i < 0 || j < 0 || i >= n || j >= m || g[i][j] == '#')
		return 0;
	if (dp[i][j] != -1)
		return dp[i][j];
	if (i == (n - 1) && j == (m - 1))
		return 1;
	ll ans = 0;
	g[i][j] = '#';
	ans += path(g, i + 1, j, dp);
	ans += path(g, i, j + 1, dp);
	g[i][j] = '.';
	dp[i][j] = ans % mod;
	return dp[i][j];
}

int main(void) {

	fio


	cin >> n >> m;

	vector< vector<char> > g(n, vector<char> (m));
	vector< vector<ll> > dp(n,vector<ll> (m, -1));

	for (ll i = 0; i < n; i++)
		for (ll j = 0; j < m; j++)
			cin >> g[i][j];

	cout << path(g, 0, 0, dp) << "\n";

}

Measured memory_bytes: 9216
S = input()
ans = 0
for i in range(2 ** (len(S) - 1)):
    txt = S[0]
    for j in range(len(S) - 1):
        if i >> j & 1:
            txt += " " + S[j + 1]
        else:
            txt += S[j + 1]
    ans += sum(list(map(int, txt.split())))
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
int solve(int a[],int n,int k,int p,int dp[]) { 
  if(k<0)
  return p;
  if(dp[k]==0)
  return p;
  if(dp[k]==1)
  return p^1;
  for(int i=0;i<n;i++){
  	int so=solve(a,n,k-a[i],p^1,dp);
  	if(so==p){
  	dp[k]=0;
  	return p;
  	}
  }
  dp[k]=1;
  return p^1;
} 
  
   
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  int dp[k+1];
  memset(dp,-1,sizeof(dp));
  int so=solve(a,n,k,0,dp);
  if(so==0)
  cout<<"First\n";
  else
  cout<<"Second\n";
  return 0;
}

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

int main(void){
	int H,W,res=0;
	cin>>H>>W;
	int cost[H+1][H+1]={},dp[H+1][H+1]={};
	string s[H+1];
	rep1(y,H)cin>>s[y];
	rep(x,W-1){
		rep1(i,H)rep1(j,H)cost[i][j]=(s[i][x]==s[j][x+1])+cost[i-1][j-1];
		rep(i,H+1)rep(j,H+1)if(i||j)
			dp[i][j]=min(i?dp[i-1][j]+cost[i][j]:INT_MAX,j?dp[i][j-1]+cost[i][j]:INT_MAX);
		res+=dp[H][H];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1152
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    X, Y, Z = map(int, input().split())
    X, Y = Y, X
    X, Z = Z, X
    print(X, Y, Z)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9820
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  REP(i, s.length()) {
    if (i % 2 == 0) {
      if (s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] == 'R') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


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

using namespace std;
using ll = long long;


int main(){
    ll a;
    int b0,b1;
    scanf("%Ld %d.%d", &a, &b0, &b1);
    cout << a * (b0*100+b1) / 100 << endl;
    return 0;
}

Measured memory_bytes: 3760
import java.io.IOException;
import java.util.Scanner;
import java.util.Stack;

class Solve{
	final Scanner in = new Scanner(System.in);
	char[] s;
	String curl = "()[]";
	boolean solve(){
		char[] tmp = in.nextLine().toCharArray();
		if(tmp[0] == '.') return false;
		int n = 0;
		for(int i=0; i<tmp.length; i++) if(curl.indexOf(tmp[i]) != -1) n++;
		s = new char[n];
		int idx = 0;
		for(int i=0; i<tmp.length; i++) if(curl.indexOf(tmp[i]) != -1) s[idx++] = tmp[i];
		Stack<Character> stack = new Stack<Character>();
		boolean ok = true;
		out: for(int i=0; i<s.length; i++){
			switch(s[i]){
			case '(':
				stack.push(s[i]);
				break;
			case ')':
				if(stack.isEmpty() || stack.pop() != '('){
					ok = false;
					break out;
				}
				break;
			case '[':
				stack.push(s[i]);
				break;
			case ']':
				if(stack.isEmpty() || stack.pop() != '['){
					ok = false;
					break out;
				}
				break;
			}
		}
		if(!stack.isEmpty()) ok = false;
		System.out.println(ok ? "yes" : "no");
		return true;
	}
	
}

public class Main{
	public static void main(String[] args) throws IOException{
		Solve solve = new Solve();
		while(solve.solve());
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    string s;
    cin>>s;
    int l=(sz(s)-1)/2;
    while(true){
        //cout<<l<<endl;
        //cout<<s.substr(0,l)<<","<<s.substr(l,l)<<endl;
        if(s.substr(0,l)==s.substr(l,l)){
            cout<<l*2<<endl;
            break;
        }
        l--;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    sort(all(A));
    
    ll l=0,r=N-1;
    while(r-l>=1){
        ll h=(l+r)/2;
        
        //A[h]のサイズでは合体できん?
        bool c=true;
        ll tmp=0;
        rep(i,h+1){
            tmp+=A[i];
        }
        //tmp*2>=A[i]取り込める
        FOR(i,h+1,N){
            if(tmp*2>=A[i]){
                tmp+=A[i];
            }
            else c=false;
        }
        if(!c) l=h+1;
                // h以下に解がないような条件=A[h]は条件の否定を満たしている
        else r=h;
    }
    //[r,N)
    cout<<N-r<<endl;
}



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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) <= abs(x - b)) cout << "A";
    else cout << "B";
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M, long long S, std::vector<long long> U, std::vector<long long> V, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D){
    const ll MAX_S = 2500;
    S = min(S, MAX_S);
    vector<vector<pair<int, int>>> edges(N+1);
    rep(i,0,M) {
        edges[U[i]].emplace_back(V[i], i);
        edges[V[i]].emplace_back(U[i], i);
    }
    vector<vector<ll>> cost(N+1, vector<ll>(MAX_S+1, LLONG_MAX));
    cost[1][S] = 0;
    priority_queue<pair<ll, pair<int, int>>, vector<pair<ll, pair<int, int>>>, greater<>> que; // <time, <index, S>>
    que.push({0, {-S, 1}});
    while (!que.empty()) {
        auto time = que.top().first;
        auto current = que.top().second.second;
        auto currentS = - que.top().second.first;
        que.pop();

        for (const auto p : edges[current]) {
            int next = p.first;
            int edgeIndex = p.second;
            ll nextTime = time + B[edgeIndex];
            int nextS = currentS - A[edgeIndex];
            if (nextS < 0) continue;
            if (cost[next][min<int>(nextS, MAX_S)] > nextTime) {
                cost[next][min<int>(nextS, MAX_S)] = nextTime;
                que.push({nextTime, {-min<int>(nextS, MAX_S), next}});
            }
        }

        int newS = min<int>(currentS + C[current-1], MAX_S);
        ll newTime = time + D[current-1];
        if (cost[current][newS] > newTime) {
            cost[current][newS] = newTime;
            que.push({newTime, {-newS, current}});
        }
    }
    rep(i,2,N+1) {
        ll answer = LLONG_MAX;
        rep(s,0,MAX_S+1) answer = min<ll>(answer, cost[i][s]);
        cout << answer << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long S;
    scanf("%lld",&S);
    std::vector<long long> U(M);
    std::vector<long long> V(M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&U[i]);
        scanf("%lld",&V[i]);
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, S, std::move(U), std::move(V), std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()	
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 2e5 + 100, mod = 998244353;

int seg[4*N] ={};
int n;


void update(int pos ,int val , int idx = 1 , int l = 0 , int r = n) {
	if(r - l < 2) {
		seg[idx] = val;
		return ;
	}
	int mid = (l + r) / 2;
	if(pos < mid) {
		update(pos , val , idx*2 , l , mid);
	} else update(pos , val , idx*2 + 1 ,mid , r);
	
	seg[idx] = max(seg[2*idx] , seg[2*idx + 1]);
}

int query(int x , int y , int idx = 1 , int l = 0 , int r = n) {
	if(x >= r || l >= y) return 0;
	if(x <= l && r <= y) return seg[idx];
	int mid = (l + r) / 2;
	return max(query(x , y, 2*idx    , l , mid) , 
						 query(x , y, 2*idx + 1, mid , r));
}
signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	vector<pair<int ,int > > arr;
	vector<int> x;
	
	for(int i = 0; i < n ;i ++ ) {
		int a , b; cin >> a >> b;
		arr.push_back({a , b});
		x.push_back(a);
	}
	
	sort(begin(arr) , end(arr));
	sort(begin(x) , end(x));
	int nxt[n + 1] = {};
	nxt[n - 1] = n;
	update(n - 1, n);
	
	for(int i = n - 2 ; i >= 0 ; i --) {
		int poss = lower_bound(begin(x) , end(x) , arr[i].first + arr[i].second) - begin(x);
		update(i, poss);
		nxt[i] = query(i ,poss);
		update(i, nxt[i]);
	}
	int dd[N] = {};
	dd[n] = 1;
	for(int i = n - 1; i >= 0 ; i --) {
		dd[i] = (dd[nxt[i]] + dd[i + 1]) % mod;
	}
	w << dd[0];
}


Measured memory_bytes: 17644